Skip to content

Instantly share code, notes, and snippets.

@prashantbaid
Created March 9, 2024 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prashantbaid/314139311b151964f81bceb2c48fec50 to your computer and use it in GitHub Desktop.
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
// ==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