Advertisement
Guest User

diary_block_crap.user.js

a guest
Feb 7th, 2012
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @match        http://*.diary.ru/*
  3. // @run-at       document-start
  4. // ==/UserScript==
  5.  
  6. var linksWithCrappyTag = document.getElementsByTagName("a");
  7. for (var ix in linksWithCrappyTag) {
  8.     var link = linksWithCrappyTag[ix];
  9.     if (!link || !link.href || link.href.substr(-7) != "2895465") {
  10.         continue;
  11.     }
  12.     while (link) {
  13.         if (link.className == "paragraph") {
  14.             break;
  15.         }
  16.         link = link.parentNode;
  17.     }
  18.     link.style.display = "none";
  19.     var showContentLink = document.createElement("div");
  20.     showContentLink.className = "paragraph link-inserted";
  21.     showContentLink.style.textDecoration = "underline";
  22.     showContentLink.style.cursor = "pointer";
  23.     showContentLink.appendChild(document.createTextNode("Achtung, crap inside! Click here to show it."));
  24.     showContentLink.onclick = function() {
  25.         var chNodes = this.parentNode.childNodes;
  26.         for (var chIx in chNodes) {
  27.             var chNode = chNodes[chIx];
  28.             if (!chNode) {
  29.                 continue;
  30.             }
  31.             if (chNode.className == "paragraph") {
  32.                 chNode.style.display = "block";
  33.             } else if (chNode.className == "paragraph link-inserted") {
  34.                 chNode.style.display = "none";
  35.             }
  36.         }
  37.     };
  38.     link.parentNode.insertBefore(showContentLink, link);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement