Created
October 25, 2009 14:05
-
-
Save whym/218075 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 Google Search - Add direct links | |
| // @namespace http://github.com/whym | |
| // @include http://www.google.tld/search?* | |
| // @version 0.01 | |
| // @description Add direct links in Google search result | |
| // ==/UserScript== | |
| // based on http://userscripts.org/scripts/show/57679 by blooo | |
| (function() { | |
| function handle(doc) { | |
| var items = document.evaluate(window.LDRize.getSiteinfo()['paragraph'], doc, null, 7, null); | |
| for (var i = 0; i < items.snapshotLength; i++){ | |
| var item = items.snapshotItem(i); | |
| var link = document.evaluate('descendant::a', item, null, 7, null).snapshotItem(0); | |
| var cite = document.evaluate('descendant::cite', item, null, 7, null).snapshotItem(0); | |
| cite.innerHTML = '<a style="color:inherit;" href="'+link.href+'">'+cite.innerHTML+'</a>'; | |
| } | |
| } | |
| function registerPageHandler() { | |
| window.AutoPagerize.addFilter(function(pages) { | |
| pages.forEach(function(page) { | |
| handle(page); | |
| }); | |
| }); | |
| } | |
| handle(document); | |
| if (window.AutoPagerize) { | |
| registerPageHandler(); | |
| } else { | |
| window.addEventListener('GM_AutoPagerizeLoaded', registerPageHandler, false); | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment