Greasy Fork

Greasy Fork is available in English.

一个草率的V2EX右侧一键签到UI

网站右侧显示签到UI, 无需跳转直接签到成功

当前为 2023-12-06 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         一个草率的V2EX右侧一键签到UI
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  网站右侧显示签到UI, 无需跳转直接签到成功
// @author       echo
// @match        *://*.v2ex.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=v2ex.com
// @grant        none
// @require      https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
// @license      GNU GPLv3
// ==/UserScript==

(function () {
  'use strict';

  $(function () {
    let xhr, div;
    xhr = new XMLHttpRequest();
    xhr.onload = function (e) {
      let cnt = new RegExp("<body>.*<\/body>", "is").exec(xhr.response);
      div = document.createElement('div');
      div.innerHTML = cnt;
      let signin = div.querySelector('.site-nav .tools a[href="/signin"]');
      if (null != signin) return;
      if (window.location.pathname == '/mission/daily') return;
      let position = $('#Rightbar .box:eq(0) .cell:eq(2)');
      if (position == null) return;
      let code = 75136;
      let url = "";
      let before = { txt: '签&ensp;&ensp;&ensp;到', c1: '#9EEB80', c2: '#90CC78' };
      let after = { txt: '今日已签到', c1: '#EBA380', c2: '#EBA380' };
      let bar = $(`<div class="cell" style="">
<div cellpadding="0" cellspacing="0" border="0" width="100%" style="text-shadow:0.5px 0.5px 2px #fff;background-color:#ffffffff;padding: 4px;text-align: center;"><a href="#" style="
  color:#666;
  font-weight:bold;
  display: block;
  width: 100%;
  height: 100%;
  text-decoration: none;
  user-select:none
"></a>
</div>
</div>`);
      let aFather = bar.children();
      let a = aFather.children();
      position.after(bar);
      xhr = new XMLHttpRequest();
      xhr.onload = function (e) {
        let cnt = new RegExp("<body>.*<\/body>", "is").exec(xhr.response);
        div.innerHTML = cnt;
        let btn = div.querySelector('#Main input');
        if (btn == null || btn.value == "查看我的账户余额") { refresh(after); stopA(); return; } else { refresh(before); }
        let txt = btn.getAttribute('onclick');
        code = new RegExp("(?<=once=)\\d{5}").exec(txt)[0];
        url = `/mission/daily/redeem?once=${code}`;
        a.one('click', function (e) { $.get(url, function (rs) { refresh(after) }); setTimeout(() => { stopA(); }, 10); });
      }
      xhr.open('get', '/mission/daily');
      xhr.send();
    }
    xhr.open('get', 'https://www.v2ex.com/');
    xhr.send();
    function refresh(signin) {
      a.html(signin.txt);
      aFather.css('backgroundColor', signin.c1);
      aFather.hover(function () { $(this).css('backgroundColor', signin.c2) }, function () { $(this).css('backgroundColor', signin.c1) });
    }
    function stopA() {
      a.attr('href', '/mission/daily');
    }
  });
})();