All pastes #211981 Raw Edit

Anonymous

public text v1 · immutable
#211981 ·published 2006-10-20 16:47 UTC
rendered paste body
function killTabbrowser()
{
	if ('TabbrowserService' in window && !TabbrowserService.initialized)
		window.setTimeout(killTabbrowser, 0);

	var b = document.getElementById('content');
	if ('__tabkiller__initialized' in b) return;


	try {
		if (b.mPrefs.getBoolPref('tabkiller.disabled')) {
			b.__tabkiller__initialized = true;
			document.documentElement.removeAttribute('tabkiller-enabled');
			return;
		}
	}
	catch(e) {
		b.mPrefs.setBoolPref('tabkiller.disabled', false);
	}

	document.documentElement.setAttribute('tabkiller-enabled', true);

	try {
		var openWindow = b.mPrefs.getBoolPref('tabkiller.openWindowInsteadOfTab');
	}
	catch(e) {
		b.mPrefs.setBoolPref('tabkiller.openWindowInsteadOfTab', false);
	}


	for (var i = 0; i < b.mTabContainer.childNodes.length; i++)
		if (b.mTabContainer.childNodes[i] != b.selectedTab)
			b.removeTab(b.mTabContainer.childNodes[i]);

	b.mStrip.collapsed = true;
	b.mStrip.hidden    = true;

	b.addTab = function(aURI, aReferrer, aCharset)
	{
		var browserURI = location.href;
		var openWindow;
		try {
			openWindow = this.mPrefs.getBoolPref('tabkiller.openWindowInsteadOfTab');
		}
		catch(e) {
			openWindow = false;
		}

		if (
			openWindow &&
			'TabbrowserService' in window &&
			TabbrowserService.winHookMode > 0
			) {
			var w = arguments.callee.caller;
			do {
				w = w.__parent__;
			}
			while (w.__parent__);
			if (w != window && w.location.href == browserURI)
				openWindow = false;
		}

		if (openWindow) {
			window.openDialog(browserURI, '_blank', 'chrome,all,dialog=no', aURI, aCharset, aReferrer);
		}
		else {
			this.loadURI(aURI, aReferrer, aCharset);
		}
		return this.selectedTab;
	};
	b.removeTab = function(aTab) {};
	b.setStripVisibilityTo = function(aShow) {};
	b.getStripVisibility = function() { return false; }

	if ('TabbrowserService' in window) {
		b.__tabextensions__addTab = b.addTab;
		b.__tabextensions__removeTab = b.removeTab;
	}


	b.__tabkiller__initialized = true;
}