I am trying to code extension that corrects misspellings on 1 forum.
I am trying to access <p>
tag, with content script, but it doesn't change anything (using the code below):
document.addEventListener("DOMContentLoaded", function() {
document.getElementsByTagName("P")[4].innerHTML = "correct_word";
});
It doesn't change anything when added as an extension, apparently if I wget
the page, and put the script there, all works. Any thoughts?
My manifest.json file:
{
"manifest_version": 2,
"name": "Extension",
"description": "Description",
"version": "1.0",
"content_scripts": [{
"run_at": "document_end",
"matches": ["http://example.com/"],
"js": ["script.js"]
}],
"web_accessible_resources": ["Filedeleted(really).html"]
}
I know content scripts and WWW pages have different sandboxes, maybe content script can't access page (and tag)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…