Last active
March 9, 2024 03:21
-
-
Save dung691/d780a6e6d0e316c3d693f32cc94d8c4d to your computer and use it in GitHub Desktop.
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 Youtube A+D forward back speed | |
// @namespace http://tampermonkey.net/ | |
// @license Unlicense | |
// @version 2024-03-05 | |
// @description Youtube A+D forward back speed | |
// @author dung691 | |
// @match https://www.youtube.com/* | |
// @grant none | |
// @updateURL https://gist.githubusercontent.com/dung691/d780a6e6d0e316c3d693f32cc94d8c4d/raw/yt.ad.forward-backward.user.js | |
// @downloadURL https://gist.githubusercontent.com/dung691/d780a6e6d0e316c3d693f32cc94d8c4d/raw/yt.ad.forward-backward.user.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
document.addEventListener('keydown', function (event) { | |
if (!isWatchPage() && !isShortsPage()) return; | |
var video = document.querySelector('video.html5-main-video'); | |
if (!video) return; | |
if (event.code === 'KeyA') { | |
video.currentTime -= 5;//Math.floor(videoElement.duration * 0.05); | |
} else if (event.code === 'KeyD') { | |
video.currentTime += 5;//Math.floor(videoElement.duration * 0.05); | |
} | |
}); | |
function isWatchPage() { | |
return /^\/watch/.test(location.pathname); | |
} | |
function isShortsPage() { | |
return /^\/shorts/.test(location.pathname); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment