Perma Tabsのためのハック

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@1920 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2008-02-26 13:21:07 +00:00
parent 4a67345964
commit e849d61e2b
2 changed files with 92 additions and 51 deletions

View File

@ -10,6 +10,19 @@ TreeStyleTabService.overrideExtensionsPreInit = function() {
); );
} }
/*
// Perma Tabs
if ('permaTabs' in window) {
// if this line exists, perma tabs crashes always. wyh?
eval('permaTabs.showPermaTab = '+
permaTabs.showPermaTab.toSource().replace(
'tab.setAttribute("permaTabId", props.id);',
'if (this.delayedStartupCall) $&'
)
);
}
*/
}; };
TreeStyleTabService.overrideExtensionsOnInitBefore = function() { TreeStyleTabService.overrideExtensionsOnInitBefore = function() {

View File

@ -929,9 +929,14 @@ catch(e) {
{ {
var funcs; var funcs;
var func; var func;
var overwriteProcess;
eval('window.BrowserLoadURL = '+ overwriteProcess = function(aName) {
window.BrowserLoadURL.toSource().replace( var overwroteFunc;
eval('overwroteFunc = '+aName);
if (overwroteFunc.toSource().indexOf('(function BrowserLoadURL') != 0) return;
eval(aName + ' = '+
overwroteFunc.toSource().replace(
'aTriggeringEvent && aTriggeringEvent.altKey', 'aTriggeringEvent && aTriggeringEvent.altKey',
<><![CDATA[ <><![CDATA[
TreeStyleTabService.checkReadyToOpenNewTab({ TreeStyleTabService.checkReadyToOpenNewTab({
@ -947,6 +952,12 @@ catch(e) {
]]></> ]]></>
) )
); );
};
overwriteProcess('window.BrowserLoadURL');
if ('permaTabs' in window &&
'window.BrowserLoadURL' in permaTabs.utils.wrappedFunctions)
overwriteProcess('permaTabs.utils.wrappedFunctions["window.BrowserLoadURL"]');
eval('nsContextMenu.prototype.openLinkInTab = '+ eval('nsContextMenu.prototype.openLinkInTab = '+
nsContextMenu.prototype.openLinkInTab.toSource().replace( nsContextMenu.prototype.openLinkInTab.toSource().replace(
@ -1040,12 +1051,12 @@ catch(e) {
} }
funcs = 'contentAreaClick __contentAreaClick __ctxextensions__contentAreaClick'.split(' '); funcs = 'contentAreaClick __contentAreaClick __ctxextensions__contentAreaClick'.split(' ');
for (var i in funcs) overwriteProcess = function(aName) {
{ var overwroteFunc;
if (funcs[i] in window && window[funcs[i]] && eval('overwroteFunc = '+aName);
/^function contentAreaClick/.test(window[funcs[i]].toString())) if (overwroteFunc.toSource().indexOf('(function contentAreaClick') != 0) return;
eval('window.'+funcs[i]+' = '+ eval(aName + ' = '+
window[funcs[i]].toSource().replace( overwroteFunc.toSource().replace(
/(openWebPanel\([^\(]+\("webPanels"\), wrapper.href\);event.preventDefault\(\);return false;\})/, /(openWebPanel\([^\(]+\("webPanels"\), wrapper.href\);event.preventDefault\(\);return false;\})/,
<><![CDATA[ <><![CDATA[
$1 $1
@ -1068,7 +1079,15 @@ catch(e) {
]]></> ]]></>
) )
); );
};
for (var i in funcs)
{
if (funcs[i] in window && window[funcs[i]])
overwriteProcess('window.'+funcs[i]);
} }
if ('permaTabs' in window &&
'window.contentAreaClick' in permaTabs.utils.wrappedFunctions)
overwriteProcess('permaTabs.utils.wrappedFunctions["window.contentAreaClick"]');
funcs = 'gotoHistoryIndex BrowserForward BrowserBack __rewindforward__BrowserForward __rewindforward__BrowserBack'.split(' '); funcs = 'gotoHistoryIndex BrowserForward BrowserBack __rewindforward__BrowserForward __rewindforward__BrowserBack'.split(' ');
for (var i in funcs) for (var i in funcs)
@ -1087,14 +1106,23 @@ catch(e) {
} }
func = 'BrowserGoHome' in window ? 'BrowserGoHome' : 'BrowserHomeClick' ; func = 'BrowserGoHome' in window ? 'BrowserGoHome' : 'BrowserHomeClick' ;
eval('window.'+func+' = '+ overwriteProcess = function(aName, aFunc) {
window[func].toSource().replace( var overwroteFunc;
eval('overwroteFunc = '+aName);
if (overwroteFunc.toSource().indexOf('(function '+func) != 0) return;
eval(aName + ' = '+
overwroteFunc.toSource().replace(
'gBrowser.loadTabs(', 'gBrowser.loadTabs(',
<><![CDATA[ <><![CDATA[
TreeStyleTabService.readyToOpenNewTabGroup(gBrowser); TreeStyleTabService.readyToOpenNewTabGroup(gBrowser);
gBrowser.loadTabs(]]></> gBrowser.loadTabs(]]></>
) )
); );
};
overwriteProcess('window.'+func);
if ('permaTabs' in window &&
'window.BrowserHomeClick' in permaTabs.utils.wrappedFunctions)
overwriteProcess('permaTabs.utils.wrappedFunctions["window.BrowserHomeClick"]');
eval('nsBrowserAccess.prototype.openURI = '+ eval('nsBrowserAccess.prototype.openURI = '+
nsBrowserAccess.prototype.openURI.toSource().replace( nsBrowserAccess.prototype.openURI.toSource().replace(