forked from arantius/resurrect-pages
-
Notifications
You must be signed in to change notification settings - Fork 3
/
popup.js
35 lines (31 loc) · 1 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
32
33
34
35
chrome.storage.local.get('openIn', res => {
document.querySelectorAll('input[type=radio]').forEach(el => {
el.checked = el.value == res.openIn;
});
});
document.querySelectorAll('*[data-locale]').forEach(el => {
el.appendChild(document.createTextNode(
' ' + chrome.i18n.getMessage(el.getAttribute('data-locale'))
));
});
function onOpenInChange() {
setOpenIn(document.querySelector('input[name="openIn"]:checked').value);
};
document.querySelectorAll('input[type=radio]').forEach(el => {
el.addEventListener('click', onOpenInChange, true);
});
function resurrect(gen) {
return function() {
chrome.tabs.query({active: true, currentWindow: true}, tabObj => {
logLastError();
let url = gen(tabObj[0].url);
console.info('Resurrecting via URL', url);
goToUrl(url, openIn, tabObj[0].id);
window.close();
});
}
}
document.querySelectorAll('button').forEach(el => {
el.addEventListener(
'click', resurrect(window[el.getAttribute('data-gen')]), true);
});