-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
32 lines (25 loc) · 1.06 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
import unloader from './lib/unloader.js';
// Item of Menu Options
const menuItems = ['unloadSelected', 'unloadAllExceptSelected', 'unloadAll', 'unloadAllFromThisWindowExceptSelected', 'unloadAllFromThisWindow'];
// Create element of popup page
const menu = document.getElementById('menu');
for (let menuItem of menuItems) {
const menuOption = document.createElement('a');
menuOption.classList.add("item");
menuOption.textContent = chrome.i18n.getMessage(menuItem);
menuOption.addEventListener('click', () => {
window.close();
unloader(menuItem);
});
menu.appendChild(menuOption);
}
const divider = document.createElement('div');
divider.classList.add('ts-divider');
menu.appendChild(divider);
const preferenceButton = document.createElement('a');
preferenceButton.classList.add('item');
preferenceButton.textContent = chrome.i18n.getMessage('preference');
preferenceButton.addEventListener('click', () => {
chrome.tabs.create({ 'url': chrome.runtime.getURL('preference/preference.html') });
});
menu.appendChild(preferenceButton);