Last active
January 22, 2024 15:39
-
-
Save abjugard/62b7b4337d2e77f8a3abbfc3efcc65b9 to your computer and use it in GitHub Desktop.
MacRumors filter
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
// ==UserScript== | |
// @name Remove useless articles on MacRumors | |
// @namespace https://github.com/abjugard/ | |
// @version 1.11 | |
// @description Removes promos on MacRumors | |
// @author Adrian Bjugård | |
// @match https://www.macrumors.com/ | |
// @match https://www.macrumors.com/*/ | |
// @icon https://www.google.com/s2/favicons?domain=macrumors.com | |
// @grant none | |
// @updateURL https://gist.githubusercontent.com/abjugard/62b7b4337d2e77f8a3abbfc3efcc65b9/raw/macrumors-filter.user.js | |
// @downloadURL https://gist.githubusercontent.com/abjugard/62b7b4337d2e77f8a3abbfc3efcc65b9/raw/macrumors-filter.user.js | |
// ==/UserScript== | |
const unwantedRes = [ | |
/\$/i, | |
/deal(s|):/i, | |
/discount(s|)/i, | |
/black friday/i, | |
/back to school/i, | |
/lowest price/i, | |
/(low|best) price(s|)/i, | |
/Apple Releases (New |)(Beta |)Firmware.*(Air(Pod|Tag)(s|)|Remote|Display|Beats|MagSafe Charger|Pencil)/i, | |
/Apple Seeds.*(New |)(Beta|Release Candidate).*(Developers|Public Beta Testers)/i, | |
/Apple Releases (New |)(Beta |).*(Air(Pod|Tag)(s|)|Remote|Display|Beats|MagSafe Charger|Pencil).*Firmware/i, | |
/Beta:/i, | |
/Apple Seeds.*Beta.*OS.*Developers/i, | |
/Apple Vision/i, | |
/Vision Pro/i | |
]; | |
(function() { | |
'use strict'; | |
if (window.location.href.length > 32) { | |
return; | |
} | |
document.querySelectorAll('article').forEach(article => { | |
const title = article.querySelector('div[class^="titlebar--"]'); | |
if (title == null) { | |
return; | |
} | |
if (unwantedRes.some(re => re.test(title.innerText))) { | |
article.childNodes.forEach(node => { | |
if (!node.className.includes('titlebar--')) { | |
article.removeChild(node); | |
} | |
}); | |
const content = article.querySelector('div[class^="content--"]'); | |
article.removeChild(content); | |
title.style.opacity = '40%'; | |
title.style.padding = '1px 15px 4px 15px'; | |
const link = title.querySelector('a'); | |
link.style.fontSize = '12px'; | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment