From e849d61e2b738589e6e10b2294f9eb80aa62e6ee Mon Sep 17 00:00:00 2001 From: piro Date: Tue, 26 Feb 2008 13:21:07 +0000 Subject: [PATCH] =?UTF-8?q?Perma=20Tabs=E3=81=AE=E3=81=9F=E3=82=81?= =?UTF-8?q?=E3=81=AE=E3=83=8F=E3=83=83=E3=82=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@1920 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/hacks.js | 13 +++ content/treestyletab/treestyletab.js | 130 ++++++++++++++++----------- 2 files changed, 92 insertions(+), 51 deletions(-) diff --git a/content/treestyletab/hacks.js b/content/treestyletab/hacks.js index b2d10345..a3f19e69 100644 --- a/content/treestyletab/hacks.js +++ b/content/treestyletab/hacks.js @@ -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() { diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index 1e3c844c..2b00f5e4 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -929,24 +929,35 @@ catch(e) { { var funcs; var func; + var overwriteProcess; + + overwriteProcess = function(aName) { + var overwroteFunc; + eval('overwroteFunc = '+aName); + if (overwroteFunc.toSource().indexOf('(function BrowserLoadURL') != 0) return; + eval(aName + ' = '+ + overwroteFunc.toSource().replace( + 'aTriggeringEvent && aTriggeringEvent.altKey', + <> + ) + ); + }; + overwriteProcess('window.BrowserLoadURL'); + if ('permaTabs' in window && + 'window.BrowserLoadURL' in permaTabs.utils.wrappedFunctions) + overwriteProcess('permaTabs.utils.wrappedFunctions["window.BrowserLoadURL"]'); - eval('window.BrowserLoadURL = '+ - window.BrowserLoadURL.toSource().replace( - 'aTriggeringEvent && aTriggeringEvent.altKey', - <> - ) - ); eval('nsContextMenu.prototype.openLinkInTab = '+ nsContextMenu.prototype.openLinkInTab.toSource().replace( @@ -1040,35 +1051,43 @@ catch(e) { } funcs = 'contentAreaClick __contentAreaClick __ctxextensions__contentAreaClick'.split(' '); + overwriteProcess = function(aName) { + var overwroteFunc; + eval('overwroteFunc = '+aName); + if (overwroteFunc.toSource().indexOf('(function contentAreaClick') != 0) return; + eval(aName + ' = '+ + overwroteFunc.toSource().replace( + /(openWebPanel\([^\(]+\("webPanels"\), wrapper.href\);event.preventDefault\(\);return false;\})/, + <> + ) + ); + }; for (var i in funcs) { - if (funcs[i] in window && window[funcs[i]] && - /^function contentAreaClick/.test(window[funcs[i]].toString())) - eval('window.'+funcs[i]+' = '+ - window[funcs[i]].toSource().replace( - /(openWebPanel\([^\(]+\("webPanels"\), wrapper.href\);event.preventDefault\(\);return false;\})/, - <> - ) - ); + 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(' '); for (var i in funcs) @@ -1087,14 +1106,23 @@ catch(e) { } func = 'BrowserGoHome' in window ? 'BrowserGoHome' : 'BrowserHomeClick' ; - eval('window.'+func+' = '+ - window[func].toSource().replace( - 'gBrowser.loadTabs(', - <> - ) - ); + overwriteProcess = function(aName, aFunc) { + var overwroteFunc; + eval('overwroteFunc = '+aName); + if (overwroteFunc.toSource().indexOf('(function '+func) != 0) return; + eval(aName + ' = '+ + overwroteFunc.toSource().replace( + '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 = '+ nsBrowserAccess.prototype.openURI.toSource().replace(