PT签到+首页喊魔力(不会反复跳转)

支持PT站点签到,论坛存在签到字样不会反复跳转(优化部分站点会跳多次问题),增加部分站点自动喊魔力。默认12秒后才跳转签到页面,请等13秒再随便点其他页面就好,由于优化为只跳转一次,如因为网络问题导致跳转卡住没有进入签到页面,需要手动刷新一下。修改自@shareit @xiongzwen 。

// ==UserScript==
// @name         PT签到+首页喊魔力(不会反复跳转)
// @namespace    http://tampermonkey.net/
// @version      1.0.17
// @license      MIT
// @author       40
// @description  支持PT站点签到,论坛存在签到字样不会反复跳转(优化部分站点会跳多次问题),增加部分站点自动喊魔力。默认12秒后才跳转签到页面,请等13秒再随便点其他页面就好,由于优化为只跳转一次,如因为网络问题导致跳转卡住没有进入签到页面,需要手动刷新一下。修改自@shareit @xiongzwen 。
// @grant GM_setValue
// @grant GM_getValue
// @icon  data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAgCAYAAACYTcH3AAAAAXNSR0IArs4c6QAAAbxJREFUWEftlz1IQlEUx/9Xn4hBRGNNBdXQh0a1RIsRfdDmUCQ0CAUt0ahCi0sNrrUEDm4NDQ8iomiwIWjRIKmlpaYc4xVU0vPduI8EET/O1ScOvTs+/uec3/ufc97lMRCPqhspgD8FFOcWMQSqXjgC2FBAccxSYhhFJDSqbnAA19TEfzEpAP6A4iDVIYn+L4w3oq05GHY4x3S1tsX2OvHyXEAy8UntLEKbHejrdyK2+1ErJsO5cZaNd8eYL6xtg+GgXoUWwpilGeOrzBfR0gAm2w3DOc8KGLEldY+wPPdawOV5vq62KFhcdqOn10luLRmGTNCE0IapZp7tjO3MxJQLd+kf8n61bGZWgh6MjCo4Vb/JQC2BKYI8Pug4Of5qnzONgpj3E/U6EJbPL7lxdZGHeONKpxkQKZiBQQXrIY/JIKwvB2oWRApGiIU7omg5kBUg0jCVgIbHXCak7LBWajN5ZkqDSx0Sz60AaciZIpQAmltwI5czpNa31p435Az5wyEptGHsW1tyZMB8Ue0GHDOygVbrGcMt84bfNxjjCauTy+bjQND88R+PvvkBx36t31vZ5BL6DDiS9/Guw1/5Ifek+Vvu+AAAAABJRU5ErkJggg==
// @include    http://hdmayi.com/*
// @include    http://ihdbits.me/*
// @include    https://zhuque.in/*
// @include    https://1ptba.com/*
// @include    https://audiences.me/*
// @include    https://byr.pt/*
// @include    https://ccfbits.org/*
// @include    https://club.hares.top/*
// @include    https://cyanbug.net/*
// @include    https://discfan.net/*
// @include    https://et8.org/*
// @include    https://filelist.io/*
// @include    https://hdatmos.club/*
// @include    https://hdchina.org/*
// @include    https://hdcity.leniter.org/*
// @include    https://hdfans.org/*
// @include    https://hdhome.org/*
// @include    https://hdmayi.com/*
// @include    https://hdsky.me/*
// @include    https://hdtime.org/*
// @include    https://hdvideo.one/*
// @include    https://hhanclub.top/*
// @include    https://hudbt.hust.edu.cn/*
// @include    https://iptorre*
// @include    https://kp.m-team.cc/*
// @include    https://lemonhd.org/*
// @include    https://nanyangpt.com/*
// @include    https://npupt.com/*
// @include    https://ourbits.club/*
// @include    https://piggo.me/*
// @include    https://pt.btschool.club/*
// @include    https://pt.eastgame.org/*
// @include    https://pt.hdbd.us/*
// @include    https://pt.keepfrds.com/*
// @include    https://ptchina.org/*
// @include    https://pterclub.com/*
// @include    https://pthome.net/*
// @include    https://springsunday.net/*
// @include    https://totheglory.im/*
// @include    https://www.beitai.pt/*
// @include    https://www.carpet.net/*
// @include    https://www.haidan.video/*
// @include    https://www.hd.ai/*
// @include    https://www.hdarea.co/*
// @include    https://hdarea.club/*
// @include    https://www.hddolby.com/*
// @include    https://www.hdpt.xyz/*
// @include    https://www.htpt.cc/*
// @include    https://www.icc2022.com/*
// @include    https://www.nicept.net/*
// @include    https://www.oshen.win/*
// @include    https://www.pthome.net/*
// @include    https://www.tjupt.org/*
// @include    https://www.torrent*
// @include    https://zmpt.cc/*
// @include    https://carpt.net/*
// @include    https://wintersakura.net/*
// @include    https://sharkpt.net/*
// @include    https://gainbound.net/*
// @include    https://hdvideo.one/*
// @include    https://pt.2xfree.org/*
// @include    http://www.oshen.win/*
// @include    http://uploads.ltd/*
// @include    https://ubits.club/*
// @include    http://hdzone.me/*
// @include    https://pt.soulvoice.club/*
// @include    https://www.gamegamept.com/*
// @include    https://pt.itzmx.com/*
// @include    https://pt.0ff.cc/*
// @include    https://carpt.net/*
// @include    https://www.pttime.org/*
// @include    https://rousi.zip/*
// @include    https://pandapt.net/*
// @include    https://invites.fun/*
// @include    https://wukongwendao.top/*
// @include    https://hdfun.me/*
// @include    https://hhanclub.top/*
// @include    https://pt.hd4fans.org/*
// @include    https://pt.gtk.pw/*
// @include    https://star-space.net/*
// @include    https://u2.dmhy.org/*
// @include    https://www.hdkyl.in/*
// @include    https://www.agsvpt.com/*
// @include    https://www.qingwapt.com/*
// @include    https://pt.cdfile.org/*
// @include    https://ptvicomo.net/*
// @include    https://t.tosky.club/*
// @include    https://crabpt.vip/*
// @include    https://share.ilolicon.com/*
// @include    https://ptcafe.club/*
// @include    https://pt.hdupt.com/*
// @include    https://hdcity.city/*
// ==/UserScript==

