Greasy Fork is available in English.
点选所有需要下载的种子然后一键复制。
当前为
// ==UserScript==
// @name 动漫花园(dmhy.org) - 批量复制磁力链接
// @namespace moe.jixun.dmhy
// @version 1.0
// @description 点选所有需要下载的种子然后一键复制。
// @author Jixun
// @include http://share.dmhy.org/topics/*
// @include https://share.dmhy.org/topics/*
// @grant none
// @run-at document-start
// ==/UserScript==
const APP_NAME = '动漫花园 - 批量复制磁力链接';
function text (str) {
return document.createTextNode(str);
}
function span (str) {
let span = document.createElement('span');
span.appendChild(text(str));
return span;
}
function button (name, click, type = '', icon = '') {
let btn = document.createElement('button');
btn.classList.add('btn');
btn.classList.add('btn-' + type);
if (icon) {
let i = document.createElement('i');
i.className = icon;
btn.appendChild(i);
btn.appendChild(text(' '));
btn.classList.add('btn-icon');
}
btn.addEventListener('click', click);
btn.appendChild(text(name));
return btn;
}
addEventListener('DOMContentLoaded', function() {
var topics = document.getElementById('topic_list');
var style = document.createElement('style');
style.textContent = `
.moe-jixun-container
{
position: fixed;
left: .5rem;
bottom: .5rem;
}
.moe-jixun-container > .btn+.btn,
.moe-jixun-container > span
{
margin-left: .3rem;
}
.moe-jixun-container > span
{
background: #efe;
padding: 2px 1em;
font-weight: bold;
}
.btn {
background: white;
border: 1px solid black;
padding: .3rem 1rem;
border-radius: 5px;
box-shadow: 2px 2px 5px #f3f3f3;
}
.selected td,
.selected th
{
background: lightgreen !important;
}
`;
if (topics) {
console.info('[%s]: 找到列表,开始绑定事件...', APP_NAME);
topics.addEventListener('click', function (e) {
e.preventDefault();
e.stopPropagation();
$(e.target).parents('tr').toggleClass('selected');
});
let btnContainer = document.createElement('div');
btnContainer.className = 'moe-jixun-container';
btnContainer.appendChild(button('拷贝所选磁力', function (e) {
let anchors = topics.querySelectorAll('.selected a.arrow-magnet');
let urls = Array.prototype.map.call(anchors, anchor => anchor.href);
let dummy = document.createElement('textarea');
dummy.value = urls.join('\n');
document.body.appendChild(dummy);
dummy.select();
document.execCommand('copy');
document.body.removeChild(dummy);
let notice = span('已复制!');
btnContainer.appendChild(notice);
setTimeout(function () {
btnContainer.removeChild(notice);
}, 1500);
}, 'copy'));
btnContainer.appendChild(button('选深色', function (e) {
$('tr.even', topics).toggleClass('selected');
}, 'copy'));
btnContainer.appendChild(button('选浅色', function (e) {
$('tr.odd', topics).toggleClass('selected');
}, 'copy'));
document.body.appendChild(btnContainer);
document.body.appendChild(style);
console.info('[%s]: 就绪。', APP_NAME);
} else {
console.info('[%s]: 未找到下载列表,如果误报请联系作者修正。', APP_NAME);
}
});