直播弹窗

在抖音中控台实现弹窗操作

  1. // ==UserScript==
  2. // @name 直播弹窗
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description 在抖音中控台实现弹窗操作
  6. // @author 叶思年
  7. // @match https://buyin.jinritemai.com/*
  8. // @grant none
  9. // @license GPL-3.0
  10. // ==/UserScript==
  11.  
  12. /*
  13. GNU GENERAL PUBLIC LICENSE
  14. Version 3, 29 June 2007
  15.  
  16. Copyright © 2024 叶思年
  17.  
  18. Everyone is permitted to copy and distribute verbatim copies
  19. of this license document, but changing it is not allowed.
  20.  
  21. This program is free software: you can redistribute it and/or modify
  22. it under the terms of the GNU General Public License as published by
  23. the Free Software Foundation, either version 3 of the License, or
  24. (at your option) any later version.
  25.  
  26. This program is distributed in the hope that it will be useful,
  27. but WITHOUT ANY WARRANTY; without even the implied warranty of
  28. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  29. GNU General Public License for more details.
  30.  
  31. You should have received a copy of the GNU General Public License
  32. along with this program. If not, see <https://www.gnu.org/licenses/>.
  33. */
  34.  
  35. (function () {
  36. 'use strict';
  37.  
  38. // 创建交互界面的容器
  39. const uiContainer = document.createElement('div');
  40. uiContainer.style.position = 'fixed';
  41. uiContainer.style.top = '515px';
  42. uiContainer.style.right = '8px';
  43. uiContainer.style.zIndex = '9999'; // 提升 z-index
  44. uiContainer.style.backgroundColor = '#fff';
  45. uiContainer.style.border = '3px solid #007bff';
  46. uiContainer.style.padding = '8px';
  47. uiContainer.style.boxShadow = '0 2px 5px rgba(0,0,0,0.2)';
  48. uiContainer.style.borderRadius = '6px';
  49. uiContainer.style.width = '55px';
  50. uiContainer.style.height = 'auto';
  51. uiContainer.style.display = 'flex'; // 确保是可见
  52. uiContainer.style.flexDirection = 'column';
  53. uiContainer.style.alignItems = 'center';
  54.  
  55. // 创建状态提示
  56. const statusMessage = document.createElement('div');
  57. statusMessage.style.marginBottom = '6px';
  58. statusMessage.style.fontSize = '14px';
  59. statusMessage.style.textAlign = 'center';
  60. statusMessage.textContent = '点击开始';
  61. uiContainer.appendChild(statusMessage);
  62.  
  63. // 创建按钮函数
  64. function createButton(text, bgColor, disabled = false) {
  65. const button = document.createElement('button');
  66. button.textContent = text;
  67. button.style.display = 'block';
  68. button.style.margin = '0 auto 2px';
  69. button.style.padding = '5px';
  70. button.style.backgroundColor = bgColor;
  71. button.style.color = 'white';
  72. button.style.border = 'none';
  73. button.style.borderRadius = '4px';
  74. button.style.cursor = 'pointer';
  75. button.style.fontSize = '14px';
  76. button.style.width = '35px';
  77. button.disabled = disabled;
  78. return button;
  79. }
  80.  
  81. const startButton = createButton('开始', '#28a745');
  82. const stopButton = createButton('停止', '#dc3545', true);
  83. const helpButton = createButton('帮助', '#007bff');
  84.  
  85. uiContainer.appendChild(startButton);
  86. uiContainer.appendChild(stopButton);
  87. uiContainer.appendChild(helpButton);
  88. document.body.appendChild(uiContainer);
  89.  
  90. let clickInterval;
  91.  
  92. // 点击按钮的函数
  93. function performClick() {
  94. const button = document.querySelector('.lvc2-grey-btn.active, .lvc2-grey-btn:hover');
  95. if (button) {
  96. button.click();
  97. console.log('Button clicked!');
  98. setTimeout(() => {
  99. button.click();
  100. console.log('Button clicked again!');
  101. }, 500);
  102. } else {
  103. console.log('Button not found.');
  104. // 这里可以添加一些条件,避免频繁停止
  105. if (clickInterval) {
  106. clearInterval(clickInterval);
  107. startButton.textContent = '重启';
  108. startButton.disabled = false;
  109. stopButton.disabled = true;
  110. statusMessage.textContent = '意外暂停';
  111. uiContainer.style.borderColor = 'red';
  112. uiContainer.style.boxShadow = '0 2px 5px rgba(255,0,0,0.5)';
  113. }
  114. }
  115. }
  116.  
  117. // 开始点击操作的事件监听器
  118. startButton.addEventListener('click', function () {
  119. // 清除之前的点击间隔
  120. clearInterval(clickInterval);
  121. statusMessage.textContent = '正在弹窗';
  122. startButton.disabled = true;
  123. stopButton.disabled = false;
  124. uiContainer.style.borderColor = 'green';
  125. uiContainer.style.boxShadow = '0 2px 5px rgba(0,255,0,0.5)';
  126. performClick();
  127. clickInterval = setInterval(performClick, 10000);
  128. });
  129.  
  130. // 停止点击操作的事件监听器
  131. stopButton.addEventListener('click', function () {
  132. clearInterval(clickInterval);
  133. startButton.textContent = '开始';
  134. startButton.disabled = false;
  135. stopButton.disabled = true;
  136. statusMessage.textContent = '操作已停止。';
  137. uiContainer.style.borderColor = '#007bff';
  138. uiContainer.style.boxShadow = '0 2px 5px rgba(0,0,0,0.2)';
  139. });
  140.  
  141. // 帮助按钮事件监听器
  142. helpButton.addEventListener('click', function () {
  143. alert('帮助信息:\n 1、本脚本为提升商品曝光促进转化所用,使用前请先阅读本篇帮助来助于您对本脚本的了解。\n\n 2、“点击开始”按钮前请确保已有商品正在讲解当中,这点很重要!请留意直播画面。\n\n 3、如提示“未找到要点击的按钮”,请点击重启即可。\n\n4、自动弹链接的选择方式是基于正在讲解的商品来进行弹出的,如遇到换款的情况,正常手动换款后,弹链接的选择判定也会同步更新。\n\n5、如使用脚本期间遇到问题可联系微信:wx8691wt');
  144. });
  145.  
  146. // 监听页面DOM变化
  147. const observer = new MutationObserver(() => {
  148. if (!document.body.contains(uiContainer)) {
  149. document.body.appendChild(uiContainer);
  150. }
  151. });
  152.  
  153. observer.observe(document.body, { childList: true, subtree: true });
  154. })();

QingJ © 2025

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