Xiaohongshu Assistant

小红书助手:自动取消视频静音

  1. // ==UserScript==
  2. // @name Xiaohongshu Assistant
  3. // @namespace https://www.xiaohongshu.com/
  4. // @version 0.1.0
  5. // @description 小红书助手:自动取消视频静音
  6. // @author muggledy
  7. // @match https://www.xiaohongshu.com/*
  8. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @grant none
  10. // @license MIT
  11. // @run-at document-start
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. var video_obj = null;
  18. var playButton = null;
  19. var muteButton = null;
  20. // 定义定时器
  21. const checkMuteButton = setInterval(() => {
  22. // 尝试获取 muteButton 元素
  23. //video_obj = document.getElementsByTagName('video')[0];
  24. playButton = document.querySelector('.xgplayer-icon-play');
  25. muteButton = document.querySelector('.xgplayer-icon-muted');
  26.  
  27. // 如果 muteButton 存在,则停止定时器并继续后续操作
  28. if (/*video_obj && */muteButton && playButton) {
  29. //console.log('Video obj found:', video_obj);
  30. console.log('Play button found:', playButton);
  31. console.log('Mute button found:', muteButton);
  32. clearInterval(checkMuteButton); // 停止定时器
  33.  
  34. setTimeout(() => {
  35. if (playButton) {
  36. console.log('click play button');
  37. playButton.click();
  38. setTimeout(() => {
  39. if (muteButton) {
  40. console.log('click mute button');
  41. muteButton.click();
  42. }
  43. }, 1000);
  44. }
  45. }, 3000);
  46.  
  47. }
  48. }, 100); // 每 100 毫秒检查一次,直到元素被找到
  49.  
  50. // Your code here...
  51. })();

QingJ © 2025

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