sosovalue_execute.user.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 GroupSelectors = [
  13. "#\\:rf\\: > span.transition-opacity.font-medium",
  14. "#\\:rh\\: > span.transition-opacity.font-medium",
  15. "#\\:ri\\: > span.transition-opacity.font-medium",
  16. "#\\:rj\\: > span.transition-opacity.font-medium",
  17. "#\\:rk\\: > span.transition-opacity.font-medium",
  18. "#\\:rg\\: > span.transition-opacity.font-medium",
  19. ];
  20. let newWindow = null;
  21. const originalOpen = window.open;
  22. window.open = function (url, name, features) {
  23. newWindow = originalOpen(url, name, features);
  24. return newWindow;
  25. };
  26. function clickButtonGroup(group, delay, closeWindow = false, callback) {
  27. let completed = 0;
  28. group.forEach((selector, index) => {
  29. setTimeout(() => {
  30. const button = document.querySelector(selector);
  31. if (button) {
  32. button.click();
  33. if (closeWindow && newWindow) {
  34. newWindow.close();
  35. }
  36. }
  37. completed++;
  38. if (completed === group.length && callback) {
  39. callback();
  40. }
  41. }, index * delay);
  42. });
  43. }
  44. function createCustomButtons() {
  45. const button = document.createElement("button");
  46. button.textContent = "执行";
  47. button.style.position = "fixed";
  48. button.style.top = "10%";
  49. button.style.left = "2%";
  50. button.style.transform = "translateY(-50%)";
  51. button.style.padding = "3px 8px";
  52. button.style.fontSize = "10px";
  53. button.style.backgroundColor = "#007baf";
  54. button.style.color = "#fff";
  55. button.style.border = "none";
  56. button.style.borderRadius = "5px";
  57. button.style.cursor = "pointer";
  58. button.style.zIndex = "10000";
  59. button.addEventListener("click", () => {
  60. clickButtonGroup(GroupSelectors, 1000, true, () => {
  61. // 所有按钮点击完成后,等待1秒刷新页面
  62. setTimeout(() => {
  63. location.reload();
  64. }, 1000);
  65. });
  66. });
  67. document.body.appendChild(button);
  68. }
  69. window.addEventListener("load", createCustomButtons);
  70. setInterval(() => {
  71. if (newWindow && !newWindow.closed) {
  72. newWindow.close();
  73. }
  74. }, 1000);
  75. })();