Skip to content

Instantly share code, notes, and snippets.

@ino46
Created August 9, 2009 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ino46/164930 to your computer and use it in GitHub Desktop.
Save ino46/164930 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Paste And Go
// @namespace http://www.xuldev.org/
// @description Adds 'Paste and Go' menu to the context menu in Location bar.
// @include main
// @author Gomita
// @version 1.0.20090810074113
// @homepage http://www.xuldev.org/misc/ucjs.php
// ==/UserScript==
//
// v1.0.20090810074113 : Firefox 3.5 対応
//
document.getElementById("urlbar").addEventListener("popupshowing", function(event) {
const eltID = "pasteandgo-menuitem";
var menupopup = event.originalTarget;
var refChild = menupopup.getElementsByAttribute("cmd", "cmd_paste")[0];
var canPaste = refChild.getAttribute("disabled") == "true";
var menuitem = document.getElementById(eltID);
if (!menuitem) {
var pasteAndGo = function(event) {
goDoCommand("cmd_paste");
//handleURLBarCommand(event);
gURLBar.handleCommand(event);
menupopup.hidePopup();
};
menuitem = document.createElement("menuitem");
menuitem.id = eltID;
menuitem.setAttribute("label", "Paste and Go");
menuitem.setAttribute("accesskey", "G");
menuitem.addEventListener("command", pasteAndGo, false);
menupopup.insertBefore(menuitem, refChild.nextSibling);
}
menuitem.setAttribute("disabled", canPaste.toString());
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment