It's not a dupplicate, I have already checked the question Chrome extension: Modifying the content of a webpage but it does not answer my question, since I want to block only at certain hours, thus the blocking/not blocking must be done inside the js code (according to me).
So I have a little chrome extension which I want to block some sites at some hours. I have not put the code checking the time, since it is not relevant to my problem.
manifest.json
:
{
"manifest_version": 2,
"name": "Site Blocker Extension",
"description": "This extension blocks some sites at defined hours",
"version": "1.0",
"content_scripts": [
{
"matches": ["https://www.facebook.com/*"],
"js": ["contentScript.js"]
}
],
"page_action": {
"default_icon": "icon.png",
"default_popup": "popup.html",
"default_title": "SiteBlocker Extension"
},
"permissions": ["activeTab","tabs","https://www.facebook.com/*"]
}
contentScript.js
:
chrome.tabs.executeScript({
//code: 'document.body.style.backgroundColor="red"'
code: 'document.body.textContent="<p>Go back to work :-)</p>"'
});
Neither changing the background color to red, nor suppressing the body of the html by changing it seems to work.
It's my first chrome extension: Do you have an idea what I am doing wrong ?