v2ex 自动签到

try to take over the world!

  1. // ==UserScript==
  2. // @name v2ex 自动签到
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.6
  5. // @description try to take over the world!
  6. // @author imzhi
  7. // @match https://v2ex.com
  8. // @match https://v2ex.com/mission/daily
  9. // @require https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.5.1/jquery.min.js
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. 'use strict';
  14.  
  15. (function() {
  16. // 对cloudflare拦截时直接返回
  17. if (!$('#Logo').length) {
  18. console.warn('no #Logo');
  19. return;
  20. }
  21. if (!$('#member-activity').length) {
  22. console.warn('未登录');
  23. return;
  24. }
  25. var date = new Date();
  26. var currdate = date.getFullYear() + '-' + (date.getMonth()+1) + '-' + date.getDate();
  27. var store = localStorage.getItem('tampermonkey-v2ex-sign');
  28. // 判断今天是否已经执行过
  29. if (store && store === currdate) {
  30. console.warn('已执行', store, currdate);
  31. return;
  32. }
  33. var url = 'https://v2ex.com/mission/daily';
  34. var href = location.href;
  35. if (href === 'https://v2ex.com/') {
  36. var $link = $('#Rightbar .inner a');
  37. if ($link.length) {
  38. location.href = url;
  39. } else {
  40. localStorage.setItem('tampermonkey-v2ex-sign', currdate);
  41. console.warn('已签到');
  42. }
  43. }
  44. if (href === url) {
  45. var $button = $('#Main .cell .super.normal.button');
  46. console.warn('签到按钮不存在aaa', $button);
  47. if ($button.length) {
  48. $button.click();
  49. localStorage.setItem('tampermonkey-v2ex-sign', currdate);
  50. } else {
  51. console.warn('签到按钮不存在');
  52. }
  53. }
  54. })();