Skip to content

Instantly share code, notes, and snippets.

@julenwang
Last active May 20, 2022 05:12
Show Gist options
  • Save julenwang/f889ef5d9bb7869ff2675cc6991f5d02 to your computer and use it in GitHub Desktop.
Save julenwang/f889ef5d9bb7869ff2675cc6991f5d02 to your computer and use it in GitHub Desktop.
copy dmhy all magnet urls
// ==UserScript==
// @name copyDmhyAllMagnet.js
// @version 0.1.1
// @description 2022/05/05
// @author Julen
// @match https://share.dmhy.org/topics/list?*
// @icon https://www.google.com/s2/favicons?sz=64&domain=dmhy.org
// @grant none
// ==/UserScript==
(function () {
let searchButton = document.querySelector('.quick_search>form>input[type="submit"]');
if (searchButton) {
let btn = document.createElement('button');
btn.type = 'button';
btn.textContent = 'copy所有磁力链';
searchButton.parentNode.insertBefore(btn, searchButton.nextSibling);
btn.onclick = () => {
let result = Array.from(document.querySelectorAll('#topic_list>tbody>*'))
.map((ele) => {
return ele.querySelector('td>.download-arrow').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