slides | markdown | HTML
⌂ | 0-Introduction | 1-Hello World! | 2-Architecture | 3-DOM | 4-Explosion | 5-Examples
localStorage
Add a new file background.js to the root of your project folder and paste this code.
background.js
// background.js console.log(" Hello from background.js");
Add a new file content.js to the root of your project and paste this code.
content.js
// content.js console.log(" Hello from content.js");
Manifest files use JSON, which has a strict syntax. If you have issues then try checking your manifest code using jsonlint.com.
manifest.json
chrome://extensions
{ "name": "Explode the Web! Tutorial", "description": "", "version": "1.2.0", "manifest_version": 3, "background": { "service_worker": "background.js" }, "content_scripts": [{ "matches": ["<all_urls>"], "js": ["content.js"] }] }
To find proof the extension is "working" and that the content script has loaded:
Content scripts are injected into each page, but you can also view messages from the scripts running in the background using DevTools:
Presentation comments ...