Skip to content

Instantly share code, notes, and snippets.

View eric-zeng's full-sized avatar

Eric Zeng eric-zeng

View GitHub Profile
@eric-zeng
eric-zeng / detect_ads.js
Created June 23, 2022 22:29
Example code for detecting ads in JavaScript using EasyList
// Sample code for detecting HTML elements corresponding to ads, in JavaScript, using
// AdBlock Plus filter lists, like Easylist. Can be adapted for browser extensions and
// automation tools like puppeteer, Chrome Devtools Protocol, and OpenWPM. You can
// also paste this particular gist in the JavaScript console.
// CSS Selectors from Easylist (https://easylist.to). I filtered to rules that start with "##"
// to get the CSS selectors, these then have to be stripped
let selectors = [
"###A9AdsMiddleBoxTop", "###A9AdsOutOfStockWidgetTop", "###A9AdsServicesWidgetTop", "###AD-300x250", "###AD-300x250-1", "###AD-300x250-2", "###AD-300x250-3", "###AD-HOME-LEFT", "###AD001", "###AD1line", "###AD2line", "###AD300Right", "###AD300_VAN", "###AD300x250", "###AD300x600", "###AD728Top", "###ADEXPERT_PUSHDOWN", "###ADEXPERT_RECTANGLE", "###ADInterest", "###ADNETwallBanner1", "###ADNETwallBanner2", "###ADSLOT_1", "###ADSLOT_2", "###ADSLOT_3", "###ADSLOT_4", "###ADSLOT_

Keybase proof

I hereby claim:

  • I am eric-zeng on github.
  • I am ericzeng (https://keybase.io/ericzeng) on keybase.
  • I have a public key whose fingerprint is 5113 3676 20A1 2351 6C2C 2CFC 05C2 A023 B85E 355E

To claim this, I am signing this object: