mirror of
https://github.com/XFox111/TabsAsideExtension.git
synced 2026-04-22 07:58:01 +03:00
Added thumbnails to saved tabs
This commit is contained in:
@@ -191,6 +191,8 @@
|
||||
|
||||
background-color: #c2c2c2 !important;
|
||||
background-image: url("chrome-extension://__MSG_@@extension_id__/images/tab_thumbnail.png");
|
||||
background-size: cover !important;
|
||||
background-position-x: center !important;
|
||||
|
||||
display: inline-grid !important;
|
||||
grid-template-rows: 1fr auto !important;
|
||||
|
||||
+2
-1
@@ -123,7 +123,7 @@ function AddCollection(collection)
|
||||
for (var i = 0; i < collection.links.length; i++)
|
||||
{
|
||||
rawTabs +=
|
||||
"<div title='" + collection.titles[i] + "'>" +
|
||||
"<div title='" + collection.titles[i] + "'" + ((collection.thumbnails[i]) ? " style='background-image: url(" + collection.thumbnails[i] + ")'" : "") + ">" +
|
||||
"<span value='" + collection.links[i] + "'></span>" +
|
||||
"<div>" +
|
||||
"<div" + ((collection.icons[i] == 0 || collection.icons[i] == null) ? "" : " style='background-image: url(\"" + collection.icons[i] + "\")'") + "></div>" +
|
||||
@@ -204,6 +204,7 @@ function RestoreTabs(collectionData, removeCollection = true)
|
||||
chrome.runtime.sendMessage(
|
||||
{
|
||||
command: "restoreTabs",
|
||||
removeCollection: removeCollection,
|
||||
collectionIndex: Array.prototype.slice.call(collectionData.parentElement.children).indexOf(collectionData) - 1
|
||||
},
|
||||
function ()
|
||||
|
||||
+40
-3
@@ -179,8 +179,8 @@ function SaveCollection()
|
||||
tabsCount: tabs.length,
|
||||
titles: tabs.map(tab => tab.title ?? ""),
|
||||
links: tabs.map(tab => tab.url ?? ""),
|
||||
icons: tabs.map(tab => tab.favIconUrl ?? "")//,
|
||||
//tumbnails: tabs.map(tab => chrome.tabs.captureVisibleTab)
|
||||
icons: tabs.map(tab => tab.favIconUrl ?? ""),
|
||||
thumbnails: tabs.map(tab => thumbnails.find(i => i.tabId == tab.id)?.url ?? "")
|
||||
};
|
||||
|
||||
var rawData;
|
||||
@@ -282,4 +282,41 @@ function RemoveTab(collectionIndex, tabIndex)
|
||||
localStorage.setItem("sets", JSON.stringify(collections));
|
||||
|
||||
UpdateTheme();
|
||||
}
|
||||
}
|
||||
|
||||
var thumbnails = [];
|
||||
|
||||
function AppendThumbnail(tabId, cahngeInfo, tab)
|
||||
{
|
||||
if (!tab.active || !tab.url.startsWith("http"))
|
||||
return;
|
||||
|
||||
chrome.tabs.captureVisibleTab(
|
||||
{
|
||||
format: "jpeg",
|
||||
quality: 1
|
||||
},
|
||||
function (dataUrl)
|
||||
{
|
||||
if(!dataUrl)
|
||||
{
|
||||
console.log("Failed to retrieve thumbnail");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Thumbnail retrieved");
|
||||
var item = thumbnails.find(i => i.tabId == tabId);
|
||||
if (item)
|
||||
item.url = dataUrl;
|
||||
else
|
||||
thumbnails.unshift(
|
||||
{
|
||||
tabId: tabId,
|
||||
url: dataUrl
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
chrome.tabs.onUpdated.addListener(AppendThumbnail);
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
[
|
||||
"tabs",
|
||||
"unlimitedStorage",
|
||||
"activeTab"
|
||||
"<all_urls>"
|
||||
],
|
||||
|
||||
"icons":
|
||||
|
||||
Reference in New Issue
Block a user