Last active
December 16, 2019 03:15
-
-
Save matt-auckland/e393a897ac9b3a8bc123772726dce603 to your computer and use it in GitHub Desktop.
Hide premium articles on a page on medium
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
// 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