I have the following code for a chrome extension, the contentscript.py as per another question on stackoverflow:
manifest.js
{
"name": "test script",
"version": "0.1",
"content_scripts": [{
"js": ["contentscript.js"],
"matches": ["http://*/*"]
}],
"manifest_version": 2,
"web_accessible_resources": ["script.js"]
}
contentscript.js
var s = document.createElement('script');
s.src = chrome.extension.getURL('script.js');
(document.head||document.documentElement).appendChild(s);
s.onload = function() {
s.parentNode.removeChild(s);
};
script.js
document.body.innerHTML = document.body.innerHTML.replace(new RegExp("this", "gi"), "that");
In order to simply replace some text. If I put the same expression that is on script.js on a test html file, it works, but it in the extension it doesn't appear as though the code is actually injected. I cannot for the life of me figure out why. The manifest and the contentscript seem in order, so I don't know what to do here.