Skip to content

Instantly share code, notes, and snippets.

@matt-auckland
Last active December 16, 2019 03:15
Show Gist options
  • Save matt-auckland/e393a897ac9b3a8bc123772726dce603 to your computer and use it in GitHub Desktop.
Save matt-auckland/e393a897ac9b3a8bc123772726dce603 to your computer and use it in GitHub Desktop.
Hide premium articles on a page on medium
// Only tested on topic pages, e.g. https://medium.com/topic/Javascript
function hideArticles() {
document.querySelectorAll('.star-15px_svg__svgIcon-use').forEach(hidePremiumArticles);
}
function hidePremiumArticles(node) {
const targetNode = climb(node, 0);
if (targetNode.tagName !== 'SECTION') return;
targetNode.style = 'display: none !important;';
}
function climb(node, level) {
if (node.tagName == 'SECTION' || node.tagName == 'BODY' || level > 15) {return node;}
return climb(node.parentNode, level + 1);
}
hideArticles();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment