Skip to content
Snippets Groups Projects
Commit 148e4a8a authored by Anton Bershanskiy's avatar Anton Bershanskiy
Browse files

Simplified injection process

parent 2674cdcc
No related branches found
No related tags found
No related merge requests found
// This code is executed in the background context
// source: https://stackoverflow.com/questions/9862182/on-page-load-event-in-chrome-extensions
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/executeScript
// Listen for the navigation event
chrome.webNavigation.onCompleted.addListener (function(details) {
// Execute the context script in its own context with "clean DOM"
chrome.tabs.executeScript(details.tabId, {
file: "/content_scripts/inject.js"
});
});
\ No newline at end of file
......@@ -11,9 +11,7 @@
},
"permissions": [
"storage",
"cookies",
"tabs",
"webNavigation"
"cookies"
],
"optional_permissions": [
"webRequest",
......@@ -30,12 +28,14 @@
],
"persistent": true
},
"content_scripts": [ {
"matches":["http://*/", "https://*/"],
"all_frames": true,
"js": [ "content_scripts/inject.js" ],
"run_at": "document_start"
} ],
"content_scripts": [
{
"matches":["http://*/", "https://*/"],
"all_frames": true,
"js": [ "content_scripts/inject.js" ],
"run_at": "document_start"
}
],
"web_accessible_resources": [
"web_accessible_resources/*"
]
......
// This code is executed in the context of the window
var veryConvolutedInjection = 4;
var injectionSuccessful = true;
console.log("Injection completed, try logging the variable veryConvolutedInjection");
\ No newline at end of file
console.log("Injection completed, try logging the variable injectionSuccessful");
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment