mcbbs 自动领取任务

自动领取任务。

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==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" })
    }
}
)();