Created
March 9, 2024 08:48
-
-
Save prashantbaid/314139311b151964f81bceb2c48fec50 to your computer and use it in GitHub Desktop.
Forward and rewind video playback on OTT platforms like Jiocinema with keyboard arrow keys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Video Fast Forward/Rewind with Arrow Keys | |
// @version 1 | |
// @description Use right and left arrow keys to fast forward or rewind HTML video | |
// @author pb | |
// @grant none | |
// @match https://www.jiocinema.com/* | |
// @match https://www.sonyliv.com/* | |
// @namespace | |
// @license MIT | |
// ==/UserScript== | |
(function() { | |
document.body.onkeydown = e => { | |
//do not interfere with navigating jio in-video slider | |
if (isJioSlickSlider(e)) { | |
return; | |
} | |
const videos = document.getElementsByTagName('video'); | |
console.log('videos ', videos); | |
if (videos.length > 0) { | |
const video = videos[0]; | |
const seek = time => { | |
e.stopImmediatePropagation(); | |
video.currentTime += time; | |
} | |
switch (e.key) { | |
case 'ArrowRight': | |
seek(10); | |
break; | |
case 'ArrowLeft': | |
seek(-10); | |
break; | |
default: | |
break; | |
} | |
} | |
} | |
})(); | |
const isJioSlickSlider = e => { | |
return e.target.className.toLowerCase().includes('slick-'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment