pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

pastebin - collaborative debugging tool View Help


Posted by Rhaomi on Thu 16 Apr 22:03
report abuse | download | new post

  1. // Google Reader Preview
  2. // version 0.1
  3. // 2006-16-11
  4. // Copyright (c) 2006, Itai Lahan
  5. // Released under the GPL license
  6. // http://www.gnu.org/copyleft/gpl.html
  7. // --------------------------------------------------------------------
  8. // WHAT IT DOES:
  9. // Replaces Google Reader's article summary with a frame containing the actual blog item
  10. // --------------------------------------------------------------------
  11. // ==UserScript==
  12. // @name            Google Reader Preview
  13. // @description     Replaces Google Reader's article summary with a frame containing the actual blog item
  14. // @include         http://reader.google.com/reader/*
  15. // @include         http://www.google.com/reader/*
  16. // ==/UserScript==
  17.  
  18. document.getElementsByClassName = function(className, parentNode) {
  19.   var elements = [];
  20.   var parent = parentNode;
  21.   if (parentNode == undefined) {
  22.           parent = document.body;
  23.   }
  24.   if (parent.getElementsByTagName == undefined) {
  25.           return elements;
  26.   }
  27.   var children = parent.getElementsByTagName('*');
  28.   for (var i = 0; i < children.length; i ++) {
  29.         var child = children[i];
  30.     if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) {
  31.       elements[elements.length] = child;
  32.         }
  33.   }
  34.   return elements;
  35. }
  36.  
  37. var decorate_new_elements = function(e) {
  38.         var element = e.target;
  39.         if (element.className != "entry-container") {
  40.                 return;
  41.         }
  42.         var elements = document.getElementsByClassName("entry-title", element);
  43.         if ((elements == undefined) || (elements.length == 0)) {
  44.                 return;
  45.         }
  46.         var entry_title = elements[0];
  47.         var href_array = /\"(http:\/\/[^\"]*)\"/.exec(entry_title.innerHTML);
  48.         if (href_array == undefined || href_array.length == 0) {
  49.                 return;
  50.         }
  51.         var href = href_array[1];
  52.  
  53.         elements = document.getElementsByClassName("entry-body", element);
  54.         if (elements != undefined && (elements.length > 0)) {
  55.                 var body = elements[0];
  56.                 // Turn off preview for URLs that match the strings below.
  57.                 if (
  58.                         href.lastIndexOf("foo")==-1 &&
  59.                         href.lastIndexOf("foo2")==-1 &&
  60.                         href.lastIndexOf("foo3")==-1 &&
  61.                         href.lastIndexOf("foo4")==-1
  62.                 )
  63.                 {
  64.                 body.innerHTML = "<IFRAME src='"+href+"' height=500 width=1000></IFrame>";
  65.                 }
  66.         }
  67. }
  68.  
  69. document.body.addEventListener('DOMNodeInserted', decorate_new_elements, false);

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post