(function () {
  const host = window.location.host;
  const href = window.location.href;
  const AttendanceDay = host + 'AttendanceDay';
  const GetMOLIDay = host + 'GetMOLI';
  function formatDate(date) {
     let year = date.getFullYear();
     let month = (date.getMonth() + 1).toString().padStart(2, '0');
     let day = date.getDate().toString().padStart(2, '0');
     return `${year}-${month}-${day}`;
  }
  const today = formatDate(new Date());
  function xpath(query) {
     return document.evaluate(query, document, null,
         XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  }
  setTimeout(function () {
    var attendanceTexts = [
      "签到得魔力",
      "签 到",
      "签到得猫粮",
      "签到",
      "簽到",
      "每日签到",
      "簽到得魔力",
      "每日打卡",
      "签到领魔力",
    ];
    var lastAttendanceDay = GM_getValue(AttendanceDay);
    if (lastAttendanceDay === today) {
        console.log("今日已签到:"+lastAttendanceDay);
         return;
    }
    for (var index in attendanceTexts) {
        var text = attendanceTexts[index];
        var allElements = xpath("//*[contains(text(), '"+text+"')]");
        for (var i = 0; i < allElements.snapshotLength; i++) {
            var ptSignElements = allElements.snapshotItem(i);
            if (ptSignElements != null) {
                // console.log(ptSignElements.innerText);
                if (ptSignElements.innerText.indexOf(text) != -1) {
                    if (ptSignElements.innerText.indexOf("已") != -1 || ptSignElements.innerText.indexOf("详情") != -1) {
                        console.log("已签到:" + window.location.host);
                        GM_setValue(AttendanceDay, today);
                    } else {
                        try{
                          if(host.indexOf("ourbits")!=-1 ){
                              console.log("href:"+href);
                              console.log("host:"+host);
                              if(href.indexOf("attendance.php")==-1){
                                  setTimeout(function(){GM_setValue(AttendanceDay, today);ptSignElements.click();},5000);
                              }
                              else{
                                  GM_setValue(AttendanceDay, today);
                              }
                          }else{
                              if(href.indexOf("attendance.php")==-1){
                                  GM_setValue(AttendanceDay, today);
                                  ptSignElements.click();
                              }
                              else{
                                  GM_setValue(AttendanceDay, today);
                              }
                          }
                          console.log("签到:" + window.location.host);
                        } catch (error) {
                          // do nothing
                            console.log("error:"+error);
                        }
                    }
                }
            }
        }
    }
  }, 12000);
  setTimeout(function () {
    var getMOLIDayTexts = [
      ["shbox_text","hbsubmit","qingwapt.com","蛙总,求上传"],
      ["shbox_text","hbsubmit","tosky.club","来点魔力|来点上传"],
      ["shbox_text","hbsubmit","ptvicomo.net","小象求象草"],
      ["shbox_text","hbsubmit","cyanbug.net","青虫娘 求魔力|青虫娘 求上传|青虫娘 求VIP|青虫娘 求彩虹ID"],
    ];
    var lastGetMOLIDay = GM_getValue(GetMOLIDay);
    if (lastGetMOLIDay === today) {
        console.log("今日已求:"+lastGetMOLIDay);
         return;
    }
    for (var index in getMOLIDayTexts) {
        if(getMOLIDayTexts[index]==null || getMOLIDayTexts[index][2]==null || host.indexOf(getMOLIDayTexts[index][2]) == -1){
            continue;
        }
        var input = getMOLIDayTexts[index][0];
        var sayALL = getMOLIDayTexts[index][3];
        var submit = getMOLIDayTexts[index][1];
        var inputElement=document.getElementById(input);
        var submitElement=document.getElementById(submit);
        if(inputElement==null || submitElement==null){
            continue;
        }
        try{
            var sayArr = sayALL.split("|");
            for (let i = 0; i < sayArr.length; i++) {
                (function (j) {
                    let say=sayArr[j];
                    let stay=500+2000*j;
                    setTimeout(() => {
                        inputElement.value=say;
                        submitElement.click();
                        console.log(window.location.host+"已喊:" +say);
                    },stay);
                })(i);
            }
            GM_setValue(GetMOLIDay, today);
            } catch (error) {
            console.log("error:"+error);
        }
    }
  }, 500);
})();