Skip to content

Instantly share code, notes, and snippets.

@Juribiyan
Last active June 14, 2025 10:01
Show Gist options
  • Select an option

  • Save Juribiyan/e205d7d50df6043fbb61fefa17cc4190 to your computer and use it in GitHub Desktop.

Select an option

Save Juribiyan/e205d7d50df6043fbb61fefa17cc4190 to your computer and use it in GitHub Desktop.
Youtube Fixed Shortcuts
// ==UserScript==
// @name Youtube Fixed Shortcuts
// @namespace http://tampermonkey.net/
// @version 0.2.1
// @description Fix the arrow keys function on Youtube
// @author Ubhelbr
// @match https://www.youtube.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @run-at document-idle
// @grant none
// ==/UserScript==
'use strict';
const targetSelectors = ['.ytp-progress-bar', '.ytp-volume-panel'];
const processedElements = new WeakSet();
const observer = new MutationObserver(mutationList => {
for (const mutation of mutationsList) {
if (mutation.type === 'childList') {
mutation.addedNodes.forEach(node => {
if (node.nodeType !== Node.ELEMENT_NODE) return;
if (targetSelectors.some(selector => node.matches(selector))) {
handleNewElement(node)
}
for (const selector of targetSelectors) {
const elements = node.querySelectorAll(selector)
elements.forEach(handleNewElement)
}
})
}
}
})
function handleNewElement(el) {
if (processedElements.has(el)) return;
processedElements.add(el)
el.removeAttribute('tabindex')
}
function main() {
console.log(processedElements)
targetSelectors.forEach(selector => document.querySelectorAll(selector).forEach(handleNewElement))
observer.observe(document.body, { childList: true, subtree: true })
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment