Reduce use of eval()

This commit is contained in:
YUKI Hiroshi 2016-09-05 17:06:47 +09:00
parent 488116670b
commit 3daff1ec87

View File

@ -615,41 +615,46 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// https://addons.mozilla.org/firefox/addon/tile-tabs/ // https://addons.mozilla.org/firefox/addon/tile-tabs/
if ('tileTabs' in window && if ('tileTabs' in window &&
TreeStyleTabUtils.getTreePref('compatibility.TileTabs')) { TreeStyleTabUtils.getTreePref('compatibility.TileTabs')) {
if ('allocateTab' in window.tileTabs) if ('allocateTab' in window.tileTabs &&
eval('tileTabs.allocateTab = '+ !tileTabs.__treestyletab__allocateTab) {
tileTabs.allocateTab.toSource().replace( tileTabs.__treestyletab__allocateTab = tileTabs.allocateTab;
/(tab = gBrowser.addTab)/g, tileTabs.allocateTab = function(...aArgs) {
'TreeStyleTabService.readyToOpenNextSiblingTabNow(); $1' TreeStyleTabService.readyToOpenNextSiblingTabNow();
) return this.__treestyletab__allocateTab(...aArgs);
); };
if ('doClickBrowser' in window.tileTabs) }
eval('tileTabs.doClickBrowser = '+ if ('doClickBrowser' in window.tileTabs &&
tileTabs.doClickBrowser.toSource().replace( !tileTabs.__treestyletab__doClickBrowser) {
/(newTab = gBrowser.loadOneTab)/g, tileTabs.__treestyletab__doClickBrowser = tileTabs.doClickBrowser;
'TreeStyleTabService.readyToOpenNextSiblingTabNow(); $1' tileTabs.doClickBrowser = function(...aArgs) {
) TreeStyleTabService.readyToOpenNextSiblingTabNow();
); return this.__treestyletab__doClickBrowser(...aArgs);
if ('doDropBrowserTile' in window.tileTabs) };
eval('tileTabs.doDropBrowserTile = '+ }
tileTabs.doDropBrowserTile.toSource().replace( if ('doDropBrowserTile' in window.tileTabs &&
/(tab = gBrowser.loadOneTab)/g, !tileTabs.__treestyletab__doDropBrowserTile) {
'TreeStyleTabService.readyToOpenNextSiblingTabNow(), $1' tileTabs.__treestyletab__doDropBrowserTile = tileTabs.doDropBrowserTile;
) tileTabs.doDropBrowserTile = function(...aArgs) {
); TreeStyleTabService.readyToOpenNextSiblingTabNow();
if ('menuActions' in window.tileTabs) return this.__treestyletab__doDropBrowserTile(...aArgs);
eval('tileTabs.menuActions = '+ };
tileTabs.menuActions.toSource().replace( }
/(tab = gBrowser.loadOneTab)/g, if ('menuActions' in window.tileTabs &&
'TreeStyleTabService.readyToOpenNextSiblingTabNow(), $1' !tileTabs.__treestyletab__menuActions) {
) tileTabs.__treestyletab__menuActions = tileTabs.menuActions;
); tileTabs.menuActions = function(...aArgs) {
if ('applyLayoutString' in window.tileTabs) TreeStyleTabService.readyToOpenNextSiblingTabNow();
eval('tileTabs.applyLayoutString = '+ return this.__treestyletab__menuActions(...aArgs);
tileTabs.applyLayoutString.toSource().replace( };
/(tab = gBrowser.loadOneTab)/g, }
'TreeStyleTabService.readyToOpenNextSiblingTabNow(), $1' if ('applyLayoutString' in window.tileTabs &&
) !tileTabs.__treestyletab__applyLayoutString) {
); tileTabs.__treestyletab__applyLayoutString = tileTabs.applyLayoutString;
tileTabs.applyLayoutString = function(...aArgs) {
TreeStyleTabService.readyToOpenNextSiblingTabNow();
return this.__treestyletab__applyLayoutString(...aArgs);
};
}
} }
window.setTimeout(function(aSelf) { window.setTimeout(function(aSelf) {