Created
May 21, 2010 08:32
-
-
Save masaakif/408623 to your computer and use it in GitHub Desktop.
Show RSS link at the top
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 Show RSS link at the top | |
| // @include http://* | |
| // @include https://* | |
| // @namespace http://gist.github.com/408263 | |
| // ==/UserScript== | |
| // Version 20100521 | |
| var DEBUG=true; | |
| showRSS(); | |
| function showRSS() { | |
| var links = document.evaluate("//head/link", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); | |
| var ln = ""; | |
| var body = document.getElementsByTagName("body")[0]; | |
| var innerHTML = ""; | |
| var rows = 0; | |
| for (var i = 0; i < links.snapshotLength; i++) { | |
| ln = links.snapshotItem(i); | |
| if (ln.href.search(/rss|xml|atom/i) != -1) { | |
| innerHTML += ln.href + "\n\r"; | |
| rows++; | |
| } | |
| } | |
| if (rows > 0) { | |
| var newElem = document.createElement("textarea"); | |
| newElem.cols = "60"; | |
| newElem.id = "gm_rsslist"; | |
| newElem.rows = rows; | |
| newElem.innerHTML = innerHTML; | |
| body.insertBefore(newElem, body.firstChild); | |
| } | |
| } | |
| function debug() { | |
| if (typeof DEBUG != 'undefined' && DEBUG ) { | |
| console.log.apply(this, arguments); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment