MediaWiki:Gadget-HideAds.js: Difference between revisions

Want an adless experience? Log in or Create an account.
since we're only using kontera, I commented out the others to minimize errors and runtime.
(Created page)
 
(since we're only using kontera, I commented out the others to minimize errors and runtime.)
Line 116: Line 116:
   };
   };


   document.addEventListener('DOMNodeInserted', function(event) { disableTextAds.blockAds(event.target); }, true);
   document.addEventListener('DOMNodeInserted', function(event) { disableTextAds.findKonteraText(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);