Created
September 11, 2011 16:49
-
-
Save teramako/1209808 to your computer and use it in GitHub Desktop.
[Vimperator-plugin]タブを削除せずに、アンロードさせるプラグイン
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* タブを削除せずに、セッションを残しつつコンテンツをアンロードさせるエコなプラグイン | |
* unload[tab] num | |
*/ | |
if (!("SS" in this)) { | |
XPCOMUtils.defineLazyServiceGetter(this, "SS", "@mozilla.org/browser/sessionstore;1", "nsISessionStore"); | |
} | |
function unloadTab (aTab) { | |
var state = SS.getTabState(aTab); | |
var tab = gBrowser.addTab(null, { skipAnimation: true }); | |
SS.setTabState(tab, state); | |
if (aTab.pinned) { | |
gBrowser.pinTab(tab); | |
} else { | |
let objState = JSON.parse(state); | |
if (objState.hidden) { | |
gBrowser.hideTab(tab); | |
TabView.moveTabTo(tab, JSON.parse(objState.extData["tabview-tab"]).groupID); | |
} | |
} | |
gBrowser.moveTabTo(tab, aTab._tPos + 1) | |
gBrowser.removeTab(aTab); | |
} | |
commands.addUserCommand(["unload[tab]"], "Unload Tabs", | |
function action (args) { | |
var str = args[0]; | |
var m = str.match(/^(\d+):?/); | |
if (!m) | |
return; | |
var tab = gBrowser.tabs[m[1]]; | |
if (tab && !tab.selected && !tab.linkedBrowser.__SS_restoreState) | |
unloadTab(tab); | |
}, { | |
literal: 0, | |
completer: function (context, args) { | |
context.anchored = false; | |
context.completions = [ | |
[tab._tPos + ": " + tab.label, tab.linkedBrowser.currentURI.spec] | |
for each(tab in Array.slice(gBrowser.tabs)) | |
if (!tab.selected && !tab.linkedBrowser.__SS_restoreState) | |
]; | |
} | |
}, true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is old version.
The latest version is here