Created
August 9, 2009 22:43
-
-
Save ino46/164933 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 Search bar. | |
// @include main | |
// @author Gomita | |
// @version 1.0.20090810074157.ino46 | |
// @homepage http://www.xuldev.org/misc/ucjs.php | |
// ==/UserScript== | |
// | |
// v1.0.20090810074157.ino46 : サーチバーで「貼り付けて移動」するように変更 | |
// v1.0.20090810074113 : Firefox 3.5 対応 | |
// | |
document.getElementById("searchbar").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"); | |
var searchbar = document.getElementById("searchbar"); | |
searchbar.handleSearchCommand(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