Skip to content

Instantly share code, notes, and snippets.

@leyuskckiran1510
Last active May 24, 2024 14:51
Show Gist options
  • Select an option

  • Save leyuskckiran1510/30f2d1a70c8d4f275c56699da5ae7a8d to your computer and use it in GitHub Desktop.

Select an option

Save leyuskckiran1510/30f2d1a70c8d4f275c56699da5ae7a8d to your computer and use it in GitHub Desktop.
  1. Download tampermonkey in you brower
  2. now click on tamper monkey icon
  3. and select create new script
  4. and when a code editor opens up paste the code
// ==UserScript==
// @name Video Speeder
// @namespace randomnamespaceforusers
// @version 2024-05-22
// @description control video playback in any site
// @author leyuskc
// @match *://*/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant none
// ==/UserScript==
(function() {
'use strict';
let key_pressed = (key)=>{
if (key=="S"){
document.querySelectorAll("video").forEach(x => {if (!x.paused) {x.playbackRate += 0.25}})
};
if (key=="A"){
document.querySelectorAll("video").forEach(x => {if (!x.paused) {x.playbackRate -= 0.25}})
};
if (key=="Z"){
document.querySelectorAll("video").forEach(x => {if (!x.paused) {x.currentTime-=5}})
};
if (key=="C"){
document.querySelectorAll("video").forEach(x => {if (!x.paused) {x.currentTime+=5}})
};
if (key=="Q"){
document.querySelectorAll("video").forEach(x => {if (!x.paused) {x.pause()}else{x.play();}})
};
if (key=="D"){
document.querySelectorAll("video").forEach(x => {x.muted=!x.muted})
};
};
document.addEventListener('keyup', function(event) {
if ('input' === document.activeElement.tagName.toLowerCase()) {
return;
}
key_pressed(event.key);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment