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 // @name Twitch Clickable Video
// @namespace zomo.dev // @namespace zomo.dev
// @match https://www.twitch.tv/* // @match https://www.twitch.tv/*
// @version 1.0 // @version 1.1
// @description hold Control key to be able to right click the video element // @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 // @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 // @supportURL https://git.zomo.dev/zomo/browser-scripts/issues
// @homepageURL https://git.zomo.dev/zomo/browser-scripts // @homepageURL https://git.zomo.dev/zomo/browser-scripts
// ==/UserScript== // ==/UserScript==
var getElems = () => [ var Elems = `
document.querySelector('.video-player__overlay'), .video-player__overlay,
document.querySelector( .video-player__overlay:nth-child(1) > div:nth-child(1),
'.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
document.querySelector( `
'.video-player__overlay:nth-child(1) > div:nth-child(1) > div:nth-child(1)' var getElems = () => {
), const elems = Elems.split(',').filter(l => l.trim().length)
document.querySelector('.click-handler'), return elems.map(elem => document.querySelector(elem.trim()))
] }
var elemsSet = () => var elemsSet = () =>
getElems().forEach(elem => elem && (elem.style.pointerEvents = 'none')) getElems().forEach(elem => elem && (elem.style.pointerEvents = 'none'))
var elemsClear = () => var elemsClear = () =>

View File

@@ -9,6 +9,6 @@ Requires Violentmonkey (or Tampermonkey etc): [Chrome](https://chrome.google.com
- zomo.dev 1.0 - zomo.dev 1.0
- automatically grab optifine links through the ads - automatically grab optifine links through the ads
- [Twitch Clickable Video](https://git.zomo.dev/zomo/browser-scripts/raw/branch/main/dist/twitch-clickable-video.user.js) - [Twitch Clickable Video](https://git.zomo.dev/zomo/browser-scripts/raw/branch/main/dist/twitch-clickable-video.user.js)
- zomo.dev 1.0 - zomo.dev 1.1
- hold Control key to be able to right click the video element - hold Control key to be able to right click the video element
<!-- END INSTALL LINKS --> <!-- END INSTALL LINKS -->

View File

@@ -1,13 +1,14 @@
const getElems = () => [ const Elems = `
document.querySelector<HTMLDivElement>('.video-player__overlay'), .video-player__overlay,
document.querySelector<HTMLDivElement>( .video-player__overlay:nth-child(1) > div:nth-child(1),
'.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
document.querySelector<HTMLDivElement>( `
'.video-player__overlay:nth-child(1) > div:nth-child(1) > div:nth-child(1)'
), const getElems = () => {
document.querySelector<HTMLDivElement>('.click-handler'), const elems = Elems.split(',').filter(l => l.trim().length)
] return elems.map(elem => document.querySelector<HTMLElement>(elem.trim()))
}
const elemsSet = () => const elemsSet = () =>
getElems().forEach(elem => elem && (elem.style.pointerEvents = 'none')) getElems().forEach(elem => elem && (elem.style.pointerEvents = 'none'))

View File

@@ -3,6 +3,6 @@
"name": "Twitch Clickable Video", "name": "Twitch Clickable Video",
"namespace": "zomo.dev", "namespace": "zomo.dev",
"match": "https://www.twitch.tv/*", "match": "https://www.twitch.tv/*",
"version": "1.0", "version": "1.1",
"description": "hold Control key to be able to right click the video element" "description": "hold Control key to be able to right click the video element"
} }