I changed the LouCypher code a little to open new tab next to current one, here is:
Code:
function handleCommand(aTriggeringEvent) {
if (aTriggeringEvent instanceof MouseEvent && aTriggeringEvent.button == 2)
return; // Do nothing for right clicks
var url = this.value;
var mayInheritPrincipal = false;
var postData = null;
var action = this._parseActionUrl(url);
if (action) {
url = action.param;
if (this.hasAttribute("actiontype")) {
if (action.type == "switchtab") {
this.handleRevert();
let prevTab = gBrowser.selectedTab;
if (switchToTabHavingURI(url) &&
isTabEmpty(prevTab))
gBrowser.removeTab(prevTab);
}
return;
}
}
else {
[url, postData, mayInheritPrincipal] = this._canonizeURL(aTriggeringEvent);
if (!url)
return;
}
this.value = url;
gBrowser.userTypedValue = url;
try {
addToUrlbarHistory(url);
} catch (ex) {
// Things may go wrong when adding url to session history,
// but don't let that interfere with the loading of the url.
Cu.reportError(ex);
}
function loadCurrent() {
let flags = Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP;
// Pass LOAD_FLAGS_DISALLOW_INHERIT_OWNER to prevent any loads from
// inheriting the currently loaded document's principal, unless this
// URL is marked as safe to inherit (e.g. came from a bookmark
// keyword).
if (!mayInheritPrincipal)
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_DISALLOW_INHERIT_OWNER;
gBrowser.loadURIWithFlags(url, flags, null, null, postData);
}
if (aTriggeringEvent instanceof MouseEvent) {
// We have a mouse event (from the go button), so use the standard
// UI link behaviors
let where = whereToOpenLink(aTriggeringEvent, false, false);
if (where == "current") {
loadCurrent();
} else {
this.handleRevert();
content.focus();
openUILinkIn(url, where,
{ allowThirdPartyFixup: true, postData: postData });
}
return;
}
if (aTriggeringEvent &&
aTriggeringEvent.altKey &&
!isTabEmpty(gBrowser.selectedTab)) {
this.handleRevert();
content.focus();
var currTab=gBrowser.mCurrentTab;
var newTab = gBrowser.loadOneTab(url, {
postData: postData,
inBackground: false,
allowThirdPartyFixup: true
});
gBrowser.moveTabTo(newTab, currTab._tPos+1);
aTriggeringEvent.preventDefault();
aTriggeringEvent.stopPropagation();
} else {
loadCurrent();
}
gBrowser.selectedBrowser.focus();
}
gURLBar.handleCommand_TMP = gURLBar.handleCommand; // you can skip this line
gURLBar.handleCommand = handleCommand;
ps: someone tried the last version of
Tab Utilities addon? Wow! This thing is a real clone of TMP
without bugs, I'm thinking about changing addon. Last time I tried tab utilities it was so featureless...