From 77b02db4959f83b47eb95bbfe810b99f489bafef Mon Sep 17 00:00:00 2001 From: YUKI Hiroshi Date: Mon, 5 Sep 2016 15:28:44 +0900 Subject: [PATCH] Reduce use of eval() --- content/treestyletab/windowHelperHacks.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/content/treestyletab/windowHelperHacks.js b/content/treestyletab/windowHelperHacks.js index db4a8c6d..9dc2503b 100644 --- a/content/treestyletab/windowHelperHacks.js +++ b/content/treestyletab/windowHelperHacks.js @@ -207,15 +207,13 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove // https://addons.mozilla.org/firefox/addon/selection-links/ if ('selectionlinks' in window && 'parseSelection' in selectionlinks && - TreeStyleTabUtils.getTreePref('compatibility.SelectionLinks')) { - eval('selectionlinks.parseSelection = '+ - selectionlinks.parseSelection.toSource().replace( - /((?:[^\s:;]+.selectedTab\s*=\s*)?([^\s:;]+).addTab\()/g, - ' if ($2.treeStyleTab)\n' + - ' $2.treeStyleTab.readyToOpenChildTab(focusedWindow);\n' + - '$1' - ) - ); + TreeStyleTabUtils.getTreePref('compatibility.SelectionLinks') && + !selectionlinks.__treestyletab__parseSelection) { + selectionlinks.__treestyletab__parseSelection = selectionlinks.parseSelection; + selectionlinks.parseSelection = function(...aArgs) { + gBrowser.treeStyleTab.readyToOpenChildTabNow(gBrowser.selectedTab, true); + return selectionlinks.__treestyletab__parseSelection(...aArgs); + }; }