Skip to content

Instantly share code, notes, and snippets.

@julenwang
Created July 2, 2024 18:56
Show Gist options
  • Save julenwang/6441fa6a23b1458413d915db500cc648 to your computer and use it in GitHub Desktop.
Save julenwang/6441fa6a23b1458413d915db500cc648 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name copyNyaaMagnets
// @namespace http://tampermonkey.net/
// @version 2024-07-02
// @description try to take over the world!
// @author Julen
// @match https://nyaa.si/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=nyaa.si
// @grant none
// ==/UserScript==
(function () {
let nav = document.querySelector('nav');
if (nav) {
let btn = document.createElement('button');
btn.type = 'button';
btn.textContent = 'copy所有磁力链';
nav.append(btn);
btn.onclick = () => {
let result = Array.from(document.querySelectorAll('.table-responsive tbody td a[href^="magnet"]'))
.map((ele) => {
return ele.href;
})
.reduce((acc, cur) => {
return `${acc}${cur}\n`;
}, '');
window.navigator.clipboard.writeText(result);
};
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment