-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
40 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
36
37
38
39
40
const allColumnsButton = document.getElementById('all-columns-button');
allColumnsButton.addEventListener("click", async (e) => {
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
const data = {
allColumns: true,
activeColumns: '',
};
chrome.tabs.sendMessage(tab.id, data);
});
function buildButton(view) {
const viewSelection = document.getElementById('view-selection');
const selectViewButton = document.createElement('button');
selectViewButton.textContent = view.name;
selectViewButton.addEventListener('click', async () => {
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
const data = {
allColumns: false,
activeColumns: view.activeColumns,
};
chrome.tabs.sendMessage(tab.id, data);
});
viewSelection.appendChild(selectViewButton);
}
function loadViews() {
chrome.storage.local.get("views", (result) => {
result.views.forEach((view) => {
buildButton(view);
});
});
}
loadViews();