MediaWiki:Gadget-HideAds.js: Difference between revisions

Want an adless experience? Log in or Create an account.
no edit summary
(Created page)
 
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 113: Line 113:


       return document.createTextNode(content.substring(0,content.length-1));
       return document.createTextNode(content.substring(0,content.length-1));
    },
    blockKontera: function(elt) {
      var target = elt;
      if (elt.nodeName.toLowerCase() == 'a' && elt.getAttribute('class') == 'kLink') {
        var childNode = disableTextAds.findKonteraText(elt);
      }
      // Grab the inner text and replace the inserted tag with it
      if (childNode) {
        target.parentNode.replaceChild(childNode, target);
      }
     }
     }
   };
   };


   document.addEventListener('DOMNodeInserted', function(event) { disableTextAds.blockAds(event.target); }, true);
   document.addEventListener('DOMNodeInserted', function(event) { disableTextAds.blockKontera(event.target); }, true);


   // Handle the cases that don't trigger our DOMNodeInserted hook.
   // Handle the cases that don't trigger our DOMNodeInserted hook.
  window.addEventListener("load", function(event) {  
//  window.addEventListener("load", function(event) {  


     // According to LingoSpot, setting this global variable will disable all ads.  Doesn't actually see to have any effect.
     // According to LingoSpot, setting this global variable will disable all ads.  Doesn't actually see to have any effect.
    unsafeWindow.LINGOSPOT_DISABLED = true;
//    unsafeWindow.LINGOSPOT_DISABLED = true;


     // Thanks to Descriptor for yet another way to block LingoSpot; doesn't on every page, unfortunately.
     // Thanks to Descriptor for yet another way to block LingoSpot; doesn't on every page, unfortunately.
     // Still, it should reduce runtime for pages where it works.
     // Still, it should reduce runtime for pages where it works.
    unsafeWindow.tf_maxKeywords = 0;
//    unsafeWindow.tf_maxKeywords = 0;


     // Unfortunately, Linkworth has decided to remove their container div, so we're stuck crawling the entire document body.  Meh.
     // Unfortunately, Linkworth has decided to remove their container div, so we're stuck crawling the entire document body.  Meh.
    var links = document.evaluate("//a[@class='lw_cad_link' or @itxtdid]", document.body, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
//    var links = document.evaluate("//a[@class='lw_cad_link' or @itxtdid]", document.body, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
    for (var i=0; i<links.snapshotLength; i++) {  
//    for (var i=0; i<links.snapshotLength; i++) {  
      var anchor = links.snapshotItem(i);
//      var anchor = links.snapshotItem(i);
      anchor.parentNode.replaceChild(document.createTextNode(anchor.textContent), anchor);
//      anchor.parentNode.replaceChild(document.createTextNode(anchor.textContent), anchor);
    }
//    }
  }, false);
//  }, false);