assets.zip
file you'll need to continue the tutorial.explode-tutorial
project folder./explode-tutorial/
assets/
css/
img/
libs/
js/
pages/
sounds/
background.js
content.js
manifest.json
action.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div style="width:220px; text-align:center">
<p>💥 Explode Tracked Pages!</p>
<p>Press e + ~ to test</p>
</div>
</body>
</html>
The icon identifies the browser extension in the chrome://extensions
page.
"icons": {
"16": "assets/img/explosion-icon16.png",
"32": "assets/img/explosion-icon32.png",
"64": "assets/img/explosion-icon64.png",
"128": "assets/img/explosion-icon128.png"
},
"action": {
"default_icon": {
"16": "assets/img/explosion-icon16.png",
"32": "assets/img/explosion-icon32.png"
},
"default_title": "Explode Tracked Web Pages!",
"default_popup": "action.html"
},
Let's go ahead and reference the libraries we need in our manifest.
content_script
section, and add web_accessible_resources
to the end. See documentation for details.manifest.json
on Github."content_scripts": [{
"matches": ["<all_urls>"],
"js": [
"assets/libs/anime.min-3.2.0.js",
"assets/libs/jquery-3.6.0.min.js",
"assets/libs/purify-2.3.4.js",
"assets/js/disconnect-tracking-services.js",
"assets/js/functions.js",
"assets/js/keys.js",
"assets/js/explode.js",
"content.js"
],
"css": [
"assets/css/styles.css"
],
"run_at": "document_end",
"all_frames": true
}],
"web_accessible_resources": [{
"resources": ["*.svg", "*.mp3"],
"matches": ["<all_urls>"],
"use_dynamic_url": true
}]
Press e + ~ to test
.I don't know about you but I enjoy this small function immensely.
The code that makes this work is just Javascript. I'll say two things about it:
With our extension assets ready we can start to build the tracker-tracking function!
content.js
assets/pages/test.html
and open the console.$(document).ready(() => {
console.log(`💥 The page title is ${document.title}`);
});
The console is interactive, so you can even test this on a live page.
document.body.style.backgroundColor = "red";
content.js
just under the console.log
function and before the closing });
to store a reference to all the script elements on each page.HTMLCollection
.var scriptsFoundArr = document.getElementsByTagName("script");
console.log(scriptsFoundArr);