Last active
October 23, 2023 13:59
-
-
Save trasparente/541d32d274874d4d71cd2efe1c522c63 to your computer and use it in GitHub Desktop.
bookmarklet for X hide ads and suggestion. Restore article titles
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() { // Pools (all) | |
var spans = [...document.querySelectorAll("span")] | |
var h2s = [...document.querySelectorAll("h2")] | |
// Who to follow | |
var who = spans.filter(a => a.textContent.includes("Who to follow")) | |
who.forEach((a) => { | |
var sign = a.closest('[data-testid="cellInnerDiv"]'); | |
var t1 = sign.nextSibling; | |
var t2 = t1.nextSibling; | |
var t3 = t2.nextSibling; | |
if (sign) sign.style.display = 'none'; | |
if (t1) t1.style.display = 'none'; | |
if (t2) t2.style.display = 'none'; | |
if (t3) t3.style.display = 'none'; | |
}) | |
// Ad | |
var ads = spans.filter(a => a.textContent.includes("Ad")) | |
ads.forEach(a => console.log(a.closest('article').style.display = 'none')) | |
// Lists | |
var lists = spans.filter(a => a.textContent.includes('Discover new Lists')) | |
lists.forEach((a) => { | |
var disc = a.closest('[data-testid="cellInnerDiv"]') | |
var t1 = disc.nextSibling | |
var t2 = t1.nextSibling | |
var t3 = t2.nextSibling | |
if (disc) disc.style.display = 'none'; | |
if (t1) t1.style.display = 'none'; | |
if (t2) t2.style.display = 'none'; | |
if (t3) t3.style.display = 'none'; | |
}) | |
// People | |
var peo = h2s.filter(a => a.textContent.includes('People')) | |
peo.forEach((a) => { | |
var disc = a.closest('[data-testid="cellInnerDiv"]') | |
var t1 = disc.nextSibling | |
var t2 = t1.nextSibling | |
var t3 = t2.nextSibling | |
if (disc) disc.style.display = 'none'; | |
if (t1) t1.style.display = 'none'; | |
if (t2) t2.style.display = 'none'; | |
if (t3) t3.style.display = 'none'; | |
}) | |
// Creators | |
var creo = h2s.filter(a => a.textContent.includes('Creators for you')) | |
creo.forEach((a) => { | |
var disc = a.closest('[data-testid="cellInnerDiv"]') | |
var t1 = disc.nextSibling | |
var t2 = t1.nextSibling | |
var t3 = t2.nextSibling | |
if (disc) disc.style.display = 'none'; | |
if (t1) t1.style.display = 'none'; | |
if (t2) t2.style.display = 'none'; | |
if (t3) t3.style.display = 'none'; | |
}) | |
// Show | |
var show = spans.filter(a => a.textContent.includes("Show more")) | |
show.forEach((a) => { | |
console.log(a.closest('[data-testid="cellInnerDiv"]').style.display = 'none') | |
}) | |
// View all | |
var view = spans.filter(a => a.textContent.includes("View all")) | |
view.forEach((a) => { | |
console.log(a.closest('[data-testid="cellInnerDiv"]').style.display = 'none') | |
}) | |
// Discover | |
var disc = spans.filter(a => a.textContent.includes("Discover more")) | |
disc.forEach((a) => { | |
var lui = a.closest('[data-testid="cellInnerDiv"]') | |
var next = lui.nextSibling | |
if (lui) lui.remove(); | |
if (next) next.style.display = 'none'; | |
}) | |
})(); |
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()%7B%2F%2F%20Pools%20(all)%0Avar%20spans%20%3D%20%5B...document.querySelectorAll(%22span%22)%5D%0Avar%20h2s%20%3D%20%5B...document.querySelectorAll(%22h2%22)%5D%0A%0A%2F%2F%20Who%20to%20follow%0Avar%20who%20%3D%20spans.filter(a%20%3D%3E%20a.textContent.includes(%22Who%20to%20follow%22))%0Awho.forEach((a)%20%3D%3E%20%7B%0A%20%20var%20sign%20%3D%20a.closest('%5Bdata-testid%3D%22cellInnerDiv%22%5D')%3B%0A%20%20var%20t1%20%3D%20sign.nextSibling%3B%0A%20%20var%20t2%20%3D%20t1.nextSibling%3B%0A%20%20var%20t3%20%3D%20t2.nextSibling%3B%0A%20%20if%20(sign)%20sign.style.display%20%3D%20'none'%3B%0A%20%20if%20(t1)%20t1.style.display%20%3D%20'none'%3B%0A%20%20if%20(t2)%20t2.style.display%20%3D%20'none'%3B%0A%20%20if%20(t3)%20t3.style.display%20%3D%20'none'%3B%0A%7D)%0A%0A%2F%2F%20Ad%0Avar%20ads%20%3D%20spans.filter(a%20%3D%3E%20a.textContent.includes(%22Ad%22))%0Aads.forEach(a%20%3D%3E%20console.log(a.closest('article').style.display%20%3D%20'none'))%0A%0A%2F%2F%20Lists%0Avar%20lists%20%3D%20spans.filter(a%20%3D%3E%20a.textContent.includes('Discover%20new%20Lists'))%0Alists.forEach((a)%20%3D%3E%20%7B%0A%20%20var%20disc%20%3D%20a.closest('%5Bdata-testid%3D%22cellInnerDiv%22%5D')%0A%20%20var%20t1%20%3D%20disc.nextSibling%0A%20%20var%20t2%20%3D%20t1.nextSibling%0A%20%20var%20t3%20%3D%20t2.nextSibling%0A%20%20if%20(disc)%20disc.style.display%20%3D%20'none'%3B%0A%20%20if%20(t1)%20t1.style.display%20%3D%20'none'%3B%0A%20%20if%20(t2)%20t2.style.display%20%3D%20'none'%3B%0A%20%20if%20(t3)%20t3.style.display%20%3D%20'none'%3B%0A%7D)%0A%0A%2F%2F%20People%0Avar%20peo%20%3D%20h2s.filter(a%20%3D%3E%20a.textContent.includes('People'))%0Apeo.forEach((a)%20%3D%3E%20%7B%0A%20%20var%20disc%20%3D%20a.closest('%5Bdata-testid%3D%22cellInnerDiv%22%5D')%0A%20%20var%20t1%20%3D%20disc.nextSibling%0A%20%20var%20t2%20%3D%20t1.nextSibling%0A%20%20var%20t3%20%3D%20t2.nextSibling%0A%20%20if%20(disc)%20disc.style.display%20%3D%20'none'%3B%0A%20%20if%20(t1)%20t1.style.display%20%3D%20'none'%3B%0A%20%20if%20(t2)%20t2.style.display%20%3D%20'none'%3B%0A%20%20if%20(t3)%20t3.style.display%20%3D%20'none'%3B%0A%7D)%0A%0A%2F%2F%20Creators%0Avar%20creo%20%3D%20h2s.filter(a%20%3D%3E%20a.textContent.includes('Creators%20for%20you'))%0Acreo.forEach((a)%20%3D%3E%20%7B%0A%20%20var%20disc%20%3D%20a.closest('%5Bdata-testid%3D%22cellInnerDiv%22%5D')%0A%20%20var%20t1%20%3D%20disc.nextSibling%0A%20%20var%20t2%20%3D%20t1.nextSibling%0A%20%20var%20t3%20%3D%20t2.nextSibling%0A%20%20if%20(disc)%20disc.style.display%20%3D%20'none'%3B%0A%20%20if%20(t1)%20t1.style.display%20%3D%20'none'%3B%0A%20%20if%20(t2)%20t2.style.display%20%3D%20'none'%3B%0A%20%20if%20(t3)%20t3.style.display%20%3D%20'none'%3B%0A%7D)%0A%0A%2F%2F%20Show%0Avar%20show%20%3D%20spans.filter(a%20%3D%3E%20a.textContent.includes(%22Show%20more%22))%0Ashow.forEach((a)%20%3D%3E%20%7B%0A%20%20console.log(a.closest('%5Bdata-testid%3D%22cellInnerDiv%22%5D').style.display%20%3D%20'none')%0A%7D)%0A%0A%2F%2F%20View%20all%0Avar%20view%20%3D%20spans.filter(a%20%3D%3E%20a.textContent.includes(%22View%20all%22))%0Aview.forEach((a)%20%3D%3E%20%7B%0A%20%20console.log(a.closest('%5Bdata-testid%3D%22cellInnerDiv%22%5D').style.display%20%3D%20'none')%0A%7D)%0A%0A%2F%2F%20Discover%0Avar%20disc%20%3D%20spans.filter(a%20%3D%3E%20a.textContent.includes(%22Discover%20more%22))%0Adisc.forEach((a)%20%3D%3E%20%7B%0A%20%20var%20lui%20%3D%20a.closest('%5Bdata-testid%3D%22cellInnerDiv%22%5D')%0A%20%20var%20next%20%3D%20lui.nextSibling%0A%20%20if%20(lui)%20lui.remove()%3B%0A%20%20if%20(next)%20next.style.display%20%3D%20'none'%3B%0A%7D)%7D)()%3B |
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() { // View articles aria-label | |
var links = [...document.querySelectorAll("a[rel][role='link'][aria-label]")] | |
// Loop article links | |
links.forEach((a) => { | |
title = a.getAttribute('aria-label') | |
a.prepend(document.createTextNode(title)) | |
a.style.color = 'rgb(247, 249, 249)' | |
a.style.fontFamily = 'system-ui' | |
}) | |
})(); |
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()%7B%2F%2F%20View%20articles%20aria-label%0Avar%20links%20%3D%20%5B...document.querySelectorAll(%22a%5Brel%5D%5Brole%3D'link'%5D%5Baria-label%5D%22)%5D%0A%0A%2F%2F%20Loop%20article%20links%0Alinks.forEach((a)%20%3D%3E%20%7B%0A%20%20title%20%3D%20a.getAttribute('aria-label')%0A%20%20a.prepend(document.createTextNode(title))%0A%20%20a.style.color%3D'rgb(247%2C%20249%2C%20249)'%0A%20%20a.style.fontFamily%3D'system-ui'%0A%7D)%7D)()%3B |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment