Google chrome Chrome扩展以循环关闭未选择的选项卡
我为Safari做了这个扩展,它关闭当前页面上的非活动选项卡Google chrome Chrome扩展以循环关闭未选择的选项卡,google-chrome,tabs,Google Chrome,Tabs,我为Safari做了这个扩展,它关闭当前页面上的非活动选项卡 (var tabss = safari.application.activeBrowserWindow.tabs; for (n=0; n<tabss.length; n++) { if(tabss[n] != safari.application.activeBrowserWindow.activeTab) tabss[n].cl
(var tabss = safari.application.activeBrowserWindow.tabs;
for (n=0; n<tabss.length; n++)
{
if(tabss[n] != safari.application.activeBrowserWindow.activeTab)
tabss[n].close();
}
)
(var-tabss=safari.application.activeBrowserWindow.tabs;
对于(n=0;n这应该做到:
// when a browser action is clicked, the callback is called with the current tab
chrome.browserAction.onClicked.addListener(function(curtab)
{
// get the current window
chrome.windows.getCurrent(function(win)
{
// get an array of the tabs in the window
chrome.tabs.getAllInWindow(win.id, function(tabs)
{
for (i in tabs) // loop over the tabs
{
// if the tab is not the selected one
if (tabs[i].id != curtab.id)
{
// close it
chrome.tabs.remove(tabs[i].id)
}
}
});
});
});
哇。很快就把那些标签搞定了。谢谢。我昨晚花了几个小时来学习这些东西/想办法。哈哈。谢谢。
(
for (n=0; n<tabCount; n++)
{
if(chrome.tabs[n].id != tab.id)
chrome.tabs[n].remove();
}
)
// when a browser action is clicked, the callback is called with the current tab
chrome.browserAction.onClicked.addListener(function(curtab)
{
// get the current window
chrome.windows.getCurrent(function(win)
{
// get an array of the tabs in the window
chrome.tabs.getAllInWindow(win.id, function(tabs)
{
for (i in tabs) // loop over the tabs
{
// if the tab is not the selected one
if (tabs[i].id != curtab.id)
{
// close it
chrome.tabs.remove(tabs[i].id)
}
}
});
});
});