Created
October 18, 2022 16:42
-
-
Save wernsey/1b6ef84d49f4e8af99073d2560dd578a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){ | |
/* Ad-B-Gone: Bookmarklet that removes obnoxious ads from pages */ | |
const removeAds = () => { | |
let selectors = [ | |
/* By ID: */ | |
'#sidebar-wrap', '#advert', '#xrail', '#middle-article-advert-container', | |
'#sponsored-recommendations', '#around-the-web', '#sponsored-recommendations', | |
'#taboola-content', '#taboola-below-taboola-native-thumbnails', '#inarticle_wrapper_div', | |
'#rc-row-container', '#ads', '#at-share-dock', '#at4-share', '#at4-follow', '#right-ads-rail', | |
'div#ad-interstitial', 'div#advert-article', 'div#ac-lre-player-ph', 'div#videoAdSlot', | |
'div#primisPlayerContainerDiv', 'div#videoAdSlot', | |
/* By Class: */ | |
'.ad', '.avert', '.avert__wrapper', '.middle-banner-ad', '.advertisement', | |
'.GoogleActiveViewClass', '.advert', '.cns-ads-stage', '.teads-inread', '.ad-banner', | |
'.ad-anchored', '.js_shelf_ads', '.ad-slot', '.antenna', '.xrail-content', | |
'.advertisement__leaderboard', '.ad-leaderboard', '.trc_rbox_outer', '.ks-recommended', | |
'.article-da', 'div.sponsored-stories-component', 'div.addthis-smartlayers', | |
'div.article-adsponsor', 'div.signin-prompt', 'div.article-bumper', 'div.video-placeholder', | |
'div.top-ad-container', 'div.header-ad', 'div.ad-unit', 'div.demo-block', 'div.OUTBRAIN', | |
'div.ob-widget', 'div.nwsrm-wrapper', 'div.announcementBar', 'div.partner-resources-block', | |
'div.arrow-down', 'div.m-ad', 'div.story-interrupt', 'div.taboola-recommended', | |
'div.ad-cluster-container', 'div.ctx-sidebar', 'div.incognito-modal', '.OUTBRAIN', '.subscribe-button', | |
'.ads9', '.leaderboards', '.GoogleActiveViewElement', '.mpu-container', '.ad-300x600', '.tf-ad-block', | |
'.sidebar-ads-holder-top', '.ads-one', '.FullPageModal__scroller', '.adp_interactive_ad', '._ap_apex_ad', | |
'.content-ads-holder', '.widget-area', '.social-buttons', '.ac-player-ph', '.video-js', '.primisslate', | |
/* Other: */ | |
'script', 'iframe', 'video', 'aside#sponsored-recommendations', 'aside[role="banner"]', 'aside', | |
'amp-ad', 'span[id^=ad_is_]', 'div[class*="indianapolis-optin"]', 'div[id^=google_ads_iframe]', | |
'div[data-google-query-id]', 'section[data-response]', 'ins.adsbygoogle', 'div[data-google-query-id]', | |
'div[data-test-id="fullPageSignupModal"]', 'div[data-test-id="giftWrap"]' ]; | |
selectors.forEach(selector => document.querySelectorAll(selector).forEach(node => node.parentNode.removeChild(node))); | |
} | |
const killSticky = () => { | |
/* This next part from the kill-sticky bookmarklet. | |
https://github.com/t-mart/kill-sticky | |
(See also here: https://news.ycombinator.com/item?id=32998091) | |
*/ | |
document.querySelectorAll('body *').forEach(function(node) { | |
if (['fixed', 'sticky'].includes(getComputedStyle(node).position)) { | |
node.parentNode.removeChild(node); | |
} | |
}); | |
document.querySelectorAll('html *').forEach(function(node) { | |
var s = getComputedStyle(node); | |
if ('hidden' === s['overflow']) { node.style['overflow'] = 'visible'; } | |
if ('hidden' === s['overflow-x']) { node.style['overflow-x'] = 'visible'; } | |
if ('hidden' === s['overflow-y']) { node.style['overflow-y'] = 'visible'; } | |
}); | |
var htmlNode = document.querySelector('html'); | |
htmlNode.style['overflow'] = 'visible'; | |
htmlNode.style['overflow-x'] = 'visible'; | |
htmlNode.style['overflow-y'] = 'visible'; | |
} | |
if(true) { | |
const observer = new MutationObserver(mutations => { | |
console.log('Mutations observed; removing stuff again'); | |
removeAds(); | |
killSticky(); | |
}); | |
observer.observe(document.body, { subtree: true, childList: true }); | |
} | |
console.log('Removing stuff'); | |
removeAds(); | |
killSticky(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment