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:
+2
-7
@@ -162,15 +162,10 @@
|
|||||||
line-height: initial !important;
|
line-height: initial !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tabsAside.pane > section > div > div:first-child > div
|
|
||||||
{
|
|
||||||
display: none !important; /* TODO: Implement this menu */
|
|
||||||
}
|
|
||||||
|
|
||||||
.tabsAside.pane > section > div > div:first-child > div > nav
|
.tabsAside.pane > section > div > div:first-child > div > nav
|
||||||
{
|
{
|
||||||
width: 200px !important;
|
width: 250px !important;
|
||||||
margin-top: 10px !important;
|
margin-top: 40px !important;
|
||||||
right: 50px !important;
|
right: 50px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,6 +108,7 @@
|
|||||||
cursor: pointer !important;
|
cursor: pointer !important;
|
||||||
background-color: transparent !important;
|
background-color: transparent !important;
|
||||||
border: none !important;
|
border: none !important;
|
||||||
|
box-sizing: border-box !important;
|
||||||
|
|
||||||
font-size: medium !important;
|
font-size: medium !important;
|
||||||
text-align: start !important;
|
text-align: start !important;
|
||||||
|
|||||||
+14
-5
@@ -141,8 +141,9 @@ function AddCollection(collection)
|
|||||||
"<div>" +
|
"<div>" +
|
||||||
"<button title='More...'></button>" +
|
"<button title='More...'></button>" +
|
||||||
"<nav>" +
|
"<nav>" +
|
||||||
"<button>Add tabs to favorites</button>" +
|
"<button>Restore without removing</button>" +
|
||||||
"<button>Share tabs</button>" +
|
"<button hidden>Add tabs to favorites</button>" +
|
||||||
|
"<button hidden>Share tabs</button>" +
|
||||||
"</nav>" +
|
"</nav>" +
|
||||||
"</div>" +
|
"</div>" +
|
||||||
"<button title='Remove collection'></button>" +
|
"<button title='Remove collection'></button>" +
|
||||||
@@ -156,6 +157,11 @@ function AddCollection(collection)
|
|||||||
i.onclick = function () { RestoreTabs(i.parentElement.parentElement) };
|
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 =>
|
list.querySelectorAll("div > div:last-child > div > span").forEach(i =>
|
||||||
{
|
{
|
||||||
i.onclick = function () {
|
i.onclick = function () {
|
||||||
@@ -173,14 +179,14 @@ function AddCollection(collection)
|
|||||||
i.onclick = function () { RemoveTabs(i.parentElement.parentElement) };
|
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) };
|
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 =>
|
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) };
|
i.onclick = function () { ShareTabs(i.parentElement.parentElement.parentElement.parentElement) };
|
||||||
});
|
});*/
|
||||||
|
|
||||||
document.querySelectorAll(".tabsAside.pane > section > div > div:last-child > div > div > button").forEach(i =>
|
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" });
|
chrome.runtime.sendMessage({ command: "saveTabs" });
|
||||||
}
|
}
|
||||||
|
|
||||||
function RestoreTabs(collectionData)
|
function RestoreTabs(collectionData, removeCollection = true)
|
||||||
{
|
{
|
||||||
chrome.runtime.sendMessage(
|
chrome.runtime.sendMessage(
|
||||||
{
|
{
|
||||||
@@ -202,6 +208,9 @@ function RestoreTabs(collectionData)
|
|||||||
},
|
},
|
||||||
function ()
|
function ()
|
||||||
{
|
{
|
||||||
|
if (!removeCollection)
|
||||||
|
return;
|
||||||
|
|
||||||
if (collectionData.parentElement.children.length < 3)
|
if (collectionData.parentElement.children.length < 3)
|
||||||
{
|
{
|
||||||
RemoveElement(collectionData);
|
RemoveElement(collectionData);
|
||||||
|
|||||||
+5
-2
@@ -129,7 +129,7 @@ chrome.runtime.onMessage.addListener(function (message, sender, sendResponse)
|
|||||||
SaveCollection();
|
SaveCollection();
|
||||||
break;
|
break;
|
||||||
case "restoreTabs":
|
case "restoreTabs":
|
||||||
RestoreCollection(message.collectionIndex);
|
RestoreCollection(message.collectionIndex, message.removeCollection);
|
||||||
sendResponse();
|
sendResponse();
|
||||||
break;
|
break;
|
||||||
case "deleteTabs":
|
case "deleteTabs":
|
||||||
@@ -211,7 +211,7 @@ function DeleteCollection(collectionIndex)
|
|||||||
UpdateTheme();
|
UpdateTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
function RestoreCollection(collectionIndex)
|
function RestoreCollection(collectionIndex, removeCollection)
|
||||||
{
|
{
|
||||||
collections[collectionIndex].links.forEach(i =>
|
collections[collectionIndex].links.forEach(i =>
|
||||||
{
|
{
|
||||||
@@ -222,6 +222,9 @@ function RestoreCollection(collectionIndex)
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!removeCollection)
|
||||||
|
return;
|
||||||
|
|
||||||
collections = collections.filter(i => i != collections[collectionIndex]);
|
collections = collections.filter(i => i != collections[collectionIndex]);
|
||||||
localStorage.setItem("sets", JSON.stringify(collections));
|
localStorage.setItem("sets", JSON.stringify(collections));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user