diff --git a/dist/twitch-clickable-video.user.js b/dist/twitch-clickable-video.user.js index 25a6507..7859912 100644 --- a/dist/twitch-clickable-video.user.js +++ b/dist/twitch-clickable-video.user.js @@ -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 = () => diff --git a/readme.md b/readme.md index dd567f5..297972c 100644 --- a/readme.md +++ b/readme.md @@ -9,6 +9,6 @@ Requires Violentmonkey (or Tampermonkey etc): [Chrome](https://chrome.google.com - zomo.dev 1.0 - 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) - - zomo.dev 1.0 + - zomo.dev 1.1 - hold Control key to be able to right click the video element diff --git a/scripts/twitch-clickable-video/main.ts b/scripts/twitch-clickable-video/main.ts index 04f95da..436c5a2 100644 --- a/scripts/twitch-clickable-video/main.ts +++ b/scripts/twitch-clickable-video/main.ts @@ -1,13 +1,14 @@ -const 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'), -] +const 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 +` + +const getElems = () => { + const elems = Elems.split(',').filter(l => l.trim().length) + return elems.map(elem => document.querySelector(elem.trim())) +} const elemsSet = () => getElems().forEach(elem => elem && (elem.style.pointerEvents = 'none')) diff --git a/scripts/twitch-clickable-video/meta.json b/scripts/twitch-clickable-video/meta.json index 8027896..1ff1f9f 100644 --- a/scripts/twitch-clickable-video/meta.json +++ b/scripts/twitch-clickable-video/meta.json @@ -3,6 +3,6 @@ "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" }