Netflix adjust playback rate using [ , ]

You can now adjust playback rate of Netflix using [ , ] on keyboard

  1. // ==UserScript==
  2. // @name Netflix adjust playback rate using [ , ]
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description You can now adjust playback rate of Netflix using [ , ] on keyboard
  6. // @author You
  7. // @match https://www.netflix.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=simply-how.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15.  
  16. // Your code here...
  17. (function () {
  18. var pushState = history.pushState;
  19. var replaceState = history.replaceState;
  20.  
  21. history.pushState = function () {
  22. pushState.apply(history, arguments);
  23. window.dispatchEvent(new Event('pushstate'));
  24. window.dispatchEvent(new Event('locationchange'));
  25. };
  26.  
  27. history.replaceState = function () {
  28. replaceState.apply(history, arguments);
  29. window.dispatchEvent(new Event('replacestate'));
  30. window.dispatchEvent(new Event('locationchange'));
  31. };
  32.  
  33. window.addEventListener('popstate', function () {
  34. window.dispatchEvent(new Event('locationchange'))
  35. });
  36. })();
  37.  
  38.  
  39. // Usage example:
  40. const PATH_NAME = "watch"
  41. const INTERVAL_TIME_LIMIT = 20; // in seconds
  42. window.addEventListener('locationchange', function () {
  43. console.log('onlocationchange event occurred!');
  44. if(window.location.pathname.includes(PATH_NAME)){
  45. initFunctionality()
  46. }
  47. })
  48.  
  49. if(window.location.pathname.includes(PATH_NAME)){
  50. initFunctionality()
  51. }
  52.  
  53. function initFunctionality(){
  54. let secondsOver = 0
  55. const myInterval = setInterval(() => {
  56. secondsOver++;
  57. const els = document.getElementsByTagName('video')
  58. if (secondsOver >= INTERVAL_TIME_LIMIT) {
  59. console.log(`More than ${INTERVAL_TIME_LIMIT} seconds over`);
  60. stopColor()
  61. return
  62. }
  63. if (els.length == 0) {
  64. console.log("Video tag not found");
  65. return
  66. }
  67. const video = els[0]
  68. video.style["background"] = '#000000';
  69. console.log("Updated background color to black");
  70.  
  71. const body = document.getElementsByTagName('body')
  72. const element = body[0]
  73.  
  74. function speedChangedMessageDiplay(type, time) {
  75. let block_to_insert = document.createElement('div');
  76. const DIV_ID = 'speed-change-div';
  77. block_to_insert.innerHTML = `Speed ${type} to ${video.playbackRate}`;
  78. block_to_insert.id = DIV_ID;
  79. block_to_insert.style.color = '#ffffff';
  80. block_to_insert.style.position = 'absolute';
  81. block_to_insert.style["z-index"] = 100;
  82. block_to_insert.style.top = '0px';
  83. block_to_insert.style.fontSize = '15px';
  84.  
  85. const videoPlayerWrapper = video.parentElement;
  86. videoPlayerWrapper.appendChild(block_to_insert);
  87.  
  88. setTimeout(() => {
  89. const divEl = document.getElementById(DIV_ID);
  90. divEl.remove()
  91. }, time)
  92. }
  93.  
  94. element.onkeyup = (event) => {
  95. if (event.key == ']') {
  96. video.playbackRate += 0.25
  97. speedChangedMessageDiplay('increased', 500)
  98. }
  99. else if (event.key == '[') {
  100. video.playbackRate -= 0.25
  101. speedChangedMessageDiplay('decreased', 500)
  102. }
  103. }
  104. stopColor()
  105. }, 1000);
  106. function stopColor() {
  107. clearInterval(myInterval);
  108. }
  109. }
  110.  
  111.  
  112.  
  113. })();

QingJ © 2025

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