Greasy Fork is available in English.

mcbbs 自动领取任务

自动领取任务。

// ==UserScript==
// @name         mcbbs 自动领取任务
// @version      0.9.3
// @include      https://www.mcbbs.net/*
// @author       xmdhs
// @description  自动领取任务。
// @namespace https://greasyfork.org/users/166541
// ==/UserScript==

(async () => {
    const times = localStorage.getItem("autoapply")
    if (Math.round(new Date().getTime() / 1000) - times >= 60) {
        localStorage.setItem("autoapply", Math.round(new Date().getTime() / 1000))
    } else {
        return
    }
    const url = document.querySelector(`#user_info_menu a[href^="member.php?mod=logging"]`).href
    const key = new URL(url).searchParams.get("formhash")

    const taskList = ["39", "22", "40", "24", "55"]

    sign()
    async function sign() {
        taskList.forEach(task => run(key, task, "draw"))
        await new Promise(rs => setTimeout(rs, 1500))
        taskList.forEach(task => run(key, task, "apply"))
    }

    function run(key, task, type) {
        return fetch("home.php?mod=task&do=" + type + "&id=" + task + "&hash=" + key, { credentials: "same-origin" })
    }
}
)();