Reduce use of eval
This commit is contained in:
parent
eec6610169
commit
d594fdf36b
@ -69,25 +69,33 @@ var TreeStyleTabWindowHelper = {
|
|||||||
return tab;
|
return tab;
|
||||||
};
|
};
|
||||||
|
|
||||||
[
|
window.__treestyletab__openLinkIn = window.openLinkIn;
|
||||||
'window.duplicateTab.handleLinkClick',
|
window.openLinkIn = function(aUrl, aWhere, aParams, ...aArgs) {
|
||||||
'window.duplicatethistab.handleLinkClick',
|
if (window.__treestyletab__openLinkIn_extraParams)
|
||||||
'window.__treestyletab__highlander__origHandleLinkClick',
|
Object.keys(window.__treestyletab__openLinkIn_extraParams).forEach(function(aKey) {
|
||||||
'window.__splitbrowser__handleLinkClick',
|
aParams[aKey] = window.__treestyletab__openLinkIn_extraParams[aKey];
|
||||||
'window.__ctxextensions__handleLinkClick',
|
});
|
||||||
'window.handleLinkClick'
|
try {
|
||||||
].some(function(aName) {
|
return window.__treestyletab__openLinkIn.apply(this, [aUrl, aWhere, aParams].concat(aArgs));
|
||||||
let func = this._getFunction(aName);
|
}
|
||||||
if (!func || !/^\(?function handleLinkClick/.test(func.toString()))
|
finally {
|
||||||
return false;
|
delete window.__treestyletab__openLinkIn_extraParams;
|
||||||
TreeStyleTabUtils.doPatching(func, aName, function(aName, aSource) {
|
}
|
||||||
return eval(aName+' = '+aSource.replace(
|
};
|
||||||
/(charset\s*:\s*doc\.characterSet\s*)/,
|
|
||||||
'$1, event : event, linkNode : linkNode'
|
window.__treestyletab__handleLinkClick = window.handleLinkClick;
|
||||||
));
|
window.handleLinkClick = function(aEvent, aHref, aLinkNode, ...aArgs) {
|
||||||
}, 'event : event, linkNode : linkNode');
|
window.__treestyletab__openLinkIn_extraParams = {
|
||||||
return true;
|
event : aEvent,
|
||||||
}, this);
|
linkNode : aLinkNode
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
return window.__treestyletab__handleLinkClick.apply(this, [aEvent, aHref, aLinkNode].concat(aArgs));
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
delete window.__treestyletab__openLinkIn_extraParams;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
this.overrideExtensionsPreInit(); // windowHelperHacks.js
|
this.overrideExtensionsPreInit(); // windowHelperHacks.js
|
||||||
},
|
},
|
||||||
@ -263,21 +271,17 @@ var TreeStyleTabWindowHelper = {
|
|||||||
return window.__treestyletab__duplicateTabIn.call(this, aTab, where, delta);
|
return window.__treestyletab__duplicateTabIn.call(this, aTab, where, delta);
|
||||||
};
|
};
|
||||||
|
|
||||||
[
|
window.__treestyletab__BrowserGoHome = window.BrowserGoHome;
|
||||||
'permaTabs.utils.wrappedFunctions["window.BrowserHomeClick"]',
|
window.BrowserGoHome = function(aEvent) {
|
||||||
'window.BrowserHomeClick',
|
var where = whereToOpenLink(aEvent, false, true);
|
||||||
'window.BrowserGoHome'
|
if (where == 'current' && gBrowser && gBrowser.selectedTab.pinned)
|
||||||
].forEach(function(aName) {
|
where = 'tab';
|
||||||
let func = this._getFunction(aName);
|
if (aEvent &&
|
||||||
if (!func || !/^\(?function (BrowserHomeClick|BrowserGoHome)/.test(func.toString()))
|
aEvent.button !== 2 &&
|
||||||
return;
|
where.indexOf('tab') === 0)
|
||||||
TreeStyleTabUtils.doPatching(func, aName, function(aName, aSource) {
|
TreeStyleTabService.readyToOpenNewTabGroup(gBrowser);
|
||||||
return eval(aName+' = '+aSource.replace(
|
return window.__treestyletab__BrowserGoHome.call(this, aEvent);
|
||||||
'gBrowser.loadTabs(',
|
};
|
||||||
'TreeStyleTabService.readyToOpenNewTabGroup(gBrowser); $&'
|
|
||||||
));
|
|
||||||
}, 'TreeStyleTab');
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
FeedHandler.__treestyletab__loadFeed = FeedHandler.loadFeed;
|
FeedHandler.__treestyletab__loadFeed = FeedHandler.loadFeed;
|
||||||
FeedHandler.loadFeed = function(aHref, aEvent) {
|
FeedHandler.loadFeed = function(aHref, aEvent) {
|
||||||
|
Loading…
Reference in New Issue
Block a user