Skip to content

Instantly share code, notes, and snippets.

@douglashsilva
Last active November 12, 2024 09:05
Show Gist options
  • Save douglashsilva/b62ff36dd6f8f46ecf65c81898540800 to your computer and use it in GitHub Desktop.
Save douglashsilva/b62ff36dd6f8f46ecf65c81898540800 to your computer and use it in GitHub Desktop.
Search for all hidden magnet on torrent blocking pages | Obs: Only run on the console where the page is with torrent blocking
// Search for all hidden Torrent Magnet URL on pages
function searchAllMagnet(){
// Search Torrent Magnet URL on Attributes
function searchMagnet(dom){
let trim = (str) => String(str).toString().trim(), magnet = [], regex = /^magnet\:\?.*$/gim
dom = trim(dom)
if(dom.textContent && regex.test(dom)) magnet.push(dom.textContent)
Array.from(dom.attributes)
.filter((value) => regex.test(trim(value)))
.map(({ nodeValue }) => magnet.push(trim(nodeValue)))
return magnet.length >= 1 ? magnet : false
}
// Call Search on DOM
let dom = Array.from(document.querySelectorAll("a, span, div, li, i, td, tr, textarea"))
.filter((dom) => searchMagnet(dom))
.map((dom) => searchMagnet(dom))
// Display Found's
if(dom.length >= 1){
dom.map((array) => array.map((magnet) => console.log(`Found: ${magnet} \n`)))
}else{
console.log(`Not Found!\n`)
}
}
// Run !!!
searchAllMagnet()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment