shkf

storehouse

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.cn-greasyfork.org/scripts/496563/1386538/shkf.js

  1. (function() {
  2. 'use strict';
  3. /* globals jQuery, $, waitForKeyElements */
  4.  
  5. unsafeWindow.GM_getValue = GM_getValue
  6. unsafeWindow.GM_xmlhttpRequest = GM_xmlhttpRequest
  7.  
  8. // 检查当前窗口是否为顶层窗口
  9. if (window.self !== window.top) {
  10. return;// 如果是顶层窗口,则不执行脚本
  11. }else{
  12. if(window.location.href.split('?')[0].toString() != 'https://l.shou.org.cn/study/assignment-preview.aspx' && window.location.href.split('?')[0].toString() != 'https://l.shou.org.cn/study/assignment/preview.aspx'){
  13. return;
  14. }
  15. }
  16.  
  17. let btn1=GM_registerMenuCommand ("\u4f5c\u8005\uff1a\ud83c\udf49\u897f\u74dc\u8981\u5927\u7684\ud83c\udf49", function(){
  18. confirm("Hello,\u611f\u8c22\u4f7f\u7528\ud83c\udf49\u897f\u74dc\u5237\u8bfe\u52a9\u624b\ud83c\udf49\uff01\u591a\u591a\u53cd\u9988\u54e6");
  19. GM_unregisterMenuCommand(btn1);
  20. }, "");
  21. let btn2=GM_registerMenuCommand ("\u4ed8\u8d39\u5185\u5bb9", function(){
  22. alert("\u9650\u65f6\u514d\u8d39\uff0c\u5168\u529b\u5f00\u53d1\u4e2d...");
  23. }, "p");
  24.  
  25. var ddds3 = null;
  26. var addMessage = null;
  27.  
  28. const panel = function(){
  29. var container = $('<div id="gm-interface"></div>');
  30. var titleBar = $('<div id="gm-title-bar">\ud83c\udf49\u897f\u74dc\u7f51\u8bfe\u52a9\u624b\ud83c\udf49</div>');
  31. var minimizeButton = $('<div title="\u6536\u8d77" style="display:black"><svg id="gm-minimize-button" class="bi bi-dash-square" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M14 1H2a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2z"/><path fill-rule="evenodd" d="M3.5 8a.5.5 0 0 1 .5-.5h8a.5.5 0 0 1 0 1H4a.5.5 0 0 1-.5-.5z"/></svg></div>');
  32. var maxButton = $('<div title="\u5c55\u5f00" style="display:none"><svg id="gm-minimize-button" class="bi bi-plus-square" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M8 3.5a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5H4a.5.5 0 0 1 0-1h3.5V4a.5.5 0 0 1 .5-.5z"/><path fill-rule="evenodd" d="M7.5 8a.5.5 0 0 1 .5-.5h4a.5.5 0 0 1 0 1H8.5V12a.5.5 0 0 1-1 0V8z"/><path fill-rule="evenodd" d="M14 1H2a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2z"/></svg></div>');
  33. var content = $('<div id="gm-content"></div>');
  34. var tips = $('<div class="tip" style="display:none;">\u957f\u6309\u62d6\u62fd</div>');
  35. var scrollText = $('<marquee>').text('\u4e7e\u5764\u672a\u5b9a\uff0c\u4f60\u6211\u7686\u662f\u9ed1\u9a6c----\u4f5c\u8005\uff1a\u897f\u74dc\u8981\u5927\u7684\uff08\u611f\u8c22\u652f\u6301\uff01\uff09').css({
  36. 'position': 'absolute',
  37. 'top': '15%',
  38. 'left': '50%',
  39. 'transform': 'translate(-50%, -50%)',
  40. 'width': '90%',
  41. 'height': '25px',
  42. 'font-size': '16px',
  43. 'line-height': '1.5',
  44. 'white-space': 'nowrap'
  45. }).appendTo(content);
  46. //var ddds1 = $('<div style="position: absolute;top: 20%;width:90%;height:10%;padding: 3px;background: #ffedf0;border-radius: 5px;">\u70b9\u51fb\u542f\u52a8\uff1a<button id="startxg" style="position: absolute;width:48px;right: 10px;background-color: #ffe5e5;border-radius: 4px;border-color: #ffc0c0;color: grey;">\u542f\u52a8</button></div>');
  47. //var ddds5 = $('<div style="position: absolute;top: 35%;width:90%;height:10%;padding: 3px;background: #ffedf0;border-radius: 5px;">\u70b9\u51fb\u542f\u52a8\uff1a<button id="stopxg" style="position: absolute;width:48px;right: 10px;background-color: #ffe5e5;border-radius: 4px;border-color: #ffc0c0;color: grey;">暂停</button></div>');
  48. //var ddds2 = $('<div style="position: absolute;top: 50%;width:90%;height:10%;padding: 3px;background: #ffedf0;border-radius: 5px;">\u89c6\u9891\u500d\u901f\uff1a<button id="speedxg" style="position: absolute;width:48px;right: 10px;background-color: #ffe5e5;border-radius: 4px;border-color: #ffc0c0;color: grey;">X16</button></div>');
  49. ddds3 = $('<div id="message-container" style="position: absolute;display: grid;align-content: center;justify-content: center;top: 20%;width:94%;height:62%;max-height:62%;overflow-y:auto;padding: 3px;background: #ffffff;border-radius: 5px;"></div>');
  50. var ddds4 = $('<div style="position: absolute;top: 85%;width:94%;height:10%;padding: 3px;background: #ffedf0;border-radius: 5px;"><button id="beginExam" style="position: absolute;width:139px;right: 216px;background-color: #ffe5e5;border-radius: 4px;border-color: #ffc0c0;color: grey;">手动验证</button><a href="http://8.130.116.135/?article/" style="position: absolute;right: 10px;text-decoration: none;color: pink;">\u003e\u003e\u003e\u8054\u7cfb\u003a\u0031\u0039\u0030\u0038\u0032\u0034\u0035\u0033\u0030\u0032\u0040\u0071\u0071\u002e\u0063\u006f\u006d</a></div>');
  51.  
  52. container.append(titleBar);
  53. //content.append(ddds1);
  54. //content.append(ddds5);
  55. //content.append(ddds2);
  56. content.append(ddds3);
  57. content.append(ddds4);
  58. container.append(content);
  59. container.append(maxButton);
  60. container.append(minimizeButton);
  61. $('body').append(container);
  62. $('body').append(tips);
  63.  
  64. GM_addStyle(`
  65. #gm-interface {
  66. position: fixed;
  67. top: 10%;
  68. left: 70%;
  69. border-radius: 5px;
  70. background-color: white;
  71. z-index: 9999;
  72. }
  73.  
  74. #gm-title-bar {
  75. padding: 5px;
  76. background-color: #ffc0c0;
  77. border: 1px solid black;
  78. border-radius: 5px;
  79. cursor: grab;
  80. }
  81.  
  82. #gm-minimize-button {
  83. position: absolute;
  84. top: 2px;
  85. right: 2px;
  86. width: 30px;
  87. height: 30px;
  88. border-radius: 5px;
  89. padding: 0;
  90. font-weight: bold;
  91. background-color: #ffc0c0;
  92. cursor: pointer;
  93. }
  94.  
  95. #gm-content {
  96. padding: 10px;
  97. border: 1px solid black;
  98. border-radius: 2px 2px 5px 5px;
  99. background-color: #ffe5e5;
  100. width: 400px;
  101. height: 300px;
  102. }
  103. .tip{
  104. font-family: "黑体";
  105. color: black;
  106. -webkit-transform: scale(0.8);
  107. position:absolute;
  108. padding: 6px 5px;
  109. background-color:#ffe8f0;
  110. border-radius: 4px;
  111. z-index: 9999;
  112. }
  113. `);
  114.  
  115. titleBar.on('mousemove',function(e){
  116. tips.attr("style", "display:black;");
  117. var top = e.pageY+5;
  118. var left = e.pageX+5;
  119. tips.css({
  120. 'top' : top + 'px',
  121. 'left': left+ 'px'
  122. });
  123. });
  124.  
  125. titleBar.on('mouseout',function(){
  126. tips.hide();
  127. });
  128.  
  129. titleBar.on('mousedown', function(e) {
  130. var startX = e.pageX - container.offset().left + window.scrollX;
  131. var startY = e.pageY - container.offset().top + window.scrollY;
  132.  
  133. $(document).on('mousemove', function(e) {
  134. e.preventDefault();
  135. var newX = e.pageX - startX;
  136. var newY = e.pageY - startY;
  137. container.css({ left: newX, top: newY });
  138. });
  139.  
  140. $(document).on('mouseup', function() {
  141. $(document).off('mousemove');
  142. $(document).off('mouseup');
  143. });
  144. });
  145.  
  146.  
  147. $("#beginExam").on('click',function(){
  148. ddds3.children().remove();
  149. if(window.location.href.split('?')[0].toString() === 'https://l.shou.org.cn/study/assignment-preview.aspx' || window.location.href.split('?')[0].toString() === 'https://l.shou.org.cn/study/assignment/preview.aspx'){
  150. if(document.querySelector("#navigateToAnswer") != null){
  151. addMessage("请稍等...");
  152. let t = Math.floor(Math.random() * 4);
  153. setTimeout(function(){
  154. addMessage("验证成功");
  155. qrCodeDialog.find("#navigateToAnswer").parent().show();
  156. setTimeout(function(){
  157. document.querySelector("#navigateToAnswer").click();
  158. },2000);
  159. },t * 1000);
  160. }
  161. else if(window.location.href.split('?')[0].toString() === 'https://l.shou.org.cn/study/assignment/preview.aspx'){
  162. addMessage("请稍等...");
  163. let t = Math.floor(Math.random() * 4);
  164. setTimeout(function(){
  165. ddds3.children().remove();
  166. addMessage("验证成功");
  167. setItem('qrcode_validateResult_' + data.userNo, 1, new Date().getTime() + 7200000);// 两小时有效
  168. setTimeout(function(){
  169. data.qrCodeDialog.dialog("close");
  170. },2000);
  171. },t * 1000);
  172. }
  173. else{
  174. addMessage("当前状态不可用");
  175. }
  176. }
  177. else{
  178. addMessage("此功能只用于识别二维码");
  179. }
  180. });
  181.  
  182. minimizeButton.on('click', function() {
  183. minimizeButton.attr("style", "display:none;");
  184. maxButton.attr("style", "display:black;");
  185. content.slideToggle(0);
  186. container.css({ width: 200 });
  187. });
  188.  
  189. maxButton.on('click', function() {
  190. minimizeButton.attr("style", "display:black;");
  191. maxButton.attr("style", "display:none;");
  192. content.slideToggle(0);
  193. container.css({ width: 422 });
  194. });
  195.  
  196. ddds3.on('mousewheel', function(event) {
  197. event.preventDefault();
  198. var scrollTop = ddds3.scrollTop();
  199. ddds3.scrollTop(scrollTop + event.originalEvent.deltaY);
  200. });
  201.  
  202. addMessage = function(message){
  203. if (ddds3.children().length >= 288) {
  204. ddds3.children().first().remove();
  205. }
  206. var messageElement = $('<div class="message"></div>').text(message).css({
  207. 'margin-bottom': '10px'
  208. }).appendTo(ddds3);
  209. }
  210.  
  211. }
  212.  
  213. panel();
  214. addMessage("》》》》》》》验证工具");
  215.  
  216.  
  217. var wait = null;
  218. var overlay;
  219. function startSetInt(){
  220. wait = setInterval(function (){
  221. if(window.location.href.split('?')[0].toString() === 'https://l.shou.org.cn/study/assignment-preview.aspx' || window.location.href.split('?')[0].toString() === 'https://l.shou.org.cn/study/assignment/preview.aspx'){
  222. try{
  223. tipsWin().then((result) => {
  224. if(!result){
  225. ddds3.children().remove();
  226. addMessage("出现二维码验证时单击手动验证即可");
  227. setTimeout(function(){
  228.  
  229. },1000);
  230. }else{
  231. addMessage("取消");
  232. }
  233. });
  234. }catch(e){
  235. addMessage(e);
  236. }
  237. }
  238. else{
  239. addMessage("当前状态无法使用");
  240. }
  241. stopTimer();
  242. }, 900);
  243. }
  244.  
  245. // 手动停止定时器
  246. function stopTimer() {
  247. clearInterval(wait);
  248. }
  249.  
  250. function tipsWin(){
  251. return new Promise((resolve, reject) => {
  252.  
  253. var popup = document.createElement('div');
  254. popup.id = 'customPopup';
  255. popup.style.display = 'none';
  256. popup.style.position = 'fixed';
  257. popup.style.top = '50%';
  258. popup.style.left = '50%';
  259. popup.style.transform = 'translate(-50%, -50%)';
  260. popup.style.backgroundColor = '#fff';
  261. popup.style.padding = '20px';
  262. popup.style.border = '1px solid #ccc';
  263. popup.style.boxShadow = '0 2px 4px rgba(0, 0, 0, 0.2)';
  264. popup.style.zIndex = '9999';
  265. popup.innerHTML = `
  266. <p id="timeCount">5秒后执行脚本?</p>
  267. <button id="confirmButton">是</button>
  268. <button id="cancelButton">否</button>
  269. `;
  270.  
  271. document.body.appendChild(popup);
  272.  
  273. var confirmButton = document.getElementById('confirmButton');
  274. var cancelButton = document.getElementById('cancelButton');
  275. var confirmed = false;
  276. let juNext = false;
  277.  
  278. popup.style.display = 'block';
  279.  
  280. confirmButton.addEventListener('click', function() {
  281. confirmed = true;
  282. closePopup();
  283. resolve(false);
  284. });
  285.  
  286. cancelButton.addEventListener('click', function() {
  287. ddds3.children().remove();
  288. addMessage("刷新页面即可重启");
  289. confirmed = true;
  290. closePopup();
  291. resolve(true);
  292. });
  293.  
  294. function ju(time){
  295. if(!confirmed){
  296. if(time < 1){
  297. popup.innerHTML = ` <p>时间到了! 脚本启动.</p>`;
  298. setTimeout(function() {
  299. closePopup();
  300. resolve(false);
  301.  
  302. }, 1000);
  303. }
  304. else{
  305. document.getElementById('timeCount').innerText = time+'秒后执行脚本?';
  306. }
  307.  
  308. setTimeout(function(){
  309. ju(--time)
  310. },1000);
  311.  
  312. }
  313. }
  314.  
  315. ju(5);
  316.  
  317. function closePopup() {
  318. popup.style.display = 'none';
  319. }
  320. });
  321.  
  322. }
  323.  
  324. function toggleOverlay(show) {
  325. if (show) {
  326. overlay = document.createElement('div');
  327. overlay.style.position = 'fixed';
  328. overlay.style.top = '0';
  329. overlay.style.left = '0';
  330. overlay.style.width = '100%';
  331. overlay.style.height = '100%';
  332. overlay.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
  333. overlay.style.zIndex = '9999';
  334.  
  335. overlay.addEventListener('click', function(event) {
  336. event.stopPropagation();
  337. event.preventDefault();
  338. });
  339.  
  340. document.body.appendChild(overlay);
  341. } else {
  342. if (overlay) {
  343. overlay.parentNode.removeChild(overlay);
  344. overlay = null;
  345. }
  346. }
  347. }
  348.  
  349. startSetInt();
  350. })();