Added reload on SOMtonight toggle
This commit is contained in:
parent
26ba99b803
commit
40a469de0e
@ -2,6 +2,9 @@ console.log('Somtoday\'nt content script active');
|
|||||||
|
|
||||||
function changeSlogan(message)
|
function changeSlogan(message)
|
||||||
{
|
{
|
||||||
|
if (message == 'reload') {
|
||||||
|
location.reload();
|
||||||
|
} else {
|
||||||
tonight = message[0];
|
tonight = message[0];
|
||||||
slogans = message[1];
|
slogans = message[1];
|
||||||
|
|
||||||
@ -49,6 +52,7 @@ function changeSlogan(message)
|
|||||||
var cssTag = `<link rel='stylesheet' href='${cssUrl}'>`;
|
var cssTag = `<link rel='stylesheet' href='${cssUrl}'>`;
|
||||||
document.body.innerHTML += cssTag;
|
document.body.innerHTML += cssTag;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send request to background script
|
// Send request to background script
|
||||||
|
@ -13,6 +13,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"permissions": [
|
||||||
|
"tabs",
|
||||||
|
"storage"
|
||||||
|
],
|
||||||
|
|
||||||
"icons": {
|
"icons": {
|
||||||
"25" : "assets/icons/25.png",
|
"25" : "assets/icons/25.png",
|
||||||
"32" : "assets/icons/32.png",
|
"32" : "assets/icons/32.png",
|
||||||
|
@ -49,12 +49,30 @@ request.then(function(message) {
|
|||||||
checkbox.checked = true;
|
checkbox.checked = true;
|
||||||
}
|
}
|
||||||
checkbox.addEventListener('click', function(event) {
|
checkbox.addEventListener('click', function(event) {
|
||||||
|
// Update value in local storage
|
||||||
request = browser.runtime.sendMessage({
|
request = browser.runtime.sendMessage({
|
||||||
type: "setTonight",
|
type: "setTonight",
|
||||||
value: checkbox.checked
|
value: checkbox.checked
|
||||||
});
|
});
|
||||||
|
// Reload all SOMtoday tabs
|
||||||
|
var reload = browser.tabs.query({});
|
||||||
|
reload.then(logTabs, onError);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Find id of somtoday.nl tab
|
||||||
|
function logTabs(tabs) {
|
||||||
|
for (let tab of tabs) {
|
||||||
|
// Match only tabs with url somtoday.nl
|
||||||
|
if (tab.url.includes('somtoday.nl')) {
|
||||||
|
browser.tabs.sendMessage(tab.id, 'reload');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle query errors
|
||||||
|
function onError(error) {
|
||||||
|
console.log(`Error: ${error}`);
|
||||||
|
}
|
||||||
|
|
||||||
// Add existing slogans to list items in the popup
|
// Add existing slogans to list items in the popup
|
||||||
var sloganList = '';
|
var sloganList = '';
|
||||||
|
Loading…
Reference in New Issue
Block a user