NexusPHP PT 一键认领

一键认领

当前为 2023-09-04 提交的版本,查看 最新版本

// ==UserScript==
// @name            NexusPHP PT 一键认领
// @name:en         NexusPHP PT torrents claim
// @version         0.0.1
// @description     一键认领
// @description:en  one key claim all the seeding torrents in NexusPHP PT.
// @author          mintiang
// @match           https://*/userdetails.php?id=*
// @license         MIT
// @grant           unsafeWindow
// @namespace https://gf.qytechs.cn/users/920757
// ==/UserScript==

/**
 * 改自HDTIME一键认领, 原网址: https://gf.qytechs.cn/scripts/469883
 */

(function () {
  'use strict';

  // Your code here...
  function wait(time) {
    return new Promise((resolve) => setTimeout(resolve, time)).catch((e) => { console.log(e); });
  }

  window.onload = function () {

    //let buttonArr = new Array(...jQuery('#ka1').find('[data-action="addClaim"]'))
    //if(buttonArr && buttonArr.length){
      let url = new URL(window.location.href);
      let params = url.searchParams;
      if(jQuery("a[href='claim.php?uid="+params.get("id")+"']").length){
         let aTag='<a id="claimAllTorrents" href="javascript:void(0);" onclick="window.manualClaimTorrents();" style="margin-left:10px;font-weight:bold;color:red" title="认领全部当前做种(运行后无法停止,强制停止可关闭页面)">一键认领</a><br>'
        jQuery('#ka1').parent().prepend(aTag)
      }
   // }
  }

  unsafeWindow.manualClaimTorrents = async function () {
      jQuery('#ka1').parent().find('a')[1].click()
      await wait(3000)
    let buttonArr = new Array(...(jQuery('#ka1').find('[data-action="addClaim"]').length?jQuery('#ka1').find('[data-action="addClaim"]'):[]))
    buttonArr = buttonArr.filter(x=>jQuery(x).css('display') !== 'none')
    if(!buttonArr || !buttonArr.length){
        alert('未检测到可以认领的种子\n请打开当前做种列表, 若列表没有种子您无法认领!\n若您已经全部认领请无视!')
        return
    }
    let total = 0,success=0;
    var msg = "确定要认领全部种子吗?\n\n严正警告: \n请勿短时间内多次点击, 否则后果自负!\n请勿短时间内多次点击, 否则后果自负!\n请勿短时间内多次点击, 否则后果自负! \n点击后请等待至弹窗, 种子越多越要等捏(每个种子访问间隔500ms)";
    if (confirm(msg) == true) { //提示选择确认
      for(let el of buttonArr){
          total++
          let torrentId = jQuery(el).attr("data-torrent_id")
          let action = jQuery(el).attr("data-action")
          let param = {
              "action" : action,
              "params" : {
                  torrent_id : torrentId
              }
          }
          new Promise((resolve) => {
              jQuery.post("ajax.php", param, function (response) {
                if (response.ret == 0) {
                    success++
                }
            }, "json")
          })
          layer.msg(`正在认领第${total}个,成功认领${success}个`, {
              icon: 6,
              time: 4000 //2秒关闭(如果不配置,默认是3秒)
          })
          await wait(5000)
      }
    }
    alert(`共计${total}个种子,本次成功认领${success}个。`);
  }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址