v2ex 自动签到

try to take over the world!

目前為 2024-09-25 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         v2ex 自动签到
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  try to take over the world!
// @author       imzhi
// @match        https://v2ex.com*
// @require      https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.5.1/jquery.min.js
// @grant        none
// ==/UserScript==

'use strict';

(function() {
    // 对cloudflare拦截时直接返回
    if (!$('#Logo').length) {
        console.warn('no #Logo');
        return;
    }
    if (!$('#member-activity').length) {
        console.warn('未登录');
        return;
    }
    var date = new Date();
    var currdate = date.getFullYear() + '-' + date.getMonth() + '-' + date.getDate();
    var store = localStorage.getItem('tampermonkey-v2ex-sign');
    // 判断今天是否已经执行过
    if (store && store === currdate) {
        console.warn('已执行', store, currdate);
        return;
    }
    var url = 'https://v2ex.com/mission/daily';
    var href = location.href;
    if (href === 'https://v2ex.com/') {
        var $link = $('#Rightbar > div:nth-child(4) > div > a');
        if ($link.length) {
            location.href = url;
        } else {
            localStorage.setItem('tampermonkey-v2ex-sign', currdate);
            console.warn('已签到');
        }
    }
    if (href === url) {
        var $button = $('#Main > div.box > div:nth-child(2) > input');
        if ($button.length) {
            $button.click();
            localStorage.setItem('tampermonkey-v2ex-sign', currdate);
        } else {
            console.warn('签到按钮不存在');
        }
    }
})();