{
"name" : "TabBasket " ,
"version" : "1.5" ,
"permissions" : [
"tabs" , "http://*/*"
],
"background_page" : "back.html" ,
"browser_action" : {
"default_title" : "Closed tabs" ,
"default_icon" : "icon.png" ,
"popup" : "popup.html"
}
}
* This source code was highlighted with Source Code Highlighter .
/* Tab constructor function. */
function AnyTab()
{
this .id = 0
this .url = ""
this .name = ""
this .favicon = ""
}
* This source code was highlighted with Source Code Highlighter .
var active = []
var closedTabs = []
var maxTabCount = 15
* This source code was highlighted with Source Code Highlighter .
chrome.tabs.onUpdated.addListener(onTabUpdated)
chrome.tabs.onRemoved.addListener(onTabRemoved)
chrome.tabs.onCreated.addListener(onTabCreated)
* This source code was highlighted with Source Code Highlighter .
function updateTab(index, tab) {
/* Add new tab. index = -1 passed in onTabCreated */
if (index === -1) {
var newTab = new AnyTab()
newTab.id = tab.id
newTab.url = tab.url
newTab.name = tab.title
newTab.favicon = tab.favIconUrl
active.push(newTab)
}
/* Or update tab. Find index first. */
else {
var j, tbCt = active.length
for ( j = 0; j < tbCt; j++ ) {
if ( index == active[j].id )
break
}
if ( j == tbCt ) {
console.log( "updateTab not found ID " +index)
return
}
active[j].id = tab.id
active[j].url = tab.url
active[j].name = tab.title
active[j].favicon = tab.favIconUrl || "icon.png"
}
}
* This source code was highlighted with Source Code Highlighter .
var back = chrome.extension.getBackgroundPage()
for ( var k = back.closedTabs.length - 1; k >= 0; k--) {
document .write ( "<div id='" + back.closedTabs[k].id + "' onclick='divClick(this)' class='divClass'>" )
document .write ( "<img src=" + back.closedTabs[k].favicon + " class='imgClass'>" )
var txtName = back.closedTabs[k].name
if (txtName.length > 40)
txtName = txtName.substr(0, 35) + "..."
document .write ( "<span class='labelClass'>" + txtName + "</span>" )
document .write ( "</div>" )
}
* This source code was highlighted with Source Code Highlighter .
var divs = document .getElementsByTagName( "div" );
for ( var i = 0; i < divs.length; i++)
{
if (divs[i].id === "toolDiv" ) {
divs[i].onclick = cleanToolClick
} else {
divs[i].onmouseover = mouseOverEvent
divs[i].onmouseout = mouseOutEvent
}
}
* This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/127676/