Steam_Zoom_Like

批量点赞Steam动态朋友圈, 原作者 Garen

  1. // ==UserScript==
  2. // @name:zh-CN Steam 动态批量点赞
  3. // @name Steam_Zoom_Like
  4. // @namespace https://blog.chrxw.com
  5. // @supportURL https://blog.chrxw.com/scripts.html
  6. // @contributionURL https://afdian.com/@chr233
  7. // @version 1.8
  8. // @description:zh-CN 批量点赞Steam动态朋友圈, 原作者 Garen
  9. // @description 批量点赞Steam动态朋友圈, 原作者 Garen
  10. // @author Garen, Chr_
  11. // @license AGPL-3.0
  12. // @icon https://blog.chrxw.com/favicon.ico
  13. // @match https://steamcommunity.com/id/*/home*
  14. // @match https://steamcommunity.com/profiles/*/home*
  15. // @grant GM_addStyle
  16. // @grant GM_registerMenuCommand
  17. // ==/UserScript==
  18.  
  19. // 原版脚本: https://greasyfork.org/zh-CN/scripts/379844
  20.  
  21. (function () {
  22. 'use strict';
  23.  
  24. // 获取添加按钮的父元素
  25. const titleArea = document.querySelector('div.blotter_page_title');
  26.  
  27. // 创新点赞按钮
  28. const btnArea = document.createElement("div");
  29. btnArea.className = "panel_szl";
  30. titleArea.appendChild(btnArea);
  31.  
  32. const chkReview = genChk("评测", "发布评测", "szl_chk_review", btnArea);
  33. const chkPurchase = genChk("购买", "购买新游戏", "szl_chk_purchase", btnArea);
  34. const chkScreenshot = genChk("截图", "上传截图", "szl_chk_image", btnArea);
  35. const chkUserstatus = genChk("状态", "用户状态", "szl_chk_userstatus", btnArea);
  36. const chkOther = genChk("其它", "艺术作品, 指南, 创意工坊, 其它", "szl_chk_other", btnArea);
  37. const btnLike = genBtn("开始点赞", "btn_szl", startLike, btnArea);
  38.  
  39. let t = 0;
  40. let autoStart = localStorage.getItem("szl_auto") === "true";
  41.  
  42. function startLike() {
  43. if (t === 0) {
  44. btnLike.textContent = "停止点赞";
  45. t = setInterval(() => {
  46. const elemets = document.querySelectorAll("div.blotter_day>div.blotter_block>div[class]:not([like])");
  47. for (let ele of elemets) {
  48. const clsName = ele.className;
  49. let a = undefined;
  50.  
  51. if (chkReview.checked && clsName === "blotter_recommendation") {
  52. a = ele.querySelector("div.control_block>a[onclick^='UserReviewVoteUp']:not(.btn_active)");
  53. } else if (
  54. (chkPurchase.checked && clsName === "blotter_gamepurchase") ||
  55. (chkScreenshot.checked && clsName === "blotter_screenshot") ||
  56. (chkUserstatus.checked && clsName === "blotter_userstatus") ||
  57. (chkOther.checked && clsName !== "blotter_gamepurchase" && clsName !== "blotter_screenshot" && clsName !== "blotter_userstatus")
  58. ) {
  59. a = ele.querySelector("div.blotter_control_container>a[id^='vote_up']:not(.active)");
  60. }
  61.  
  62. if (a) {
  63. ele.setAttribute("like", "");
  64. a.click();
  65. break;
  66. }
  67. }
  68. }, 100);
  69. } else {
  70. btnLike.textContent = "开始点赞";
  71. clearInterval(t);
  72. t = 0;
  73. }
  74. }
  75.  
  76. GM_registerMenuCommand(autoStart ? "自动开始点赞 [开]" : "自动开始点赞 [关]", () => {
  77. autoStart = !autoStart;
  78. localStorage.setItem("szl_auto", autoStart);
  79. ShowAlertDialog("提示", "设置已保存, 刷新页面后生效");
  80. if (!autoStart && t > 0) {
  81. startLike();
  82. }
  83. });
  84.  
  85. if (autoStart) {
  86. startLike();
  87. }
  88.  
  89. function genChk(name, title, key, parent) {
  90. const d = document.createElement("div");
  91. const l = document.createElement("label");
  92. const i = document.createElement("input");
  93. d.className = "container_szl";
  94. i.textContent = name;
  95. i.title = title;
  96. i.type = "checkbox";
  97. i.id = key;
  98. i.checked = localStorage.getItem(key) === "true";
  99. i.addEventListener('change', () => { localStorage.setItem(key, i.checked); });
  100. l.title = title;
  101. l.textContent = name;
  102. l.setAttribute("for", key);
  103. d.appendChild(i);
  104. d.appendChild(l);
  105. parent.appendChild(d);
  106. return i;
  107. }
  108. function genBtn(name, cls, func, parent) {
  109. const b = document.createElement("button");
  110. b.textContent = name;
  111. b.className = cls;
  112. b.addEventListener("click", func);
  113. parent.appendChild(b);
  114. return b;
  115. }
  116. })();
  117.  
  118. GM_addStyle(`
  119. div.panel_szl {
  120. float: right;
  121. margin-right: 2%;
  122. margin-top: -2%;
  123. display: inline-flex;
  124. }
  125. div.panel_szl > * {
  126. margin-left: 6px;
  127. }
  128. div.container_szl {
  129. align-items: center;
  130. display: flex;
  131. }
  132. button.btn_szl {
  133. width: 75px;
  134. border-radius: 2px;
  135. border: none;
  136. padding: 1px;
  137. display: inline-block;
  138. cursor: pointer;
  139. text-decoration: none !important;
  140. color: #fff !important;
  141. background: #acb5bd;
  142. background: -webkit-linear-gradient(top, #acb5bd 5%, #414a52 95%);
  143. background: linear-gradient(to bottom, #acb5bd 5%, #414a52 95%);
  144. }
  145. `);