vikacg enhancement

为vikacg提供自动签到,自动翻页功能

  1. // ==UserScript==
  2. // @name vikacg enhancement
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.4.6
  5. // @description 为vikacg提供自动签到,自动翻页功能
  6. // @author cordea
  7. // @match https://www.vikacg.com/*
  8. // @grant GM_setValue
  9. // @grant GM_getValue
  10. // @grant GM_xmlhttpRequest
  11. // ==/UserScript==
  12. "use strict";
  13. const DATE = "DATE";
  14. let today = new Date();
  15. let lastSignIn = new Date(GM_getValue(DATE, new Date("2006-1-1")));
  16. if (
  17. today.getFullYear() != lastSignIn.getFullYear() ||
  18. today.getMonth() != lastSignIn.getMonth() ||
  19. today.getDate() != lastSignIn.getDate()
  20. ) {
  21. GM_setValue(DATE, today);
  22. DailySignIn();
  23. }
  24. else{
  25. console.log("今天已经自动签到,如有问题请尝试手动签到");
  26. }
  27. const button = document.querySelector(
  28. "#main > div.zrz-pager.clearfix.pd10.pos-r.box > div > button"
  29. );
  30. const options = {
  31. threshold: 1.0,
  32. };
  33. const callback = function (entries, observer) {
  34. button.click();
  35. console.log("auto click");
  36. };
  37. const observer = new IntersectionObserver(callback, options);
  38. observer.observe(button);
  39. function DailySignIn() {
  40. console.log(GM_getValue(DATE, "Date not found"));
  41. GM_xmlhttpRequest({
  42. "method": "GET",
  43. "url": "https://www.vikacg.com/qiandao",
  44. "headers": {
  45. "Accept":
  46. "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
  47. "Accept-Encoding": "gzip, deflate, br",
  48. "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,ja;q=0.7",
  49. "Cache-Control": "max-age=0",
  50. "Connection": "keep-alive",
  51. "Host": "www.vikacg.com",
  52. "Referer": "https://www.vikacg.com",
  53. "Sec-Fetch-Dest": "document",
  54. "Sec-Fetch-Mode": "navigate",
  55. "Sec-Fetch-Site": "same-origin",
  56. "Sec-Fetch-User": "?1",
  57. "Upgrade-Insecure-Requests": "1",
  58. "User-Agent":
  59. "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36",
  60. },
  61. //"cookie": document.cookie,
  62. "onload": function (result) {
  63. console.log("签到成功,请刷新查看积分是否有变动");
  64. },
  65. });
  66. }