-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtab_data.js
36 lines (31 loc) · 1.19 KB
/
tab_data.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
const saveWindowData = (event) => {
const clickedBtnId = parseInt(event.toElement.id);
const windowData = currentWindowsData[clickedBtnId - 1];
let isAlreadySaved = false;
for (let i = 0; i < localStorage.length; i++) {
if (localStorage.getItem("saved_window" + (i + 1)) == JSON.stringify(windowData)) {
alert('Already saved! Please check the Saved Windows!');
isAlreadySaved = true;
break;
}
}
if (!isAlreadySaved) {
localStorage.setItem("saved_window" + (localStorage.length + 1), JSON.stringify(windowData));
savedSectionData();
}
}
const removeWindowData = (event) => {
const clickedBtnId = parseInt(event.toElement.id);
localStorage.removeItem("saved_window" + clickedBtnId);
savedSectionData();
}
const loadWindow = (event) => {
const clickedBtnId = parseInt(event.toElement.id);
const clickedWindowTabs = JSON.parse(localStorage.getItem("saved_window" + clickedBtnId));
let urls = [];
for (let tabIdx = 0; tabIdx < clickedWindowTabs.length; tabIdx++) {
const tab = clickedWindowTabs[tabIdx];
urls.push(tab.url);
}
chrome.windows.create({ url: urls });
}