Currently, I am in the process of developing a Google Chrome extension that is designed to hide the "news" section located on the right-hand side of Facebook, along with the ads displayed on the right side. Additionally, the background color is meant to be changed to black.
At this moment, I am facing an issue where upon loading Facebook, the news and white background briefly appear for a split second before disappearing. It appears that setting the run_at
attribute to document_end
causes my JavaScript code to run after the page has already been loaded. I have attempted using both document_start
and document_idle
with similar outcomes. How can I prevent the news section from showing up altogether?
manifest.json:
{
"manifest_version": 2,
"name": "FB_Trending_Hide_ChromeExtension",
"description": "This extension will hide the trending news section of Facebook",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png"
},
"content_scripts": [{
"run_at": "document_end",
"matches": ["*://*.facebook.com/*"],
"js": ["content.js"],
"all_frames": true
}],
"permissions": [
"tabs", "*://*.facebook.com/*", "activeTab"
]
}
content.js:
document.getElementById("pagelet_trending_tags_and_topics").style.display = 'none';
document.getElementById("pagelet_ego_pane").style.display = 'none';
document.body.style.background = 'black';