Created
May 12, 2009 05:30
-
-
Save kurumigi/110330 to your computer and use it in GitHub Desktop.
[GM script]Copy URL in Google search
This file contains 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 Copy URL in Google search | |
// @namespace http://d.hatena.ne.jp/kurumigi/ | |
// @description Enable copying URLs if logged in to Google. | |
// @include http*://www.google.tld/search* | |
// @include http*://www.google.tld/custom* | |
// @include http*://www.google.tld/cse* | |
// @version 0.2 | |
// ==/UserScript== | |
(function() { | |
function replaceEvent(node) { | |
var aElm = document.evaluate('.//a[contains(concat(" ", @class, " "), " l ")]', node, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); | |
for (var i = 0; i < aElm.snapshotLength; i++) { | |
if (aElm.snapshotItem(i).hasAttribute('onmousedown')) { | |
var mousedown = aElm.snapshotItem(i).getAttribute('onmousedown'); | |
aElm.snapshotItem(i).removeAttribute('onmousedown'); | |
aElm.snapshotItem(i).setAttribute('onmouseup', 'if (event.button != 2) { ' + mousedown + ' };'); | |
} | |
} | |
} | |
replaceEvent(document); | |
document.body.addEventListener('AutoPagerize_DOMNodeInserted',function(evt) { | |
replaceEvent(evt.target); | |
},false); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment