abstracted elems definitions

This commit is contained in:
2023-04-09 22:39:27 -05:00
parent 567dabf661
commit 888687f2f5
4 changed files with 24 additions and 23 deletions

View File

@@ -2,22 +2,22 @@
// @name Twitch Clickable Video
// @namespace zomo.dev
// @match https://www.twitch.tv/*
// @version 1.0
// @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 getElems = () => [
document.querySelector('.video-player__overlay'),
document.querySelector(
'.video-player__overlay:nth-child(1) > div:nth-child(1)'
),
document.querySelector(
'.video-player__overlay:nth-child(1) > div:nth-child(1) > div:nth-child(1)'
),
document.querySelector('.click-handler'),
]
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 = () => {
const elems = Elems.split(',').filter(l => l.trim().length)
return elems.map(elem => document.querySelector(elem.trim()))
}
var elemsSet = () =>
getElems().forEach(elem => elem && (elem.style.pointerEvents = 'none'))
var elemsClear = () =>