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.

Javascript pastebin - collaborative debugging tool View Help


Posted by DecemberBoy on Fri 13 Feb 10:41
report abuse | download | new post

  1. // ==UserScript==
  2. // @name           Metafilter Ignore List
  3. // @namespace      http://www.nowhere.com/nothing
  4. // @description    Ignore users on Metafilter
  5. // @include        http://*.metafilter.com/*
  6. // @include        http://metafilter.com/*
  7. // ==/UserScript==
  8. // Last Updated: Thu 05 Feb 2009 07:05:57 PM CST
  9.  
  10. if (/.*metafilter\.com\/(\d{1,7}\/|mefi\/|comments\.mefi).*/.test(window.location)) {
  11.         //Add users in the brackets below, enclosed in double quotes, comma separated
  12.         var ignorelist = ["DummyUser01","DummyUser02"];
  13.         var ilist_all = [];
  14.         ilist_main();
  15. }
  16.  
  17. function ilist_main() {
  18.         var elements = document.evaluate('//div/span[@class="smallcopy"]',document.body,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
  19.         poster = elements.snapshotItem(0).getElementsByTagName('a').item(0).textContent.toString();
  20.  
  21.         for (var i=0,element;element = elements.snapshotItem(i);i++) {
  22.                 var author = element.getElementsByTagName('a').item(0).textContent.toString();
  23.                 if (typeof(ilist_all[author]) == "object") {
  24.                         ilist_all[author].push(element);
  25.                 } else{
  26.                         ilist_all[author] = [element,];
  27.                 }
  28.         }
  29.  
  30.         for (var author in ilist_all) {
  31.                 for (var i = 0,lim=ilist_all[author].length;i<lim;i++) {
  32.                         if (ignorelist.indexOf(author) != -1) {
  33.                                 //if it was posted by an author on the ignore list, then...
  34.                                 author_link_e = ilist_all[author][i].getElementsByTagName('a').item(0);
  35.                                 postedby = author_link_e.parentNode;
  36.                                 author_link = author_link_e.href;
  37.                                 //...remove the posted by line, and...
  38.                                 comment = postedby.parentNode;
  39.                                 comment.removeChild(postedby);
  40.                                 // ...the comment itself
  41.                                 removed_text = document.createElement("p");
  42.                                 removed_text.setAttribute("class","reason");
  43.                                 removed_text.innerHTML = "Removed comment by <a href=\"" + author_link + "\">" + author + "</a>, who is on your ignore list";
  44.                                 //comment.parentNode.removeChild(comment);
  45.                                 comment.parentNode.replaceChild(removed_text,comment);
  46.                         }
  47.                 }
  48.         }
  49. }

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