I am developing a chrome extension to highlight the Facebook Notifications using jQuery. I can get it to load, when Facebook loads first time, but after a while it stops working. In manifest I have tried persistent set to true and false, no difference. I have tried using background.js.
I have been fiddling with chrome.tabs.onActivated and .onHighlighted and can get an alert to show up, but my code or the jQuery $ isn't seen.
In dev tools, my extension isn't listed in the environments I can choose to use here
My Code: manifest.json
{
"name": "Facebook Your notification highlight",
"version": "0.3.2",
"description": "Highlights notifications with 'your' in the notification!",
"background": {
"scripts": ["jquery.min.js","background.js"],
"persistent": false
},
"browser_action": {
"default_icon": "icon48.png"
},
"icons": {
"48": "icon48.png",
"128": "icon128.png" },
"permissions": [ "tabs", "webNavigation", "https://www.facebook.com/" , "https://facebook.com/", "http://www.facebook.com/"],
"manifest_version": 2
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
New manifest.js
{
"name": "Facebook Your notification highlight",
"version": "0.3.3",
"description": "Highlights notifications with 'your' in the notification!",
"background": {
"scripts": ["jquery.min.js","background.js"]
},
"browser_action": {
"default_icon": "icon48.png"
},
"content_scripts": [
{
"matches": ["https://*.facebook.com/"],
"js": ["jquery.min.js","inject.js"]
}
],
"web_accessible_resources": [
"jquery.min.js",
"inject.js"
],
"icons": {
"48": "icon48.png",
"128": "icon128.png" },
"permissions": [ "activeTab", "tabs", "webNavigation", "https://www.facebook.com/" , "https://facebook.com/", "http://www.facebook.com/"],
"manifest_version": 2
}
new inject.js
//add listeners when injected
$(document).ready(function() {
AddFbListeners();
});
function AddFbListeners() {
$('div#js_11.uiScrollableAreaWrap').scroll( function() {
HighlightFb();
});
$('#fbNotificationsJewel').click ( function () {
setTimeout( HighlightFb(), 250);
});
}
function HighlightFb() {
//alert("highlight");
//highlight you
$("._33c:contains('you')").find('*').css("background-color", "#CCCC00"); //greeny yellow
//highlight your
$("._33c:contains('your')").find('*').css("background-color", "66CC00"); //darker yellow
//highlight reacted or liked
$("._33c:contains('liked')").find('*').css("background-color", "#b2b300"); //mustard
$("._33c:contains('reacted')").find('*').css("background-color", "#b2b300"); //mustard
//mentioned
$("._33c:contains('mentioned')").find('*').css("background-color", "#62b300"); //green
}