Created
August 18, 2019 02:14
-
-
Save fallaciousreasoning/7bda9a82307abdd140789dc6ee41e3f6 to your computer and use it in GitHub Desktop.
Opens magnet links in a new tab. This is useful if you have a website registered as a handler for magnet:// links (such as instant.io, or Deluge Web)
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 Magnet Links in New Tab | |
// @namespace Violentmonkey Scripts | |
// @match https://thepiratebay.*/* | |
// @match *://audiobookbay.*/* | |
// @grant none | |
// ==/UserScript== | |
const poll = (action, regularity) => { | |
action(); | |
setTimeout(() => poll(action, regularity), regularity); | |
} | |
const openMagnetsInNewTab = () => { | |
const untargeted = document.querySelectorAll("a[href^='magnet']:not([target])"); | |
for (const a of untargeted) | |
a.setAttribute('target', '_blank'); | |
} | |
poll(openMagnetsInNewTab, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment