You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.2 KiB
36 lines
1.2 KiB
let toggleButton = document.getElementById('toggleButton');
|
|
|
|
chrome.storage.sync.get('switchValue', function(data) {
|
|
toggleButton.checked = data.switchValue;
|
|
});
|
|
|
|
toggleButton.onclick = function(element) {
|
|
let value = this.checked;
|
|
chrome.storage.sync.set({'switchValue': value}, function() {
|
|
console.log("Switch is " + value);
|
|
});
|
|
if(value) {
|
|
function getNotificationId() {
|
|
var id = Math.floor(Math.random() * 9007199254740992) + 1;
|
|
return id.toString();
|
|
}
|
|
chrome.notifications.create(getNotificationId(), {
|
|
title: 'ytMusicNotification',
|
|
iconUrl: 'icon128.png',
|
|
type: 'basic',
|
|
message: 'The extension is active.'
|
|
}, function() {});
|
|
}
|
|
else{
|
|
function getNotificationId() {
|
|
var id = Math.floor(Math.random() * 9007199254740992) + 1;
|
|
return id.toString();
|
|
}
|
|
chrome.notifications.create(getNotificationId(), {
|
|
title: 'ytMusicNotification',
|
|
iconUrl: 'icon128.png',
|
|
type: 'basic',
|
|
message: 'The extension is inactive.'
|
|
}, function() {});
|
|
}
|
|
};
|