Skip to content

Sample extension for message passing between Chrome extension components and injected components.

Notifications You must be signed in to change notification settings

litesaber15/chrome-ext-messaging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#Chrome Extension Messaging Sample

The JavaScript components of Chrome extensions have several restrictions due to cross-origin policy. This sample extension serves as boilerplate code for first-timers.

Comedy of restrictions:

  • background.js runs independent of tabs.
  • content.js is tab-specific.
  • Only background.js can make web requests.
  • Only content.js can access DOM of the page.
  • iframe.js can neither access DOM nor make web requests.
  • background.js cannot see iframe.js and must talk to it through the content script that injected it.

background.js, iframe.js, and content scripts must rely on each other using message passing for functions they cannot perform.

popup.js works like a content script.

Here's a working example of an extension made that uses iframes: Claw4Twitter, source

About

Sample extension for message passing between Chrome extension components and injected components.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published