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)
|
||||
{
|
||||
if (message == 'reload') {
|
||||
location.reload();
|
||||
} else {
|
||||
tonight = message[0];
|
||||
slogans = message[1];
|
||||
|
||||
@ -50,6 +53,7 @@ function changeSlogan(message)
|
||||
document.body.innerHTML += cssTag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Send request to background script
|
||||
browser.runtime.sendMessage({ type: "get"});
|
||||
|
@ -13,6 +13,11 @@
|
||||
}
|
||||
},
|
||||
|
||||
"permissions": [
|
||||
"tabs",
|
||||
"storage"
|
||||
],
|
||||
|
||||
"icons": {
|
||||
"25" : "assets/icons/25.png",
|
||||
"32" : "assets/icons/32.png",
|
||||
|
@ -49,12 +49,30 @@ request.then(function(message) {
|
||||
checkbox.checked = true;
|
||||
}
|
||||
checkbox.addEventListener('click', function(event) {
|
||||
// Update value in local storage
|
||||
request = browser.runtime.sendMessage({
|
||||
type: "setTonight",
|
||||
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
|
||||
var sloganList = '';
|
||||
|
Loading…
Reference in New Issue
Block a user