Plex Skipper

在 Plex Web 实现自动跳过片头、片尾和自动播放下一集。

目前为 2023-09-04 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Plex Skipper
  3. // @namespace https://github.com/x1ao4/plex-skipper
  4. // @version 1.0
  5. // @description Automatically skip intros, credits, and autoplay the next episode on Plex Web.
  6. // @description:zh-CN 在 Plex Web 实现自动跳过片头、片尾和自动播放下一集。
  7. // @description:zh-HK 在 Plex Web 實現自動跳過片頭、片尾和自動播放下一集。
  8. // @description:zh-TW 在 Plex Web 實現自動跳過片頭、片尾和自動播放下一集。
  9. // @author x1ao4
  10. // @match https://app.plex.tv/*
  11. // @match http://localhost:32400/*
  12. // @match http://127.0.0.1:32400/*
  13. // @license MIT
  14. // @grant none
  15. // ==/UserScript==
  16.  
  17. (function() {
  18. 'use strict';
  19.  
  20. // Set the interval for checking the buttons and the "play next" element
  21. const interval = 1000;
  22.  
  23. // Set the selectors for the buttons
  24. const skipIntroSelector = 'button.AudioVideoFullPlayer-overlayButton-D2xSex';
  25. const skipOutroSelector = 'button.AudioVideoFullPlayer-overlayButton-D2xSex';
  26.  
  27. // Function to click a button if it exists
  28. function clickButton(selector) {
  29. const buttons = document.querySelectorAll(selector);
  30. for (const button of buttons) {
  31. button.click();
  32. break;
  33. }
  34. }
  35.  
  36. // Function to check if an element exists
  37. function elementExists(selector) {
  38. return document.querySelector(selector) !== null;
  39. }
  40.  
  41. // Set an interval to check for the buttons and the "play next" element, and click them or press space if they exist
  42. setInterval(() => {
  43. clickButton(skipIntroSelector);
  44. clickButton(skipOutroSelector);
  45. if (elementExists('label[for="autoPlayCheck"]')) {
  46. document.dispatchEvent(new KeyboardEvent('keydown', {key: ' ', keyCode: 32}));
  47. }
  48. }, interval);
  49. })();