Files
browser-scripts/dist/twitch-clickable-video.user.js
2023-04-09 22:41:06 -05:00

28 lines
1.2 KiB
JavaScript

// ==UserScript==
// @name Twitch Clickable Video
// @namespace zomo.dev
// @match https://www.twitch.tv/*
// @version 1.1
// @description hold Control key to be able to right click the video element
// @downloadURL https://git.zomo.dev/zomo/browser-scripts/raw/branch/main/dist/twitch-clickable-video.user.js
// @supportURL https://git.zomo.dev/zomo/browser-scripts/issues
// @homepageURL https://git.zomo.dev/zomo/browser-scripts
// ==/UserScript==
var Elems = `
.video-player__overlay,
.video-player__overlay:nth-child(1) > div:nth-child(1),
.video-player__overlay:nth-child(1) > div:nth-child(1) > div:nth-child(1),
.click-handler
`
var getElems = () =>
Elems.split(',')
.filter(l => l.trim().length)
.map(elem => document.querySelector(elem.trim()))
var elemsSet = () =>
getElems().forEach(elem => elem && (elem.style.pointerEvents = 'none'))
var elemsClear = () =>
getElems().forEach(elem => elem && (elem.style.pointerEvents = ''))
addEventListener('keydown', e => e.key === 'Control' && elemsSet())
addEventListener('keyup', e => e.key === 'Control' && elemsClear())
addEventListener('click', e => (e.ctrlKey ? elemsSet() : elemsClear()))