/* * タブを削除せずに、セッションを残しつつコンテンツをアンロードさせるエコなコマンド * unload[tab] num */ /* Thu, 11 Jul 2013 01:55:46 +0800 unload[tab] negative_number for unload all tab without seleted tab set tab title opacity when unload or restore */ var INFO = xml` teramako MPL 1.1/GPL 2.0/LGPL 2.1 :unloadtab :unload :unloadtab tabNumber

Unload the tab contents.

`; if (!("SS" in this)) { XPCOMUtils.defineLazyServiceGetter(this, "SS", "@mozilla.org/browser/sessionstore;1", "nsISessionStore"); } function unloadTab (aTab) { var browser = aTab.linkedBrowser, state = SS.getTabState(aTab), shistory = browser.sessionHistory, icon = aTab.getAttribute("image"); browser.addEventListener("load", function onload(){ this.removeEventListener("load", onload, true); if (shistory.count > 1) shistory.PurgeHistory(shistory.count -1); aTab.ownerDocument.defaultView.setTimeout(function(){ aTab.setAttribute("image", icon); }, 0); SS.setTabState(aTab, state); }, true); browser.loadURI("about:blank"); } 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), tab.style.opacity = 0.5 ; // unload other tabs if (m[1] < 0) for each(tab in Array.slice(gBrowser.tabs)) if(tab && !tab.selected){ if(!tab.linkedBrowser.__SS_restoreState) unloadTab(tab); tab.style.opacity = 0.5 ; } }, { 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); // the listener for recovering opacity gBrowser.tabContainer.addEventListener('SSTabRestored', function tabRestored(event){ var tab = event.originalTarget ; tab.style.opacity = 1 ; } , true);