AntAutoPost

Auto post ant articles

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

// ==UserScript==
// @name         AntAutoPost
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  Auto post ant articles
// @author       snaillonely
// @match        *://s.alipay.com/life/web/fortune/publishNew*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        GM_log
// @grant        GM_getResourceText
// @grant        GM_addStyle
// @license      MIT
// ==/UserScript==
function toIsoString(date) {
    var pad = function(num) {
        return (num < 10 ? '0' : '') + num;
    }

    return date.getFullYear() + '-' + pad(date.getMonth() + 1) + '-' + pad(date.getDate())
        + 'T' + pad(date.getHours()) + ':' + pad(date.getMinutes()) + ':' + pad(date.getSeconds())
}
var countDown

(function() {
    'use strict';

    let btn1 = document.createElement('input')
    btn1.type = 'datetime-local'
    btn1.step = '30'
    btn1.style.margin = "8px"
    let btn2 = document.createElement('input')
    btn2.type = 'checkbox'
    btn2.id = 'auto_post_checkbox'
    btn2.style.margin = "8px"
    let btn3 = document.createElement('label')
    btn3.textContent = '定时发送'
    btn3.setAttribute('for', 'auto_post_checkbox')
    btn3.style.margin = "8px"

    let divBtn = document.createElement('div')
    divBtn.appendChild(btn1)
    divBtn.appendChild(btn2)
    divBtn.appendChild(btn3)
    divBtn.setAttribute('class', 'buttonContainer___g_Ssy')
    // divBtn.addEventListener('click', () => { btn2.click() })


    btn2.addEventListener('click', () => {
        btn2.click()
        GM_log("btn2 is checked: " + btn2.checked)
        if (btn2.checked) {
            countDown = setInterval(() => {
                let myDate = new Date();
                let current = toIsoString(new Date())
                GM_log("current time is: " + current)
                GM_log("setting time is: " + btn1.value)
                // GM_log("btn1 value is: " + btn1.value)
                if (btn1.value != "" && btn1.value <= current) {
                    btn2.click()
                    // document.querySelector("#react-root > div > div.main-content > div.buttonContainer___g_Ssy > button:nth-child(2)").click()
                    document.querySelector("#react-root > div > div.main-content > div.buttonContainer___g_Ssy > button.ant-btn.ant-btn-primary").click()
                }
            }, 1000)
        } else {
            clearInterval(countDown)
        }
    })

    var searchTime = 0
    let searchMainContent = setInterval(() => {
        let temp = document.querySelector("#react-root > div > div.main-content")
        if (temp == null) {
            GM_log('can not find the button')
            searchTime++
            if (searchTime == 10) {
                alert('版本过低,请联系开发人员升级')
                clearInterval(searchMainContent)
            }
        } else {
            temp.appendChild(divBtn)
            clearInterval(searchMainContent)
        }
    }, 1000)
})();

QingJ © 2025

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