sosovalue_execute.user.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. // ==UserScript==
  2. // @name sosovalue 半自动点击
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.6
  5. // @description 检测并点击页面中的 5 组按钮,并关闭新弹出的页面
  6. // @author Jack
  7. // @match https://sosovalue.com/*/*
  8. // @grant none
  9. // ==/UserScript==
  10. (function() {
  11. 'use strict';
  12. const firstGroupSelectors = [
  13. '#\\:ro\\: > span.transition-opacity.font-medium',
  14. '#\\:rp\\: > span.transition-opacity.font-medium',
  15. '#\\:rq\\: > span.transition-opacity.font-medium',
  16. '#\\:rr\\: > span.transition-opacity.font-medium',
  17. '#\\:rs\\: > span.transition-opacity.font-medium',
  18. '#\\:r8\\: > span.transition-opacity.font-medium',
  19. '#\\:rh\\: > span.transition-opacity.font-medium',
  20. '#\\:rg\\: > span.transition-opacity.font-medium',
  21. '#\\:r7\\: > span.transition-opacity.font-medium',
  22. '#\\:r6\\: > span.transition-opacity.font-medium',
  23. '#\\:r10\\: > span.transition-opacity.font-medium',
  24. '#\\:ri\\: > span.transition-opacity.font-medium'
  25. ];
  26. const secondGroupSelectors = [
  27. '#\\:rf\\: > span.transition-opacity.font-medium',
  28. '#\\:rh\\: > span.transition-opacity.font-medium',
  29. '#\\:ri\\: > span.transition-opacity.font-medium',
  30. '#\\:rj\\: > span.transition-opacity.font-medium',
  31. '#\\:rk\\: > span.transition-opacity.font-medium'
  32. ];
  33. let newWindow = null;
  34. const originalOpen = window.open;
  35. window.open = function(url, name, features) {
  36. newWindow = originalOpen(url, name, features);
  37. return newWindow;
  38. };
  39. function clickButtonGroup(group, delay, closeWindow = false, callback) {
  40. let completed = 0;
  41. group.forEach((selector, index) => {
  42. setTimeout(() => {
  43. const button = document.querySelector(selector);
  44. if (button) {
  45. button.click();
  46. if (closeWindow && newWindow) {
  47. newWindow.close();
  48. }
  49. }
  50. completed++;
  51. if (completed === group.length && callback) {
  52. callback();
  53. }
  54. }, index * delay);
  55. });
  56. }
  57. function createCustomButtons() {
  58. const button1 = document.createElement('button');
  59. button1.textContent = '验证';
  60. button1.style.position = 'fixed';
  61. button1.style.top = '20px';
  62. button1.style.left = '40%';
  63. button1.style.padding = '10px 20px';
  64. button1.style.backgroundColor = '#007bff';
  65. button1.style.color = '#fff';
  66. button1.style.border = 'none';
  67. button1.style.borderRadius = '5px';
  68. button1.style.cursor = 'pointer';
  69. button1.style.zIndex = '10000';
  70. button1.addEventListener('click', () => {
  71. clickButtonGroup(firstGroupSelectors, 100, false, () => {
  72. setTimeout(() => {
  73. location.reload();
  74. }, 1000);
  75. });
  76. });
  77. const button2 = document.createElement('button');
  78. button2.textContent = '执行';
  79. button2.style.position = 'fixed';
  80. button2.style.top = '20px';
  81. button2.style.left = '60%';
  82. button2.style.padding = '10px 20px';
  83. button2.style.backgroundColor = '#007bff';
  84. button2.style.color = '#fff';
  85. button2.style.border = 'none';
  86. button2.style.borderRadius = '5px';
  87. button2.style.cursor = 'pointer';
  88. button2.style.zIndex = '10000';
  89. button2.addEventListener('click', () => {
  90. clickButtonGroup(secondGroupSelectors, 500, true, () => {
  91. setTimeout(() => {
  92. location.reload();
  93. }, 1000);
  94. });
  95. });
  96. document.body.appendChild(button1);
  97. document.body.appendChild(button2);
  98. }
  99. window.addEventListener('load', createCustomButtons);
  100. setInterval(() => {
  101. if (newWindow && !newWindow.closed) {
  102. newWindow.close();
  103. }
  104. }, 1000);
  105. })();