Last active
January 30, 2023 20:20
-
-
Save vadimstasiev/f314337de6b218a0366896396dcbcd46 to your computer and use it in GitHub Desktop.
Home assistant - frigate card - prevent touch inputs when casting to Google Hub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Home assistant - frigate card - prevent touch inputs when casting to Google Hub | |
# The reason I need to prevent touch input is because for some reason playback doesn't work | |
# and I need static cards that don't start playback when I click on them as the frigate cards do | |
# there is no option to turn that off so this script can be injected into the dashboard to | |
# prevent touch input on those cards only | |
let result = []; | |
function getElements(root, tagName) { | |
let elements = root.querySelectorAll(tagName); | |
result = [...result, ...Array.from(elements)]; | |
let shadowRoots = root.querySelectorAll('*'); | |
for (let shadowRoot of shadowRoots) { | |
if (shadowRoot.shadowRoot) { | |
getElements(shadowRoot.shadowRoot, tagName); | |
} | |
} | |
return result | |
} | |
setInterval(() => { | |
let cards = getElements(document, 'frigate-card'); | |
for (let card of cards) { | |
card.addEventListener("touchstart", (event) => { | |
event.preventDefault(); | |
}); | |
// card.style.pointerEvents = "none"; | |
} | |
}, 2000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment