Last active
November 14, 2018 03:51
-
-
Save rwilson/502465ffb1c66dc7d48cf78459901213 to your computer and use it in GitHub Desktop.
Unmodalify Bookmarklet
This file contains 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
// Use to remove modals that some sites add when they detect | |
// an ad blocker or unauthenticated client. | |
// Minify with: https://skalman.github.io/UglifyJS-online/ | |
// Add as bookmarklet with: javascript:<minified-code> | |
(function() { | |
// Remove elements | |
[ | |
'modal', | |
'modal-backdrop', | |
'paywall__overlay', | |
'pico-overlay', | |
'pico-content' | |
] | |
.map(cn => document.getElementsByClassName(cn)) | |
.forEach((elems) => { | |
for (let i=0; i<elems.length; i++) { | |
const elem = elems.item(i); | |
elem.parentNode.removeChild(elem); | |
} | |
}); | |
// Remove body class names | |
[ | |
/modal-open/ | |
].forEach((re) => { | |
document.body.className = document.body.className.replace(re, ''); | |
}); | |
// Remove class names | |
[ | |
'blurred', | |
'truncate-text', | |
'rb' | |
] | |
.forEach((cn) => { | |
const elems = document.getElementsByClassName(cn); | |
const re = new RegExp(cn); | |
while (elems.length > 0) { | |
const elem = elems.item(0); | |
elem.className = elem.className.replace(re, ''); | |
if (cn === 'truncate-text') { | |
elem.style.height = ''; | |
elem.style.maxHeight = ''; | |
} | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment