Reduce use of eval() hack
This commit is contained in:
parent
2afd90c96a
commit
d4dcefc75a
@ -167,21 +167,17 @@ var TreeStyleTabWindowHelper = {
|
|||||||
{
|
{
|
||||||
this.initToolbarItems();
|
this.initToolbarItems();
|
||||||
|
|
||||||
TreeStyleTabUtils.doPatching(nsContextMenu.prototype.openLinkInTab, 'nsContextMenu.prototype.openLinkInTab', function(aName, aSource) {
|
nsContextMenu.prototype.__treestyletab__openLinkInTab = nsContextMenu.prototype.openLinkInTab;
|
||||||
return eval(aName+' = '+aSource.replace(
|
nsContextMenu.prototype.openLinkInTab = function(...aArgs) {
|
||||||
'{',
|
TreeStyleTabService.handleNewTabFromCurrent(this.target.ownerDocument.defaultView);
|
||||||
'{\n' +
|
return this.__treestyletab__openLinkInTab.apply(this, aArgs);
|
||||||
' TreeStyleTabService.handleNewTabFromCurrent(this.target.ownerDocument.defaultView);'
|
};
|
||||||
));
|
|
||||||
}, 'TreeStyleTab');
|
|
||||||
|
|
||||||
TreeStyleTabUtils.doPatching(nsContextMenu.prototype.openFrameInTab, 'nsContextMenu.prototype.openFrameInTab', function(aName, aSource) {
|
nsContextMenu.prototype.__treestyletab__openFrameInTab = nsContextMenu.prototype.openFrameInTab;
|
||||||
return eval(aName+' = '+aSource.replace(
|
nsContextMenu.prototype.openFrameInTab = function(...aArgs) {
|
||||||
'{',
|
TreeStyleTabService.handleNewTabFromCurrent(this.target.ownerDocument.defaultView);
|
||||||
'{\n' +
|
return this.__treestyletab__openFrameInTab.apply(this, aArgs);
|
||||||
' TreeStyleTabService.handleNewTabFromCurrent(this.target.ownerDocument.defaultView);'
|
};
|
||||||
));
|
|
||||||
}, 'TreeStyleTab');
|
|
||||||
|
|
||||||
var viewImageMethod = ('viewImage' in nsContextMenu.prototype) ? 'viewImage' : 'viewMedia' ;
|
var viewImageMethod = ('viewImage' in nsContextMenu.prototype) ? 'viewImage' : 'viewMedia' ;
|
||||||
TreeStyleTabUtils.doPatching(nsContextMenu.prototype[viewImageMethod], 'nsContextMenu.prototype.'+viewImageMethod, function(aName, aSource) {
|
TreeStyleTabUtils.doPatching(nsContextMenu.prototype[viewImageMethod], 'nsContextMenu.prototype.'+viewImageMethod, function(aName, aSource) {
|
||||||
@ -244,12 +240,11 @@ var TreeStyleTabWindowHelper = {
|
|||||||
}, 'TreeStyleTab');
|
}, 'TreeStyleTab');
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
TreeStyleTabUtils.doPatching(window.duplicateTabIn, 'window.duplicateTabIn', function(aName, aSource) {
|
window.__treestyletab__duplicateTabIn = window.duplicateTabIn;
|
||||||
return eval(aName+' = '+aSource.replace(
|
window.duplicateTabIn = function(aTab, where, delta) {
|
||||||
'{',
|
gBrowser.treeStyleTab.onBeforeTabDuplicate(aTab, where, delta);
|
||||||
'{ gBrowser.treeStyleTab.onBeforeTabDuplicate(aTab, where, delta); '
|
return window.__treestyletab__duplicateTabIn.call(this, aTab, where, delta);
|
||||||
));
|
};
|
||||||
}, 'treeStyleTab');
|
|
||||||
|
|
||||||
[
|
[
|
||||||
'permaTabs.utils.wrappedFunctions["window.BrowserHomeClick"]',
|
'permaTabs.utils.wrappedFunctions["window.BrowserHomeClick"]',
|
||||||
@ -304,18 +299,16 @@ var TreeStyleTabWindowHelper = {
|
|||||||
));
|
));
|
||||||
}, 'treeStyleTab');
|
}, 'treeStyleTab');
|
||||||
|
|
||||||
TreeStyleTabUtils.doPatching(PrintUtils.printPreview, 'PrintUtils.printPreview', function(aName, aSource) {
|
PrintUtils.__treestyletab__printPreview = PrintUtils.printPreview;
|
||||||
return eval(aName+' = '+aSource.replace(
|
PrintUtils.printPreview = function(...aArgs) {
|
||||||
'{',
|
TreeStyleTabService.onPrintPreviewEnter();
|
||||||
'{ TreeStyleTabService.onPrintPreviewEnter();'
|
return PrintUtils.__treestyletab__printPreview.apply(this, aArgs);
|
||||||
));
|
};
|
||||||
}, 'TreeStyleTab');
|
PrintUtils.__treestyletab__exitPrintPreview = PrintUtils.exitPrintPreview;
|
||||||
TreeStyleTabUtils.doPatching(PrintUtils.exitPrintPreview, 'PrintUtils.exitPrintPreview', function(aName, aSource) {
|
PrintUtils.exitPrintPreview = function(...aArgs) {
|
||||||
return eval(aName+' = '+aSource.replace(
|
TreeStyleTabService.onPrintPreviewExit();
|
||||||
'{',
|
return PrintUtils.__treestyletab__exitPrintPreview.apply(this, aArgs);
|
||||||
'{ TreeStyleTabService.onPrintPreviewExit();'
|
};
|
||||||
));
|
|
||||||
}, 'TreeStyleTab');
|
|
||||||
|
|
||||||
if ('TabsOnTop' in window) {
|
if ('TabsOnTop' in window) {
|
||||||
TreeStyleTabUtils.doPatching(TabsOnTop.syncUI, 'TabsOnTop.syncUI', function(aName, aSource) {
|
TreeStyleTabUtils.doPatching(TabsOnTop.syncUI, 'TabsOnTop.syncUI', function(aName, aSource) {
|
||||||
|
Loading…
Reference in New Issue
Block a user