Created
August 9, 2009 22:25
-
-
Save ino46/164930 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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