Building a Chrome Extension
Can a Content Script access the extension's background page?
No - Think of a content script as part of that loaded page, not as part of the extension it was packaged with (its parent extension).
What does _ precursor to name mean?
Private function.
How to send data from DOM to background script once?
Use chrome.extension.sendMessage(type, data) in your content script.
Content Script
manifest.json section for scripts which access the current page's DOM. Will execute with each page refresh.
manifest.json: required properties
name version - for auto-update system manifest_version - should be 2
manifest.json
Specifies all the special permissions required by the extension.
manifest.json: how to make an "event" background page
"background": { "scripts": ["background.js"], "persistent": false/true }
Get current page URL
window.location.href
How to add images to an extension?
Add their path to the "web_accessible_resources" array in the manifest, and append "chrome-extension://__MSG_@@extension_id__/" the URL when calling.
XHR
Another name for AJAX. Used to safely make requests across domains.
manifest.json: background
Files needed by the background tab.
What type of browser object are Chrome Extensions?
Hidden background tabs.
How to send data from DOM to background script ongoing?
Open a port on content side with chrome.runtime.connect({channel name}), and background with chrome.runtime.onConnect.addListener(onConnectFunc(portName))
manifest.json: content_scripts
Scripts which will be inserted into every page visited. Also includes CSS files.