I'm working on my first chrome extension. It is designed to toggle the display of elements on facebook.com
The problem I am facing is that facebook.com is using AJAX, so my changes only happen on refresh. I think the solution here is to use chrome.tabs.onUpdated.addListener but the console comes back with “Uncaught TypeError: Cannot read property 'onUpdated’ of undefined"
Pretty sure I have everything declared properly.. here is my manifest.json and background.js
MANIFEST.JSON
{
"name": "Facebook Display Control",
"version": "1.0",
"description": "This extension toggles the display of elements on Facebook.com",
//"background": {"page": "background.html"},
"manifest_version": 2,
"browser_action": {
"name": "Manipulate DOM",
"icons": ["icon.png"],
"default_icon": "icon.png",
"default_popup": "options.html"
},
"options_ui": {
"page": "options.html"
},
"permissions": [
"tabs",
"storage",
"webRequest",
"http://*.facebook.com/*",
"https://*.facebook.com/*"
],
"content_scripts": [ {
"js": [ "jquery-3.1.1.min.js", "background.js" ],
//"css": ["customStylex.css"],
"matches": [ "http://*.facebook.com/*", "https://*.facebook.com/*" ]
}]
}
BACKGROUND.JS
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
$(".home_right_column").css( "min-height", "0px" );
$(".home_right_column").css( "display", "none" );
chrome.storage.sync.get({"hideTrending": true}, function(e){
a = e.hideTrending;
if(a) {
$("#pagelet_trending_tags_and_topics").css( "display", "none" );
} else {
$("#pagelet_trending_tags_and_topics").css( "display", "block" );
}
});
chrome.storage.sync.get({"hideSuggestions": true}, function(e){
a = e.hideSuggestions;
if(a) {
$("#pagelet_ego_pane").css( "display", "none" );
} else {
$("#pagelet_ego_pane").css( "display", "block" );
}
});
});
Any help would be greatly appreciated!
Thanks!