-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
31 lines (28 loc) · 1.17 KB
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function set(name) {
chrome.storage.sync.get(name, function (data) {
document.getElementById(name).checked = data[name];
});
document.getElementById(name).addEventListener('change', function () {
let da = {};
da[name] = document.getElementById(name).checked
chrome.storage.sync.set(da);
});
}
document.addEventListener('DOMContentLoaded', function () {
['enabled','down','noads','novideoads','norick','nocurves','noshorts','nothanks','nomix','nopink'].forEach(e => {
set(e)
})
chrome.storage.onChanged.addListener(function(changes) {
for (let key in changes) {
console.log(key)
document.getElementById(key).checked = changes[key].newValue;
}
})
var manifestData = chrome.runtime.getManifest();
document.getElementById('ver').innerHTML = 'v'+manifestData.version+' m'+manifestData.manifest_version;
chrome.commands.getAll((commands) => {
commands.forEach((command) => {
if (command.shortcut) document.querySelector('label[for="'+command.name+'"]').insertAdjacentHTML('afterend', command.shortcut.split('+').map(key => key.trim()).map(e=>{return `<kbd>${e}</kbd>`}).join('+'))
});
});
});