千峰自动签到

千峰自动签到脚本:会在1到3秒内进行自动签到(已失效)

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         千峰自动签到
// @namespace    xiyu
// @version      0.1
// @description  千峰自动签到脚本:会在1到3秒内进行自动签到(已失效)
// @author       xiyu
// @include        *://live.polyv.cn/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    function getRandomIntInclusive(min, max) {
      min = Math.ceil(min);
      max = Math.floor(max);
      return Math.floor(Math.random() * (max - min + 1)) + min; //含最大值,含最小值
    }
    let sign = document.querySelector(".player-signed")
    let signButton = sign.querySelector(".btn-signed")

    let observer = new MutationObserver(function (mutations, observer) {
        mutations.forEach(mutationRecord => {
            setTimeout(()=> {
                let rect = signButton.getBoundingClientRect()
                var ev = document.createEvent('HTMLEvents')
                ev.pageX = rect.x + 10
                ev.pageY = rect.y + 22
                ev.initEvent('click', false, true)
                signButton.dispatchEvent(ev)
                console.log("签到成功: ", new Date())
            }, getRandomIntInclusive(1000, 3000))
        })
    });
    observer.observe(sign, {
        attributes: true
    })
    if(sign && signButton) {
        console.log("自动签到,启动成功");
    }
})();