Twitch Auto Theatre

auto click theatre mode button

目前为 2021-09-05 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Twitch Auto Theatre
  3. // @name:zh-TW Twitch 自動劇院模式
  4. // @namespace http://tampermonkey.net/
  5. // @version 0.6
  6. // @description auto click theatre mode button
  7. // @description:zh-tw 進入頁面自動啟動劇院模式
  8. // @author Long
  9. // @match https://www.twitch.tv/*
  10. // @icon https://www.google.com/s2/favicons?domain=twitch.tv
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. "use strict";
  16.  
  17. // method 1
  18. // window.onload = function() {
  19. // var twitchAutoTheatreIntervalRetry = 100;
  20. // var twitchAutoTheatreInterval = setInterval(function () {
  21. // let $theatreModeButton = document.querySelector('[data-a-target="player-theatre-mode-button"]');
  22. // // console.log($theatreModeButton);
  23. // if ($theatreModeButton) {
  24. // $theatreModeButton.click();
  25. // clearInterval(twitchAutoTheatreInterval);
  26. // console.log("[Twitch-Auto-Theatre] theatre-mode-button clicked.");
  27. // } else if (!twitchAutoTheatreIntervalRetry) {
  28. // clearInterval(twitchAutoTheatreInterval);
  29. // console.warn("[Twitch-Auto-Theatre] theatre-mode-button not found.");
  30. // }
  31. // twitchAutoTheatreIntervalRetry--;
  32. // }, 500);
  33. // };
  34.  
  35. // method 2
  36. let observer = new MutationObserver(mutations => {
  37. for(let mutation of mutations) {
  38. let node = mutation.target;
  39. if (node.matches('.player-controls__right-control-group')) {
  40. observer.disconnect();
  41. let $theatreModeButton = document.querySelector('[data-a-target="player-theatre-mode-button"]');
  42. if ($theatreModeButton) {
  43. $theatreModeButton.click();
  44. console.log("[Twitch-Auto-Theatre] theatre-mode-button clicked.");
  45. } else {
  46. console.warn("[Twitch-Auto-Theatre] control-group found. but button not found.")
  47. }
  48. }
  49. }
  50. });
  51. observer.observe(document.getElementById('root'), {
  52. childList: true,
  53. subtree: true,
  54. });
  55. })();

QingJ © 2025

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