Auto_Sub3

一键快乐-3

  1. // ==UserScript==
  2. // @name:zh-CN 蒸汽轮盘自动-3
  3. // @name Auto_Sub3
  4. // @namespace https://blog.chrxw.com
  5. // @supportURL https://blog.chrxw.com/scripts.html
  6. // @contributionURL https://afdian.com/@chr233
  7. // @version 2.26
  8. // @description 一键快乐-3
  9. // @description:zh-CN 一键快乐-3
  10. // @author Chr_
  11. // @include https://keylol.com/*
  12. // @license AGPL-3.0
  13. // @icon https://blog.chrxw.com/favicon.ico
  14. // @grant GM_setValue
  15. // @grant GM_getValue
  16. // @grant GM_xmlhttpRequest
  17. // ==/UserScript==
  18.  
  19. // 版本号
  20. const Ver = '2.17';
  21. // 上次-3时间
  22. let VLast = 0;
  23. // 今天还能不能-3
  24. let VCan3 = true;
  25. // 自动展开
  26. let VShow = false;
  27. // 自动-3
  28. let VAuto = false;
  29. // 音效载入
  30. const Vsound = new Audio('https://blog.chrxw.com/usr/keylol/gas.mp3');
  31. // 轮盘链接
  32. const Vroll = 'https://keylol.com/plugin.php?id=steamcn_lottery:view&lottery_id=46';
  33. // 正则表达式
  34. const Vregex = /plugin\.php\?id=steamcn_lottery:view&lottery_id=46&hash=(.+)&roll/;
  35.  
  36. (() => {
  37. 'use strict';
  38. if (!document.querySelector('.index_left_detail')) { return; }
  39. loadCFG();
  40. addBtns();
  41. if (VShow) {
  42. switchPanel();
  43. }
  44. if (VCan3 && VAuto) {
  45. autoRoll();
  46. }
  47. })();
  48. // 添加GUI
  49. function addBtns() {
  50. function genButton(text, foo, id) {
  51. let b = document.createElement('button');
  52. b.textContent = text;
  53. b.style.cssText = 'margin: 8px 5px;';
  54. b.addEventListener('click', foo);
  55. if (id) { b.id = id; }
  56. return b;
  57. }
  58. function genDiv(cls) {
  59. let d = document.createElement('div');
  60. if (cls) { d.className = cls; };
  61. return d;
  62. }
  63. function genPanel(name, visiable) {
  64. let p = genDiv(name);
  65. p.id = name;
  66. p.style.cssText = 'width: 100%;height: 100%;';
  67. if (!visiable) { p.style.display = 'none'; }
  68. return p;
  69. }
  70. let btnSwitch = document.querySelector('.index_left_title>div');
  71.  
  72. if (btnSwitch == null) { return; }
  73.  
  74. btnSwitch.id = 'btnSwitch1';
  75. btnSwitch.title = '点这里开启/隐藏控制面板';
  76. btnSwitch.textContent = '关注重点 - Auto Sub 3';
  77. btnSwitch.style.cssText = 'width: auto;padding: 0 5px;cursor: pointer;z-index: 1';
  78. btnSwitch.addEventListener('click', switchPanel);
  79.  
  80. let panelArea = document.querySelector('.index_navi_left');
  81. let panelOri = document.querySelector('.index_left_detail');
  82. panelOri.id = 'panelOri';
  83.  
  84. let panel54 = genPanel('panel54');
  85.  
  86. let aLP = document.createElement('a');
  87. aLP.href = Vroll;
  88. aLP.title = '前往轮盘页';
  89. let img54 = document.createElement('img');
  90. img54.src = 'https://raw.chrxw.com/GM_Scripts/master/Static/keylol.png';
  91. img54.alt = '总之这里是54的名言';
  92. img54.style.cssText = 'float: right;margin-top: -28px;height: 100%;';
  93. aLP.appendChild(img54);
  94.  
  95. let btnArea = genDiv('btnArea');
  96. btnArea.style.cssText = 'width: 180px;text-align: center;margin-top: -10px;margin-left: -10px;position: absolute;';
  97.  
  98. let btnS3 = genButton('【一键-3】', autoRoll, 'btnS3');
  99.  
  100. if (!VCan3) {
  101. btnS3.style.textDecoration = 'line-through';
  102. btnS3.textContent = '今天已经不能-3了';
  103. }
  104.  
  105. let btnAuto = genButton(bool2txt(VAuto) + '自动每日-3', fBtnAuto, 'btnAuto');
  106.  
  107. btnArea.appendChild(btnS3);
  108. btnArea.appendChild(btnAuto);
  109.  
  110. panel54.appendChild(aLP);
  111. panel54.appendChild(btnArea);
  112. panelArea.insertBefore(panel54, panelArea.children[1]);
  113. }
  114. // 自动-3
  115. function fBtnAuto() {
  116. VAuto = !VAuto;
  117. document.getElementById('btnAuto').textContent = bool2txt(VAuto) + '自动每日-3';
  118. saveCFG();
  119. }
  120. // 显示布尔
  121. function bool2txt(bool) {
  122. return bool ? '【√】' : '【×】';
  123. }
  124. // 隐藏面板
  125. function switchPanel() {
  126. let btnSwitch = document.getElementById('btnSwitch1');
  127. let panel1 = document.getElementById('panel54');
  128. let panel2 = document.getElementById('panelOri');
  129. if (panel1.style.display == 'none') {
  130. btnSwitch.textContent = 'Auto Sub 3 - By Chr_ - V ' + Ver;
  131. panel1.style.display = 'block';
  132. panel2.style.display = 'none';
  133. VShow = true;
  134. } else {
  135. btnSwitch.textContent = '关注重点 - Auto Sub 3';
  136. panel1.style.display = 'none';
  137. panel2.style.display = 'block';
  138. VShow = false;
  139. }
  140. saveCFG();
  141. }
  142. // 读取设置
  143. function loadCFG() {
  144. let t = null;
  145. t = GM_getValue('VLast');
  146. t = Number(t);
  147. if (t != t) { t = 0; }
  148. VLast = t;
  149. t = GM_getValue('VCan3');
  150. VCan3 = Boolean(t);
  151. t = GM_getValue('VShow');
  152. VShow = Boolean(t);
  153. t = GM_getValue('VAuto');
  154. VAuto = Boolean(t);
  155. // 日期变更,重置VCan3
  156. let d = new Date();
  157. let day = d.getDate();
  158. let hour = d.getHours();
  159. if (day != VLast && hour >= 8) {
  160. VCan3 = true;
  161. VLast = day;
  162. }
  163. saveCFG();
  164. }
  165. // 保存设置
  166. function saveCFG() {
  167. GM_setValue('VLast', VLast);
  168. GM_setValue('VCan3', VCan3);
  169. GM_setValue('VShow', VShow);
  170. GM_setValue('VAuto', VAuto);
  171. }
  172. // 检查能否-3
  173. function checkZP() {
  174. GM_xmlhttpRequest({
  175. method: "GET",
  176. url: Vroll,
  177. onload: (response) => {
  178. if (response.responseText != null) {
  179. let t = response.responseText;
  180. let can = t.search('<button id="roll">抽奖</button>') != -1;
  181. console.log(can);
  182. if (!can) {
  183. disableS3();
  184. }
  185. saveCFG();
  186. }
  187. },
  188. onerror: (response) => {
  189. showError('【出错了,淦】');
  190. }
  191. });
  192. }
  193. // 禁止-3
  194. function disableS3() {
  195. let b = document.getElementById('btnS3');
  196. b.style.textDecoration = 'line-through';
  197. b.textContent = '今天已经不能-3了';
  198. VCan3 = false;
  199. }
  200. // 自动-3
  201. function autoRoll() {
  202. try {
  203. Vsound.play();
  204. } catch (e) {
  205. console.error(e);
  206. }
  207. // if (!VCan3) {
  208. // return;
  209. // }
  210. let v = 0;
  211. gethash();
  212.  
  213. function gethash() {
  214. GM_xmlhttpRequest({
  215. method: "GET",
  216. url: Vroll,
  217. onload: (response) => {
  218. if (response.status == 200) {
  219. let m = response.responseText.match(Vregex);
  220. let hash = m ? m[1] : null;
  221. console.log(hash);
  222. if (hash != null) {
  223. roll(hash);
  224. roll(hash);
  225. roll(hash);
  226. } else {
  227. disableS3();
  228. saveCFG();
  229. showError('【今天已经无法 -3 了哟】');
  230. }
  231. } else {
  232. showError('【出错了,淦】');
  233. }
  234. },
  235. onerror: (response) => {
  236. showError('【出错了,淦】');
  237. }
  238. });
  239. }
  240.  
  241. function roll(hash) {
  242. GM_xmlhttpRequest({
  243. method: "GET",
  244. url: Vroll + '&hash=' + hash + '&roll',
  245. onload: (response) => {
  246. if (response.status == 200) {
  247. console.log(response.responseText);
  248. } else {
  249. showError('【出错了,淦】');
  250. console.error('出错');
  251. }
  252. if (++v == 3) {
  253. disableS3();
  254. saveCFG();
  255. showError('【自动 -3 完成,祝你好运】');
  256. setTimeout(() => { window.location.reload(); }, 600);
  257.  
  258. }
  259. },
  260. onerror: (response) => {
  261. showError('【出错了,淦】');
  262. }
  263. });
  264. }
  265. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址