v2ex_signin

V2EX自动签到

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         v2ex_signin
// @namespace    zhihaofans
// @version      3
// @description  V2EX自动签到
// @author       zhihaofans
// @match        https://v2ex.com/*
// @match        https://www.v2ex.com/*
// @grant        GM_addStyle
// @grant        GM_getResourceText
// @require      https://cdn.bootcss.com/sweetalert/1.1.3/sweetalert.min.js
// @resource     sweetalertcss https://cdn.bootcss.com/sweetalert/1.1.3/sweetalert.min.css
// @note         Greasyfork地址:https://greasyfork.org/zh-CN/scripts/28508
// @note         Github地址:https://github.com/zhihaofans/JavaScript/v2ex/v2ex_signin.js
// @license      Apache License 2.0
// ==/UserScript==
var once_key = null;
GM_addStyle (GM_getResourceText ("sweetalertcss"));
function getOnce() {
    var once_key_temp = null;
    for (var a = 0; a < $('a.top').length; a++) {
        var b = $('a.top:eq(' + a + ')').attr('onclick');
        if (b !== undefined) {
            var c = b.indexOf('?once=');
            var d = b.indexOf('\';', c);
            if (c != -1) {
                once_key_temp = b.substring(c + 6, d);

            }
        }
    }
    return once_key_temp;
}
$(document).ready(function () {
    once_key = getOnce();
    console.log('once:', once_key);
    if (once_key !== null) {
        var signinUrl = 'https://' + location.hostname + '/mission/daily/redeem?once=' + once_key;
        $.get(signinUrl, function (data) {
            console.log('连接成功');
            if (data.indexOf('<div class=\"message\" onclick=\"$(this).slideUp(\'fast\');\">每日登录奖励已领取</div>') != -1) {
                newAlert('签到成功', '恭喜你,今天签到成功了哟');
            } else if (data.indexOf('<div class=\"message\" onclick=\"$(this).slideUp(\'fast\');\">今天的登录奖励已经领取过了哦</div>') != -1) {
                console.log('很遗憾,今天已经签到过了哟');
            } else {
                newAlert('签到失败', '签到发生未知错误', 'error');
            }
        })
            .fail(function () {
                newAlert('签到失败', '发送签到请求失败', 'error');
            });
    }
});
function newAlert(alertTitle, alertText, alertType = 'success', alertTimeout = 1500) {
    swal({ title: alertTitle, text: alertText, timer: alertTimeout, showConfirmButton: false, type: alertType });
}