mirror of
https://github.com/XFox111/TabsAsideExtension.git
synced 2026-07-02 19:52:47 +03:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4559b25739 | |||
| d8c31e3da5 | |||
| 8d2c83eea6 |
@@ -26,6 +26,7 @@ jobs:
|
||||
uses: kewisch/action-web-ext@v1
|
||||
with:
|
||||
cmd: sign
|
||||
channel: listed
|
||||
source: ${{ steps.web-ext-build.outputs.target }}
|
||||
apiKey: ${{ secrets.FIREFOX_API_KEY }}
|
||||
apiSecret: ${{ secrets.FIREFOX_CLIENT_SECRET }}
|
||||
|
||||
@@ -31,6 +31,7 @@ Unfortunately, in new Chromium-based Microsoft Edge, the devs decided not to imp
|
||||
- Auto Dark mode
|
||||
- Now you can restore one tab from collection without removing
|
||||
- Now you can choose if you want to load restored tabs only when you're navigating onto them
|
||||
- Set tabs you've selected aside
|
||||
- **Now available for Firefox!**
|
||||
|
||||
## Download
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
<body>
|
||||
<div class="tabsAside background">
|
||||
<div class="tabsAside closeArea"></div>
|
||||
<aside class="tabsAside pane">
|
||||
<header>
|
||||
<h1 loc="name">Tabs aside</h1>
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
{
|
||||
"name":
|
||||
{
|
||||
"message": "Pestañas que has reservado",
|
||||
"description": "Extension name. Displayed in the manifest and pane header"
|
||||
},
|
||||
"description":
|
||||
{
|
||||
"message": "Función \"Reservar pestañas\" de Microsoft Edge clásico",
|
||||
"description": "Extension description"
|
||||
},
|
||||
"author":
|
||||
{
|
||||
"message": "Michael \"XFox\" Gordeev",
|
||||
"description": "Author name"
|
||||
},
|
||||
"options":
|
||||
{
|
||||
"message": "Opciones",
|
||||
"description": "Alternative text for options button in the pane"
|
||||
},
|
||||
"closePanel":
|
||||
{
|
||||
"message": "Cerrar",
|
||||
"description": "Alternative text for close panel button"
|
||||
},
|
||||
"loadOnRestore":
|
||||
{
|
||||
"message": "Cargar pestañas al restaurar",
|
||||
"description": "Label for option"
|
||||
},
|
||||
"showDeleteDialog":
|
||||
{
|
||||
"message": "Mostrar diálogo de confirmacion antes de eliminar un item",
|
||||
"description": "Label for option"
|
||||
},
|
||||
"swapIconAction":
|
||||
{
|
||||
"message": "Reservar pestañas al apretar el icono de la extensión (%TOGGLE_SHORTCUT% o click-derecho para abrir el panel)",
|
||||
"description": "Label for option"
|
||||
},
|
||||
"github":
|
||||
{
|
||||
"message": "Visitar la pagina de GitHub",
|
||||
"description": "Link title"
|
||||
},
|
||||
"contributors":
|
||||
{
|
||||
"message": "Contribuidores del proyecto",
|
||||
"description": "Link title"
|
||||
},
|
||||
"feedback":
|
||||
{
|
||||
"message": "Deja un comentario",
|
||||
"description": "Link title"
|
||||
},
|
||||
"buyMeACoffee":
|
||||
{
|
||||
"message": "¡Comprame un cafe!",
|
||||
"description": "Link title"
|
||||
},
|
||||
"credits":
|
||||
{
|
||||
"message": "Desarrollado por Michael 'XFox' Gordeev",
|
||||
"description": "Options menu credits"
|
||||
},
|
||||
"setAside":
|
||||
{
|
||||
"message": "Reservar las pestañas actuales",
|
||||
"description": "Save collection action name. Used in the pane, extension context menu and manifest shortcuts"
|
||||
},
|
||||
"nothingSaved":
|
||||
{
|
||||
"message": "No tienes pestañas reservadas",
|
||||
"description": "Placeholder for empty pane"
|
||||
},
|
||||
"removeTab":
|
||||
{
|
||||
"message": "Eliminar pestañas de la colección",
|
||||
"description": "Button hint on a tab card"
|
||||
},
|
||||
"restoreTabs":
|
||||
{
|
||||
"message": "Restaurar pestañas",
|
||||
"description": "Collection restore action link name"
|
||||
},
|
||||
"more":
|
||||
{
|
||||
"message": "Más...",
|
||||
"description": "Collections' more button title"
|
||||
},
|
||||
"restoreNoRemove":
|
||||
{
|
||||
"message": "Restaurar sin eliminar",
|
||||
"description": "Context action item name"
|
||||
},
|
||||
"removeCollection":
|
||||
{
|
||||
"message": "Eliminar la colección",
|
||||
"description": "Collection remove action name"
|
||||
},
|
||||
"removeCollectionConfirm":
|
||||
{
|
||||
"message": "¿Está seguro que quiere eliminar esta colección?",
|
||||
"description": "Prompt dialog content on collection deletion"
|
||||
},
|
||||
"removeTabConfirm":
|
||||
{
|
||||
"message": "¿Está seguro que quiere eliminar esta pestaña?",
|
||||
"description": "Prompt dialog content on one tab deletion"
|
||||
},
|
||||
"togglePaneContext":
|
||||
{
|
||||
"message": "Abrir panel de pestañas",
|
||||
"description": "Context action name. Used in extension context menu and manifest shortcuts"
|
||||
},
|
||||
"noTabsToSave":
|
||||
{
|
||||
"message": "No hay pestañas disponibles para reservar",
|
||||
"description": "Alert dialog message when there's no tabs to save"
|
||||
},
|
||||
"tabs":
|
||||
{
|
||||
"message": "items",
|
||||
"description": "Collection tabs counter label (e.g. 8 items)"
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,17 @@
|
||||
color: black;
|
||||
}
|
||||
|
||||
.tabsAside.closeArea
|
||||
{
|
||||
position: fixed;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.tabsAside.pane
|
||||
{
|
||||
user-select: none;
|
||||
|
||||
@@ -74,6 +74,9 @@ function Initialize()
|
||||
document.querySelector(".tabsAside header .btn.remove").addEventListener("click", () =>
|
||||
chrome.runtime.sendMessage({ command: "togglePane" })
|
||||
);
|
||||
document.querySelector(".tabsAside.closeArea").addEventListener("click", () =>
|
||||
chrome.runtime.sendMessage({ command: "togglePane" })
|
||||
);
|
||||
|
||||
document.querySelector("nav > p > small").textContent = chrome.runtime.getManifest()["version"];
|
||||
|
||||
|
||||
+104
-71
@@ -1,3 +1,21 @@
|
||||
//This variable is populated when the browser action icon is clicked, or a command is called (with a shortcut for example).
|
||||
//We can't populate it later, as selected tabs get deselected on a click inside a tab.
|
||||
var tabsToSave = [];
|
||||
|
||||
|
||||
//Get the tabs to save, either all the window or the selected tabs only, and pass them through a callback.
|
||||
function GetTabsToSave(callback)
|
||||
{
|
||||
chrome.tabs.query({ currentWindow: true }, (windowTabs) =>
|
||||
{
|
||||
var highlightedTabs = windowTabs.filter(item => item.highlighted);
|
||||
//If there are more than one selected tab in the window, we set only those aside.
|
||||
// Otherwise, all the window's tabs get saved.
|
||||
return callback((highlightedTabs.length > 1 ? highlightedTabs : windowTabs));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function TogglePane(tab)
|
||||
{
|
||||
if (tab.url.startsWith("http")
|
||||
@@ -43,50 +61,43 @@ function TogglePane(tab)
|
||||
|
||||
function ProcessCommand(command)
|
||||
{
|
||||
switch(command)
|
||||
GetTabsToSave((returnedTabs) =>
|
||||
{
|
||||
case "set-aside":
|
||||
SaveCollection();
|
||||
break;
|
||||
case "toggle-pane":
|
||||
chrome.tabs.query(
|
||||
{
|
||||
active: true,
|
||||
currentWindow: true
|
||||
},
|
||||
(tabs) => TogglePane(tabs[0])
|
||||
)
|
||||
break;
|
||||
}
|
||||
tabsToSave = returnedTabs;
|
||||
switch(command)
|
||||
{
|
||||
case "set-aside":
|
||||
SaveCollection();
|
||||
break;
|
||||
case "toggle-pane":
|
||||
chrome.tabs.query(
|
||||
{
|
||||
active: true,
|
||||
currentWindow: true
|
||||
},
|
||||
(tabs) => TogglePane(tabs[0])
|
||||
)
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
chrome.browserAction.onClicked.addListener((tab) =>
|
||||
{
|
||||
chrome.storage.sync.get({ "setAsideOnClick": false }, values =>
|
||||
GetTabsToSave((returnedTabs) =>
|
||||
{
|
||||
if (values?.setAsideOnClick)
|
||||
SaveCollection();
|
||||
else
|
||||
TogglePane(tab);
|
||||
tabsToSave = returnedTabs;
|
||||
|
||||
chrome.storage.sync.get({ "setAsideOnClick": false }, values =>
|
||||
{
|
||||
if (values?.setAsideOnClick)
|
||||
SaveCollection();
|
||||
else
|
||||
TogglePane(tab);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Adding context menu options
|
||||
chrome.contextMenus.create(
|
||||
{
|
||||
id: "toggle-pane",
|
||||
contexts: ['all'],
|
||||
title: chrome.i18n.getMessage("togglePaneContext")
|
||||
}
|
||||
);
|
||||
chrome.contextMenus.create(
|
||||
{
|
||||
id: "set-aside",
|
||||
contexts: ['all'],
|
||||
title: chrome.i18n.getMessage("setAside")
|
||||
}
|
||||
);
|
||||
|
||||
var collections = JSON.parse(localStorage.getItem("sets")) || [];
|
||||
var shortcuts;
|
||||
chrome.commands.getAll((commands) => shortcuts = commands);
|
||||
@@ -94,6 +105,27 @@ chrome.commands.getAll((commands) => shortcuts = commands);
|
||||
chrome.commands.onCommand.addListener(ProcessCommand);
|
||||
chrome.contextMenus.onClicked.addListener((info) => ProcessCommand(info.menuItemId));
|
||||
|
||||
chrome.runtime.onInstalled.addListener((reason) =>
|
||||
{
|
||||
//chrome.tabs.create({ url: "https://github.com/XFox111/TabsAsideExtension/releases/latest" });
|
||||
// Adding context menu options
|
||||
chrome.contextMenus.create(
|
||||
{
|
||||
id: "toggle-pane",
|
||||
contexts: ["browser_action"],
|
||||
title: chrome.i18n.getMessage("togglePaneContext")
|
||||
}
|
||||
);
|
||||
chrome.contextMenus.create(
|
||||
{
|
||||
id: "set-aside",
|
||||
contexts: ["browser_action"],
|
||||
title: chrome.i18n.getMessage("setAside")
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
//We receive a message from the pane aside-script, which means the tabsToSave are already assigned on message reception.
|
||||
chrome.runtime.onMessage.addListener((message, sender, sendResponse) =>
|
||||
{
|
||||
switch (message.command)
|
||||
@@ -172,48 +204,45 @@ chrome.tabs.onActivated.addListener(UpdateTheme);
|
||||
// Set current tabs aside
|
||||
function SaveCollection()
|
||||
{
|
||||
chrome.tabs.query({ currentWindow: true }, (rawTabs) =>
|
||||
var tabs = tabsToSave.filter(i => i.url != chrome.runtime.getURL("TabsAside.html") && !i.pinned && !i.url.includes("//newtab") && !i.url.includes("about:blank") && !i.url.includes("about:home"));
|
||||
|
||||
if (tabs.length < 1)
|
||||
{
|
||||
var tabs = rawTabs.filter(i => i.url != chrome.runtime.getURL("TabsAside.html") && !i.pinned && !i.url.includes("//newtab") && !i.url.includes("about:blank") && !i.url.includes("about:home"));
|
||||
alert(chrome.i18n.getMessage("noTabsToSave"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (tabs.length < 1)
|
||||
{
|
||||
alert(chrome.i18n.getMessage("noTabsToSave"));
|
||||
return;
|
||||
}
|
||||
var collection =
|
||||
{
|
||||
timestamp: Date.now(),
|
||||
tabsCount: tabs.length,
|
||||
titles: tabs.map(tab => tab.title ?? ""),
|
||||
links: tabs.map(tab => tab.url ?? ""),
|
||||
icons: tabs.map(tab => tab.favIconUrl ?? ""),
|
||||
thumbnails: tabs.map(tab => thumbnails.find(i => i.tabId == tab.id)?.url ?? "")
|
||||
};
|
||||
|
||||
var collection =
|
||||
{
|
||||
timestamp: Date.now(),
|
||||
tabsCount: tabs.length,
|
||||
titles: tabs.map(tab => tab.title ?? ""),
|
||||
links: tabs.map(tab => tab.url ?? ""),
|
||||
icons: tabs.map(tab => tab.favIconUrl ?? ""),
|
||||
thumbnails: tabs.map(tab => thumbnails.find(i => i.tabId == tab.id)?.url ?? "")
|
||||
};
|
||||
var rawData;
|
||||
if (localStorage.getItem("sets") === null)
|
||||
rawData = [collection];
|
||||
else
|
||||
{
|
||||
rawData = JSON.parse(localStorage.getItem("sets"));
|
||||
rawData.unshift(collection);
|
||||
}
|
||||
|
||||
var rawData;
|
||||
if (localStorage.getItem("sets") === null)
|
||||
rawData = [collection];
|
||||
else
|
||||
{
|
||||
rawData = JSON.parse(localStorage.getItem("sets"));
|
||||
rawData.unshift(collection);
|
||||
}
|
||||
localStorage.setItem("sets", JSON.stringify(rawData));
|
||||
|
||||
localStorage.setItem("sets", JSON.stringify(rawData));
|
||||
collections = JSON.parse(localStorage.getItem("sets"));
|
||||
|
||||
collections = JSON.parse(localStorage.getItem("sets"));
|
||||
|
||||
var newTabId;
|
||||
chrome.tabs.create({}, (tab) =>
|
||||
{
|
||||
newTabId = tab.id;
|
||||
chrome.tabs.remove(rawTabs.filter(i => !i.pinned && i.id != newTabId).map(tab => tab.id));
|
||||
});
|
||||
|
||||
UpdateTheme();
|
||||
var newTabId;
|
||||
chrome.tabs.create({}, (tab) =>
|
||||
{
|
||||
newTabId = tab.id;
|
||||
chrome.tabs.remove(tabsToSave.filter(i => !i.pinned && i.id != newTabId).map(tab => tab.id));
|
||||
});
|
||||
|
||||
UpdateTheme();
|
||||
}
|
||||
|
||||
function DeleteCollection(collectionIndex)
|
||||
@@ -251,6 +280,10 @@ function RestoreCollection(collectionIndex, removeCollection)
|
||||
});
|
||||
});
|
||||
|
||||
//We added new tabs by restoring a collection, so we refresh the array of tabs ready to be saved.
|
||||
GetTabsToSave((returnedTabs) =>
|
||||
tabsToSave = returnedTabs)
|
||||
|
||||
if (!removeCollection)
|
||||
return;
|
||||
|
||||
@@ -334,4 +367,4 @@ chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) =>
|
||||
{
|
||||
if (changeInfo.status === "complete")
|
||||
AppendThumbnail(tabId, tab)
|
||||
});
|
||||
});
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "__MSG_name__",
|
||||
"version": "1.8",
|
||||
"version": "1.9.1",
|
||||
"manifest_version": 2,
|
||||
"description": "__MSG_description__",
|
||||
"author": "__MSG_author__",
|
||||
|
||||
Reference in New Issue
Block a user