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-color: #c2c2c2 !important;
|
||||||
background-image: url("chrome-extension://__MSG_@@extension_id__/images/tab_thumbnail.png");
|
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;
|
display: inline-grid !important;
|
||||||
grid-template-rows: 1fr auto !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++)
|
for (var i = 0; i < collection.links.length; i++)
|
||||||
{
|
{
|
||||||
rawTabs +=
|
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>" +
|
"<span value='" + collection.links[i] + "'></span>" +
|
||||||
"<div>" +
|
"<div>" +
|
||||||
"<div" + ((collection.icons[i] == 0 || collection.icons[i] == null) ? "" : " style='background-image: url(\"" + collection.icons[i] + "\")'") + "></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(
|
chrome.runtime.sendMessage(
|
||||||
{
|
{
|
||||||
command: "restoreTabs",
|
command: "restoreTabs",
|
||||||
|
removeCollection: removeCollection,
|
||||||
collectionIndex: Array.prototype.slice.call(collectionData.parentElement.children).indexOf(collectionData) - 1
|
collectionIndex: Array.prototype.slice.call(collectionData.parentElement.children).indexOf(collectionData) - 1
|
||||||
},
|
},
|
||||||
function ()
|
function ()
|
||||||
|
|||||||
+39
-2
@@ -179,8 +179,8 @@ function SaveCollection()
|
|||||||
tabsCount: tabs.length,
|
tabsCount: tabs.length,
|
||||||
titles: tabs.map(tab => tab.title ?? ""),
|
titles: tabs.map(tab => tab.title ?? ""),
|
||||||
links: tabs.map(tab => tab.url ?? ""),
|
links: tabs.map(tab => tab.url ?? ""),
|
||||||
icons: tabs.map(tab => tab.favIconUrl ?? "")//,
|
icons: tabs.map(tab => tab.favIconUrl ?? ""),
|
||||||
//tumbnails: tabs.map(tab => chrome.tabs.captureVisibleTab)
|
thumbnails: tabs.map(tab => thumbnails.find(i => i.tabId == tab.id)?.url ?? "")
|
||||||
};
|
};
|
||||||
|
|
||||||
var rawData;
|
var rawData;
|
||||||
@@ -283,3 +283,40 @@ function RemoveTab(collectionIndex, tabIndex)
|
|||||||
|
|
||||||
UpdateTheme();
|
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",
|
"tabs",
|
||||||
"unlimitedStorage",
|
"unlimitedStorage",
|
||||||
"activeTab"
|
"<all_urls>"
|
||||||
],
|
],
|
||||||
|
|
||||||
"icons":
|
"icons":
|
||||||
|
|||||||
Reference in New Issue
Block a user