1
0
mirror of https://github.com/XFox111/TabsAsideExtension.git synced 2026-04-22 07:58:01 +03:00

Added "Restore without removing" feature

This commit is contained in:
Michael Gordeev
2020-04-02 03:43:44 +03:00
parent 5f9237bddc
commit c7a7d4e40d
4 changed files with 22 additions and 14 deletions
+14 -5
View File
@@ -141,8 +141,9 @@ function AddCollection(collection)
"<div>" +
"<button title='More...'>&#xE10C;</button>" +
"<nav>" +
"<button>Add tabs to favorites</button>" +
"<button>Share tabs</button>" +
"<button>Restore without removing</button>" +
"<button hidden>Add tabs to favorites</button>" +
"<button hidden>Share tabs</button>" +
"</nav>" +
"</div>" +
"<button title='Remove collection'>&#xE106;</button>" +
@@ -156,6 +157,11 @@ function AddCollection(collection)
i.onclick = function () { RestoreTabs(i.parentElement.parentElement) };
});
list.querySelectorAll("nav button:first-child").forEach(i =>
{
i.onclick = function () { RestoreTabs(i.parentElement.parentElement.parentElement.parentElement, false) };
});
list.querySelectorAll("div > div:last-child > div > span").forEach(i =>
{
i.onclick = function () {
@@ -173,14 +179,14 @@ function AddCollection(collection)
i.onclick = function () { RemoveTabs(i.parentElement.parentElement) };
});
document.querySelectorAll(".tabsAside.pane > section > div > div:first-child > div > nav > button:first-child").forEach(i =>
/*document.querySelectorAll(".tabsAside.pane > section > div > div:first-child > div > nav > button:first-child").forEach(i =>
{
i.onclick = function () { AddToFavorites(i.parentElement.parentElement.parentElement.parentElement) };
});
document.querySelectorAll(".tabsAside.pane > section > div > div:first-child > div > nav > button:last-child").forEach(i =>
{
i.onclick = function () { ShareTabs(i.parentElement.parentElement.parentElement.parentElement) };
});
});*/
document.querySelectorAll(".tabsAside.pane > section > div > div:last-child > div > div > button").forEach(i =>
{
@@ -193,7 +199,7 @@ function SetTabsAside()
chrome.runtime.sendMessage({ command: "saveTabs" });
}
function RestoreTabs(collectionData)
function RestoreTabs(collectionData, removeCollection = true)
{
chrome.runtime.sendMessage(
{
@@ -202,6 +208,9 @@ function RestoreTabs(collectionData)
},
function ()
{
if (!removeCollection)
return;
if (collectionData.parentElement.children.length < 3)
{
RemoveElement(collectionData);