diff --git a/TabsAside.html b/TabsAside.html index ddc45c8..65c56df 100644 --- a/TabsAside.html +++ b/TabsAside.html @@ -31,11 +31,15 @@ + Visit GitHub page Leave feedback Buy me a coffee! - Backup saved tabs + v1.0 diff --git a/collections.html b/collections.html index a2cbfb2..afead31 100644 --- a/collections.html +++ b/collections.html @@ -6,6 +6,10 @@ + Visit GitHub page Leave feedback diff --git a/js/aside-script.js b/js/aside-script.js index c5f191b..d944be8 100644 --- a/js/aside-script.js +++ b/js/aside-script.js @@ -37,6 +37,26 @@ else document.querySelector(".tabsAside .saveTabs").onclick = SetTabsAside; + document.querySelector("nav > p > small").textContent = chrome.runtime.getManifest()["version"]; + + /* var loadOnRestoreCheckbox = document.querySelector("nav > p > input[type=checkbox]"); + chrome.runtime.sendMessage( + { + command: "getDiscardOption" + }, + function(loadOnRestore) + { + loadOnRestoreCheckbox.checked = loadOnRestore; + } + ); + loadOnRestoreCheckbox.addEventListener("click", function () + { + chrome.runtime.sendMessage( + { + command: "toggleDiscard" + } + ); + }); */ document.querySelectorAll(".tabsAside.pane > header nav button").forEach(i => { @@ -98,6 +118,27 @@ function InitializeStandalone() document.querySelector(".tabsAside .saveTabs").onclick = SetTabsAside; + document.querySelector("nav > p > small").textContent = chrome.runtime.getManifest()["version"]; + + /* var loadOnRestoreCheckbox = document.querySelector("nav > p > input[type=checkbox]"); + chrome.runtime.sendMessage( + { + command: "getDiscardOption" + }, + function(loadOnRestore) + { + loadOnRestoreCheckbox.checked = loadOnRestore; + } + ); + loadOnRestoreCheckbox.addEventListener("click", function () + { + chrome.runtime.sendMessage( + { + command: "toggleDiscard" + } + ); + }); */ + document.querySelectorAll(".tabsAside.pane > header nav button").forEach(i => { i.onclick = function () { window.open(i.value, '_blank'); }; @@ -142,8 +183,8 @@ function AddCollection(collection) "" + "" + "Restore without removing" + - "Add tabs to favorites" + - "Share tabs" + + // "Add tabs to favorites" + + // "Share tabs" + "" + "" + "" + @@ -164,7 +205,8 @@ function AddCollection(collection) list.querySelectorAll("div > div:last-child > div > span").forEach(i => { - i.onclick = function () { + i.onclick = function () + { chrome.runtime.sendMessage( { command: "openTab", diff --git a/js/background.js b/js/background.js index c92dd17..7688391 100644 --- a/js/background.js +++ b/js/background.js @@ -1,8 +1,8 @@ chrome.browserAction.onClicked.addListener(function (tab) { if (tab.url.startsWith("http") - && !tab.url.includes("chrome.google.com") - && !tab.url.includes("microsoftedge.microsoft.com")) + && !tab.url.includes("chrome.google.com") + && !tab.url.includes("microsoftedge.microsoft.com")) { chrome.tabs.insertCSS( { @@ -146,6 +146,15 @@ chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) case "share": ShareTabs(message.collectionIndex); break; + case "toggleDiscard": + if (localStorage.getItem("loadOnRestore") == "true") + localStorage.setItem("loadOnRestore", false); + else + localStorage.setItem("loadOnRestore", true); + break; + case "getDiscardOption": + sendResponse(localStorage.getItem("loadOnRestore") == "false" ? false : true); + break; } }); @@ -202,8 +211,10 @@ function SaveCollection() collections = JSON.parse(localStorage.getItem("sets")); - chrome.tabs.remove(rawTabs.filter(i => !i.url.startsWith("chrome-extension") && !i.url.endsWith("TabsAside.html") && !i.pinned).map(tab => tab.id)); - chrome.tabs.create({}); + var newTabId; + chrome.tabs.create({}, function(tab) { newTabId = tab.id; }); + + chrome.tabs.remove(rawTabs.filter(i => !i.url.startsWith("chrome-extension") && !i.url.endsWith("TabsAside.html") && !i.pinned && i.id != newTabId).map(tab => tab.id)); }); UpdateTheme(); @@ -225,7 +236,20 @@ function RestoreCollection(collectionIndex, removeCollection) { url: i, active: false - }); + }/* , function (tab) + { + if (localStorage.getItem("loadOnRestore") == "false" ? true : false) + { + setTimeout(function() + { + chrome.tabs.get(tab.id, function(tab1) + { + console.log(tab.url); + chrome.tabs.discard(tab1.id); + }); + }, 1000); + } + } */); }); if (!removeCollection) @@ -304,7 +328,7 @@ function AppendThumbnail(tabId, cahngeInfo, tab) }, function (dataUrl) { - if(!dataUrl) + if (!dataUrl) { console.log("Failed to retrieve thumbnail"); return; diff --git a/manifest.json b/manifest.json index 9ac0ef8..12e122f 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "Tabs Aside", - "version": "1.3", + "version": "1.3.1", "manifest_version": 2, "description": "Classic Microsoft Edge \"Tabs Aside\" feature for Chromium browsers", "author": "Michael \"XFox\" Gordeev",
v1.0 diff --git a/collections.html b/collections.html index a2cbfb2..afead31 100644 --- a/collections.html +++ b/collections.html @@ -6,6 +6,10 @@ + Visit GitHub page Leave feedback diff --git a/js/aside-script.js b/js/aside-script.js index c5f191b..d944be8 100644 --- a/js/aside-script.js +++ b/js/aside-script.js @@ -37,6 +37,26 @@ else document.querySelector(".tabsAside .saveTabs").onclick = SetTabsAside; + document.querySelector("nav > p > small").textContent = chrome.runtime.getManifest()["version"]; + + /* var loadOnRestoreCheckbox = document.querySelector("nav > p > input[type=checkbox]"); + chrome.runtime.sendMessage( + { + command: "getDiscardOption" + }, + function(loadOnRestore) + { + loadOnRestoreCheckbox.checked = loadOnRestore; + } + ); + loadOnRestoreCheckbox.addEventListener("click", function () + { + chrome.runtime.sendMessage( + { + command: "toggleDiscard" + } + ); + }); */ document.querySelectorAll(".tabsAside.pane > header nav button").forEach(i => { @@ -98,6 +118,27 @@ function InitializeStandalone() document.querySelector(".tabsAside .saveTabs").onclick = SetTabsAside; + document.querySelector("nav > p > small").textContent = chrome.runtime.getManifest()["version"]; + + /* var loadOnRestoreCheckbox = document.querySelector("nav > p > input[type=checkbox]"); + chrome.runtime.sendMessage( + { + command: "getDiscardOption" + }, + function(loadOnRestore) + { + loadOnRestoreCheckbox.checked = loadOnRestore; + } + ); + loadOnRestoreCheckbox.addEventListener("click", function () + { + chrome.runtime.sendMessage( + { + command: "toggleDiscard" + } + ); + }); */ + document.querySelectorAll(".tabsAside.pane > header nav button").forEach(i => { i.onclick = function () { window.open(i.value, '_blank'); }; @@ -142,8 +183,8 @@ function AddCollection(collection) "" + "" + "Restore without removing" + - "Add tabs to favorites" + - "Share tabs" + + // "Add tabs to favorites" + + // "Share tabs" + "" + "" + "" + @@ -164,7 +205,8 @@ function AddCollection(collection) list.querySelectorAll("div > div:last-child > div > span").forEach(i => { - i.onclick = function () { + i.onclick = function () + { chrome.runtime.sendMessage( { command: "openTab", diff --git a/js/background.js b/js/background.js index c92dd17..7688391 100644 --- a/js/background.js +++ b/js/background.js @@ -1,8 +1,8 @@ chrome.browserAction.onClicked.addListener(function (tab) { if (tab.url.startsWith("http") - && !tab.url.includes("chrome.google.com") - && !tab.url.includes("microsoftedge.microsoft.com")) + && !tab.url.includes("chrome.google.com") + && !tab.url.includes("microsoftedge.microsoft.com")) { chrome.tabs.insertCSS( { @@ -146,6 +146,15 @@ chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) case "share": ShareTabs(message.collectionIndex); break; + case "toggleDiscard": + if (localStorage.getItem("loadOnRestore") == "true") + localStorage.setItem("loadOnRestore", false); + else + localStorage.setItem("loadOnRestore", true); + break; + case "getDiscardOption": + sendResponse(localStorage.getItem("loadOnRestore") == "false" ? false : true); + break; } }); @@ -202,8 +211,10 @@ function SaveCollection() collections = JSON.parse(localStorage.getItem("sets")); - chrome.tabs.remove(rawTabs.filter(i => !i.url.startsWith("chrome-extension") && !i.url.endsWith("TabsAside.html") && !i.pinned).map(tab => tab.id)); - chrome.tabs.create({}); + var newTabId; + chrome.tabs.create({}, function(tab) { newTabId = tab.id; }); + + chrome.tabs.remove(rawTabs.filter(i => !i.url.startsWith("chrome-extension") && !i.url.endsWith("TabsAside.html") && !i.pinned && i.id != newTabId).map(tab => tab.id)); }); UpdateTheme(); @@ -225,7 +236,20 @@ function RestoreCollection(collectionIndex, removeCollection) { url: i, active: false - }); + }/* , function (tab) + { + if (localStorage.getItem("loadOnRestore") == "false" ? true : false) + { + setTimeout(function() + { + chrome.tabs.get(tab.id, function(tab1) + { + console.log(tab.url); + chrome.tabs.discard(tab1.id); + }); + }, 1000); + } + } */); }); if (!removeCollection) @@ -304,7 +328,7 @@ function AppendThumbnail(tabId, cahngeInfo, tab) }, function (dataUrl) { - if(!dataUrl) + if (!dataUrl) { console.log("Failed to retrieve thumbnail"); return; diff --git a/manifest.json b/manifest.json index 9ac0ef8..12e122f 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "Tabs Aside", - "version": "1.3", + "version": "1.3.1", "manifest_version": 2, "description": "Classic Microsoft Edge \"Tabs Aside\" feature for Chromium browsers", "author": "Michael \"XFox\" Gordeev",