Posted By

loucypher on 05/26/11


Tagged

rss feed atom bookmarklet


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

surekin


Feeds Finder


 / Published in: JavaScript
 

URL: http://loucypher.tumblr.com/post/48491411/feeds-finder-bookmarklet-for-google-chrome

To be used as bookmarklet for Google Chrome. See the URL above.

  1. ({
  2. getFeedURL: function(e, doc){
  3. var j = e;
  4. var c = doc.location;
  5. if (e.indexOf("/") !=0 ) {
  6. var d = c.pathname.split("/");
  7. d[d.length-1] = e;
  8. j = d.join("/")
  9. }
  10. return c.protocol + "//" + c.hostname + j;
  11. },
  12.  
  13. isFeedBurner: function(u) {
  14. return u.indexOf("http://feeds.feedburner.com/") == 0;
  15. },
  16.  
  17. setFeedURL: function(u) {
  18. return this.isFeedBurner(u)
  19. ? u
  20. : "http://www.google.com/reader/view/feed/" + encodeURIComponent(u);
  21. },
  22.  
  23. checkForFeeds: function() {
  24. var f = false, s = "", n = 0;
  25. var m = document.getElementsByTagName("link");
  26. for (var g = 0, a; a = m[g]; g++) {
  27. var h = a.getAttribute("type");
  28. var i = a.getAttribute("rel");
  29. if ((h && h.match(/[\+\/]xml$/)) && (i && (i == "alternate"))) {
  30. var b = a.getAttribute("href");
  31. var t = a.getAttribute("title");
  32. if (b.indexOf("http") != 0) {
  33. b = this.getFeedURL(b, document);
  34. }
  35. s += "<li><a href=" + this.setFeedURL(b) + ">" + (t ? t : b) + "</a></li>";
  36. f = true;
  37. n = n + 1;
  38. }
  39. }
  40. if (!f) {
  41. alert("Can\"t find any feeds.");
  42. } else if (n == 1) {
  43. window.open(this.setFeedURL(b), "_blank");
  44. } else {
  45. var w = window.open();
  46. w.document.open();
  47. w.document.write("<h1>" + "Found " + n + " feeds</h1><ol>");
  48. w.document.write(s + "</ol>");
  49. w.document.close();
  50. }
  51. }
  52. }).checkForFeeds()

Report this snippet  

You need to login to post a comment.