From daddf249e0f1884a7e7dcb36daf234fef58cf1e5 Mon Sep 17 00:00:00 2001 From: YUKI Hiroshi Date: Thu, 5 Nov 2015 19:44:59 +0900 Subject: [PATCH] Reduce use of eval() --- content/treestyletab/windowHelper.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/content/treestyletab/windowHelper.js b/content/treestyletab/windowHelper.js index c5bcf5ec..dc82c549 100644 --- a/content/treestyletab/windowHelper.js +++ b/content/treestyletab/windowHelper.js @@ -62,15 +62,17 @@ var TreeStyleTabWindowHelper = { return this.__treesytletab__BrowserOpenTab.apply(this, aArgs); }; - TreeStyleTabUtils.doPatching(window.undoCloseTab, 'window.undoCloseTab', function(aName, aSource) { - return eval(aName+' = '+aSource.replace( - /(\btab\s*=\s*[^\.]+\.undoCloseTab\([^;]+\);)/, - 'gBrowser.__treestyletab__doingUndoCloseTab = true;\n' + - '$1\n' + - 'tab.__treestyletab__restoredByUndoCloseTab = true;\n' + - 'setTimeout(function() { delete gBrowser.__treestyletab__doingUndoCloseTab; }, 0);' - )); - }, 'treestyletab'); + window.__treesytletab__undoCloseTab = window.undoCloseTab; + window.undoCloseTab = function(...aArgs) { + gBrowser.__treestyletab__doingUndoCloseTab = true; + var tab = this.__treesytletab__undoCloseTab.apply(this, aArgs); + if (tab) + tab.__treestyletab__restoredByUndoCloseTab = true; + setTimeout(function() { + delete gBrowser.__treestyletab__doingUndoCloseTab; + }, 0); + return tab; + }; [ 'window.duplicateTab.handleLinkClick',