Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: include.textads.js

Issue 8787016: Remove "disable inline text-ads" feature (Closed)
Patch Set: Created Nov. 6, 2012, 8:16 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « background.js ('k') | manifest.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include.textads.js
===================================================================
deleted file mode 100644
--- a/include.textads.js
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * This file is part of the Adblock Plus extension,
- * Copyright (C) 2006-2012 Eyeo GmbH
- *
- * Adblock Plus is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 3 as
- * published by the Free Software Foundation.
- *
- * Adblock Plus is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
- */
-
-// Explicitly removes inline text ads, in case we were unable to block the ad script itself
-// in the beforeload handler.
-function removeTextAdFromElement(elt) {
- // The DOMNodeInserted hooks means we get called for #text nodes, which means localName is null.
- // We don't touch those
- if(!elt.localName) return;
- var keepNode;
- switch(elt.localName.toUpperCase()) {
- // AdBrite
- case 'ISPAN':
- if(elt.id.indexOf('AdBriteInlineAd_') >= 0) {
- keepNode = document.createTextNode(elt.id.substr('AdBriteInlineAd_'.length));
- }
- break;
-
- // Chitika and InfoLinks
- case 'SPAN':
- var fc = elt.firstChild;
- if(!fc) break;
- if(elt.className == 'IL_AD') {
- keepNode = fc;
- } else if(fc.localName && fc.localName.toUpperCase() == 'A' && fc.className.indexOf('lx-link') >= 0) {
- keepNode = fc.firstChild;
- }
- break;
-
- // EchoTopic and ResultLinks
- case 'NOBR':
- var fc = elt.firstChild;
- if(fc && fc.nodeName != '#text' && (fc.className == 'tfTextLink' || fc.id.indexOf('RLLINK') >= 0)) {
- keepNode = fc.firstChild;
- }
- break;
-
- case 'A':
- // Some other ones, including LinkWorth, Kontera, Affinity
- switch(elt.className) {
- case 'IL_LINK_STYLE':
- case 'contextual':
- case 'lw_cad_link':
- case 'cm_word':
- keepNode = elt.firstChild;
- break;
-
- // Kontera really mangles the original text
- case 'kLink':
- var textNodes = elt.querySelectorAll('font > span'), text = "";
- for(var i = 0; i < textNodes.length; i++) text += textNodes[i].innerHTML;
- keepNode = document.createTextNode(text);
- break;
-
- default:
- // IntelliTxt
- if(elt.hasAttribute('itxtdid')) {
- keepNode = elt.firstChild;
- break;
- }
-
- // Not sure if this AdBrite check is still necessary
- if(elt.id.indexOf('AdBriteInlineAd_') >= 0) {
- keepNode = document.createTextNode(elt.id.substr('AdBriteInlineAd_'.length));
- break;
- }
- }
- break; // case 'A'
- }
-
- // Replace the offending node with the original content that was inside it
- if(keepNode) elt.parentNode.replaceChild(keepNode, elt);
-}
-
-chrome.extension.sendRequest({reqtype: "get-domain-enabled-state"}, function(response) {
- if(response.enabled && response.disableInlineTextAds) {
- // Listen for inserted nodes and process them as they come in
- var observer = new WebKitMutationObserver(function(mutations)
- {
- for (var i = 0; i < mutations.length; i++)
- for (var j = 0; j < mutations[i].addedNodes.length; j++)
- removeTextAdFromElement(mutations[i].addedNodes[j]);
- });
- observer.observe(document.documentElement, {subtree: true, childList: true});
-
- // However, our event handler above may not have been inserted in time, so we also scan the document.
- // We use setTimeout here because there is no way to ensure that we are running after the ad scripts have run.
- // So we hope that the delay is long enough.
- setTimeout(function() {
- var elts = document.querySelectorAll("a.IL_LINK_STYLE, a.lw_cad_link, a.cm_word, a.contextual, a.kLink, a[itxtdid], nobr, ispan, span.IL_AD");
- for (var i=0; i<elts.length; i++) removeTextAdFromElement(elts[i]);
- }, 50);
- }
-});
« no previous file with comments | « background.js ('k') | manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld