North-plus Auto Task

自动领取和完成北+日常和周常任务

目前為 2018-06-17 提交的版本,檢視 最新版本

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

You will need to install an extension such as Tampermonkey to install this script.

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         North-plus Auto Task
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  自动领取和完成北+日常和周常任务
// @author       You
// @match        https://*.white-plus.net
// @match        https://*.white-plus.net/index.php
// @match        https://*.south-plus.net
// @match        https://*.white-plus.net/index.php
// @require  https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...

    var taskBaseURL = 'plugin.php?H_name=tasks&action=ajax&actions=job&cid=';
    var rewardBaseURL = 'plugin.php?H_name=tasks&action=ajax&actions=job2&cid=';

    var taskDailyID = '15';
    var taskWeeklyID = '14';

    var taskDailyKey = 'lastTaskDaily';
    var taskWeeklyKey = 'lastTaskWeekly';

    var taskDailyInterval = 1000*60*60*24;
    var taskWeeklyInterval = taskDailyInterval * 7;

    function checkTask(now, taskID, taskKey, taskInterval) {
        var lastSignIn = GM_getValue(taskKey);
        if(lastSignIn === undefined || (now - lastSignIn) > taskInterval) {
            // 领取任务
            $.get(taskBaseURL + taskID, function(data, status) {
                console.log(data);
                console.log(status);

                setTimeout(function() {
                    // 等 1.5s,领取奖励
                    $.get(rewardBaseURL + taskID, function(data, status) {
                        console.log(data);
                        console.log(status);

                        GM_setValue(taskKey, now);
                    });
                }, 1500);

            });
        }
        else {
            // do nothing.
            var interval = (now - lastSignIn) / (1000);
            console.log('距离上次任务过了 ' + interval + ' 秒');
        }
    }

    var now = Date.now();
    checkTask(now, taskDailyID, taskDailyKey, taskDailyInterval);
    setTimeout(function() {
        checkTask(now, taskWeeklyID, taskWeeklyKey, taskWeeklyInterval);
    }, 1500);


})();