Last active
July 22, 2016 12:55
-
-
Save loadletter/2614a06062fabe1a4ac9631440455e26 to your computer and use it in GitHub Desktop.
Improved nyaa.se magnetlink-adding userscript
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
// ==UserScript== | |
// @name Nyaa Magnet Links | |
// @author Kizuna | |
// @version 1.0.4 | |
// @include http://*.nyaa.se/* | |
// @include https://*.nyaa.se/* | |
// @description Adds magnet links to Nyaa.se for convenience | |
// @run-at document-end | |
// @namespace https://greasyfork.org/users/4706-kizuna | |
// @grant none | |
// ==/UserScript== | |
var url = document.URL; | |
if (url.search("page=search")) { | |
var urls = document.querySelectorAll('[title="Download"]'); | |
var magnet, i; | |
for (i=0; i<urls.length; i++) { | |
magnet = document.createElement('a'); | |
magnet.href = urls[i].href + '&magnet=1'; | |
magnet.rel = "nofollow"; | |
magnet.innerHTML = '<img src="//i.imgur.com/I1lPYRt.png" alt="MG" width="16px"/>'; | |
urls[i].parentNode.insertBefore(magnet, urls[i].nextSibling); | |
} | |
} | |
if (url.search("page=view")) { | |
var button = document.querySelector('.viewdownloadbutton a'); | |
var magnet = document.createElement('div'); | |
magnet.className = "viewdownloadbutton"; | |
magnet.innerHTML = '<a href="' + button.href + '&magnet=1" rel="nofollow"><img src="//i.imgur.com/I1lPYRt.png" alt="Magnet" width="25px" style="padding-top: 1px"/></a>'; | |
button.parentNode.parentNode.insertBefore(magnet, button.parentNode.nextSibling); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment