Skip to content

Instantly share code, notes, and snippets.

@tongyifan
Created August 26, 2020 08:15
Show Gist options
  • Save tongyifan/7f8c5d329bd391d898b4b72e7ad06e0a to your computer and use it in GitHub Desktop.
Save tongyifan/7f8c5d329bd391d898b4b72e7ad06e0a to your computer and use it in GitHub Desktop.
OpenCD 个人页批量复制HnR种子下载链接(PT-Plugin-Plus插件)
/**
* PT-Plugin-Plus插件
* OpenCD 个人页批量复制HnR种子下载链接
* @author: tongyifan
* 适用页面: /userdetails.php
* 附加脚本: /schemas/NexusPHP/common.js
*
* 需要正确配置站点密钥
*/
(function () {
class App extends window.NexusPHPCommon {
init() {
PTService.addButton({
title: "复制HnR种子下载链接",
label: "复制HnR种子",
icon: "file_copy",
type: PTService.buttonType.popup,
click: (success, error) => {
const ka3 = jQuery("#ka3");
if (!ka3.is(":visible")) {
ka3.prev().find("u").trigger("click")
error("请重试...")
return;
}
if (!PTService.site.passkey) {
error("请先设置站点密钥(Passkey)。");
return;
}
let torrents = [];
jQuery("#ka3 > table > tbody > tr").each(function (index) {
if (index === 0) return;
if (jQuery("td", this).eq(9).text() === "..." &&
(new Date().getTime() - new Date(jQuery("td", this).eq(8).find("span").attr("title")).getTime()) > 216000000) {
torrents.push(/id=(.*)&hit=1/.exec(jQuery("td", this).eq(1).find("a").attr("href"))[1])
}
})
let downloads = []
torrents.forEach(torrent => {
downloads.push("https://open.cd/download.php?id=" + torrent + "&passkey=" + PTService.site.passkey);
});
PTService.call(PTService.action.copyTextToClipboard, downloads.join("\n"))
.then(result => {
success();
})
.catch(e => {
console.log(e);
error(e);
});
}
})
}
}
new App().init();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment