mirror of
https://github.com/XFox111/TabsAsideExtension.git
synced 2026-04-22 07:58:01 +03:00
Major 2.0 (#51)
- Added cloud storage for sets - WeblySleek UI font replaced with Segoe fonts - Reworked icons (#55) - Removed changelog auto-opening on install - 'Contributors' option replaced with 'Changelog' one - Added icons to menu items - Updated UI with Fluent UI compliance - Added tooltip on how to use selective activation (#57) - Added Italian language (#52) by @blackcat-917 - Added Brazilian Portuguese language (#53) by @amandafilizola - Updated Firefox CI/CD config - Updated README: rearranged badges and added demo GIF - Updated documentation Co-authored-by: Michael Gordeev <michael@xfox111.net> Co-authored-by: blackcat-917 <53786619+blackcat-917@users.noreply.github.com> Co-authored-by: Amanda de Paiva Filizola <amandapaivafilizola@gmail.com> Co-authored-by: Amine A <15179425+AmineI@users.noreply.github.com> Co-authored-by: Dustin Jiang <56217843+Dustin-Jiang@users.noreply.github.com>
This commit is contained in:
+52
-22
@@ -100,7 +100,7 @@ function Initialize()
|
||||
})
|
||||
);
|
||||
|
||||
// Exntension browser icon action
|
||||
// Extension browser icon action
|
||||
var swapIconAction = document.querySelector("#swapIconAction");
|
||||
chrome.storage.sync.get(
|
||||
{ "setAsideOnClick": false },
|
||||
@@ -190,11 +190,34 @@ function Initialize()
|
||||
window.open(i.value, "_blank");
|
||||
});
|
||||
|
||||
chrome.runtime.sendMessage({ command: "loadData" }, (collections) =>
|
||||
// Showing changelog badge if updated
|
||||
chrome.storage.local.get({ "showUpdateBadge": false }, values =>
|
||||
{
|
||||
if (document.querySelector(".tabsAside.pane section div") == null)
|
||||
collections.forEach(i =>
|
||||
AddCollection(i));
|
||||
if (values.showUpdateBadge)
|
||||
{
|
||||
pane.setAttribute("updated", "");
|
||||
let settingsButton = document.querySelector("header .btn.more");
|
||||
settingsButton.addEventListener("focusout", () =>
|
||||
{
|
||||
if (!pane.hasAttribute("updated"))
|
||||
return;
|
||||
pane.removeAttribute("updated");
|
||||
chrome.storage.local.set({ "showUpdateBadge": false });
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
chrome.runtime.sendMessage({ command: "loadData" }, ({ collections, thumbnails }) =>
|
||||
ReloadCollections(collections, thumbnails));
|
||||
|
||||
chrome.runtime.onMessage.addListener((message) =>
|
||||
{
|
||||
switch (message.command)
|
||||
{
|
||||
case "reloadCollections":
|
||||
ReloadCollections(message.collections, message.thumbnails);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
setTimeout(() => pane.setAttribute("opened", ""), 100);
|
||||
@@ -205,13 +228,23 @@ function UpdateLocale()
|
||||
document.querySelectorAll("*[loc]").forEach(i => i.textContent = chrome.i18n.getMessage(i.getAttribute("loc")));
|
||||
document.querySelectorAll("*[loc_alt]").forEach(i => i.title = chrome.i18n.getMessage(i.getAttribute("loc_alt")));
|
||||
|
||||
var swapActionsLabel = document.querySelector("label[loc=swapIconAction]");
|
||||
var swapActionsLabel = document.querySelector("span[loc=swapIconAction]");
|
||||
chrome.runtime.sendMessage({ command: "getShortcuts" }, (shortcuts) =>
|
||||
swapActionsLabel.textContent = swapActionsLabel.textContent.replace("%TOGGLE_SHORTCUT%", shortcuts.filter(i => i.name == "toggle-pane")[0].shortcut)
|
||||
);
|
||||
}
|
||||
|
||||
function AddCollection(collection)
|
||||
|
||||
function ReloadCollections(collections, thumbnails)
|
||||
{
|
||||
document.querySelector(".tabsAside section h2").removeAttribute("hidden");
|
||||
document.querySelectorAll(".tabsAside section > div").forEach(i => i.remove());
|
||||
|
||||
for (var collection of Object.values(collections))
|
||||
AddCollection(collection, thumbnails);
|
||||
}
|
||||
|
||||
function AddCollection(collection, thumbnails)
|
||||
{
|
||||
var list = document.querySelector(".tabsAside section");
|
||||
list.querySelector("h2").setAttribute("hidden", "");
|
||||
@@ -219,30 +252,27 @@ function AddCollection(collection)
|
||||
var rawTabs = "";
|
||||
|
||||
for (var i = 0; i < collection.links.length; i++)
|
||||
{
|
||||
rawTabs +=
|
||||
"<div title='" + collection.titles[i] + "'" + ((collection.thumbnails && collection.thumbnails[i]) ? " style='background-image: url(" + collection.thumbnails[i] + ")'" : "") + " value='" + collection.links[i] + "'>" +
|
||||
//"<span class='openTab' value='" + collection.links[i] + "'></span>" +
|
||||
"<div title='" + collection.titles[i] + "'" + (thumbnails[collection.links[i]]?.pageCapture ? " style='background-image: url(" + thumbnails[collection.links[i]].pageCapture + ")'" : "") + " value='" + collection.links[i] + "'>" +
|
||||
"<div>" +
|
||||
"<div" + ((collection.icons[i] == 0 || collection.icons[i] == null) ? "" : " style='background-image: url(\"" + collection.icons[i] + "\")'") + "></div>" +
|
||||
"<div" + (!thumbnails[collection.links[i]]?.iconUrl ? "" : " style='background-image: url(\"" + thumbnails[collection.links[i]].iconUrl + "\")'") + "></div>" +
|
||||
"<span>" + collection.titles[i] + "</span>" +
|
||||
"<button loc_alt='removeTab' class='btn remove' title='Remove tab from collection'></button>" +
|
||||
"<button loc_alt='removeTab' class='btn remove' title='Remove tab from collection'></button>" +
|
||||
"</div>" +
|
||||
"</div>";
|
||||
}
|
||||
|
||||
list.innerHTML +=
|
||||
"<div class='collectionSet'>" +
|
||||
"<div class='collectionSet' id='set_"+collection.timestamp+"'>" +
|
||||
"<div class='header'>" +
|
||||
"<input type='text' value='" + (collection.name ?? new Date(collection.timestamp).toDateString()) + "'/>" +
|
||||
"<a loc='restoreTabs' class='restoreCollection'>Restore tabs</a>" +
|
||||
"<div>" +
|
||||
"<button loc_alt='more' class='btn more' title='More...'></button>" +
|
||||
"<button loc_alt='more' class='btn more' title='More...'></button>" +
|
||||
"<nav>" +
|
||||
"<button loc='restoreNoRemove' class='restoreCollection noDelete'>Restore without removing</button>" +
|
||||
"</nav>" +
|
||||
"</div>" +
|
||||
"<button loc_alt='removeCollection' class='btn remove' title='Remove collection'></button>" +
|
||||
"<button loc_alt='removeCollection' class='btn remove' title='Remove collection'></button>" +
|
||||
"<small>" + collection.links.length + " " + chrome.i18n.getMessage("tabs") +"</small>" +
|
||||
"</div>" +
|
||||
|
||||
@@ -252,7 +282,7 @@ function AddCollection(collection)
|
||||
UpdateLocale();
|
||||
|
||||
list.querySelectorAll("input").forEach(i =>
|
||||
i.oninput = (event) => RenameCollection(i.parentElement.parentElement, event.target.value));
|
||||
i.addEventListener("focusout",(event) => RenameCollection(i.parentElement.parentElement, event.target.value)));
|
||||
|
||||
list.querySelectorAll(".restoreCollection").forEach(i =>
|
||||
i.onclick = () => RestoreTabs(i.parentElement.parentElement));
|
||||
@@ -276,7 +306,7 @@ function AddCollection(collection)
|
||||
i.onclick = () => RemoveTabs(i.parentElement.parentElement));
|
||||
|
||||
document.querySelectorAll(".set .btn.remove").forEach(i =>
|
||||
i.onclick = (args) =>
|
||||
i.onclick = () =>
|
||||
RemoveOneTab(i.parentElement.parentElement));
|
||||
}
|
||||
|
||||
@@ -291,7 +321,7 @@ function RenameCollection(collectionData, name)
|
||||
{
|
||||
command: "renameCollection",
|
||||
newName: name,
|
||||
collectionIndex: Array.prototype.slice.call(collectionData.parentElement.children).indexOf(collectionData) - 1
|
||||
collectionKey: collectionData.id
|
||||
});
|
||||
}
|
||||
|
||||
@@ -301,7 +331,7 @@ function RestoreTabs(collectionData, removeCollection = true)
|
||||
{
|
||||
command: "restoreTabs",
|
||||
removeCollection: removeCollection,
|
||||
collectionIndex: Array.prototype.slice.call(collectionData.parentElement.children).indexOf(collectionData) - 1
|
||||
collectionKey: collectionData.id
|
||||
},
|
||||
() =>
|
||||
{
|
||||
@@ -321,7 +351,7 @@ function RemoveTabs(collectionData)
|
||||
chrome.runtime.sendMessage(
|
||||
{
|
||||
command: "deleteTabs",
|
||||
collectionIndex: Array.prototype.slice.call(collectionData.parentElement.children).indexOf(collectionData) - 1
|
||||
collectionKey: collectionData.id
|
||||
},
|
||||
() => RemoveCollectionElement(collectionData)
|
||||
);
|
||||
@@ -338,7 +368,7 @@ function RemoveOneTab(tabData)
|
||||
chrome.runtime.sendMessage(
|
||||
{
|
||||
command: "removeTab",
|
||||
collectionIndex: Array.prototype.slice.call(tabData.parentElement.parentElement.parentElement.children).indexOf(tabData.parentElement.parentElement) - 1,
|
||||
collectionKey: tabData.parentElement.parentElement.id,
|
||||
tabIndex: Array.prototype.slice.call(tabData.parentElement.children).indexOf(tabData)
|
||||
},
|
||||
() =>
|
||||
|
||||
Reference in New Issue
Block a user