Skip to content

Commit

Permalink
google imageTextAd collection Attempt1
Browse files Browse the repository at this point in the history
  • Loading branch information
cqx931 committed Oct 2, 2019
1 parent 195bc61 commit 66d0245
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
2 changes: 1 addition & 1 deletion filters/adnauseam.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ google.*##.mnr-c.rl-qs-crs-t._Db > ._gt:has(._mB)
#@#.adsbygoogle
# Generic hide for Google Ads
###google_image_div
##ins[id*="aswift"]
##ins[id*="aswift"] > iframe

# generichide-rules (#1466 etc)
trustedreviews.com##*[class^="ad-"]
Expand Down
47 changes: 46 additions & 1 deletion src/js/adn/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,19 +335,63 @@
}

logP('Checking children of', elem);

var imgs = elem.querySelectorAll('img');
if (imgs.length) {
findImageAds(imgs);
}
else {
findBgImage(elem) || logP('No images in children of', elem);
logP('No img found, check other cases', elem);
// var iframes = elem.querySelectorAll("iframe")
// if (iframes.length > 0) {
// logP('Iframe Found!', iframes);
// for(var i = 0; i < iframes.length; i++) {
// console.log(iframes[i])
// process(iframes[i])
// }
// break;
// }
// if no img found within the element
findGoogleImageTextAd(elem) || findBgImage(elem) || logP('No images in children of', elem);
}

// and finally check for text ads
vAPI.textAdParser.process(elem);
}
};

var findGoogleImageTextAd = function(elem){
// tmp solution, just get the image
// a#mys-content href
// div.GoogleActiveViewElement
// ->canvas.image background-Image

logP("[Parser] GoogleImageText")
var googleDisplayAd = elem.querySelector('.GoogleActiveViewElement');
if (!googleDisplayAd) return;

var img, src, link, targetURL;

if (elem.tagName == "A" && elem.id == "mys-content") {
link = elem
} else {
link = elem.querySelector('a#mys-content');
}

if (link && link.hasAttribute("href")) {
targetURL = link.getAttribute("href");
}

img = googleDisplayAd.querySelector('canvas.image');
if (img) {
var attribute = getComputedStyle(img).backgroundImage;
src = attribute.match(/\((.*?)\)/)[1].replace(/('|")/g,'');
}

if (img && src && targetURL) createImageAd(img, src, targetURL)

}

var processIFrame = function () {

try {
Expand All @@ -366,6 +410,7 @@
else {
logP('No images in iFrame');
}
// process(doc);
};

var notifyAddon = function (ad) {
Expand Down

0 comments on commit 66d0245

Please sign in to comment.