Skip to content

Instantly share code, notes, and snippets.

@dr4k0nia
Created July 25, 2022 14:18
Show Gist options
  • Save dr4k0nia/9588fb64653b10844df5818a99d16b68 to your computer and use it in GitHub Desktop.
Save dr4k0nia/9588fb64653b10844df5818a99d16b68 to your computer and use it in GitHub Desktop.
Destiny 2 Twitch Extension auto react to trials matches using Tampermonkey
// ==UserScript==
// @name D2 Reaction Farmer
// @namespace https://github.com/dr4k0nia
// @version 1.0
// @description Auto click reaction for Destiny 2 Twitch Extension
// @author drakonia
// @match https://63i11l5ul8pm3buvheb3j2oyflbhtw.ext-twitch.tv/63i11l5ul8pm3buvheb3j2oyflbhtw/1.61/a2539f7f48a126bb354318161238275c/video_overlay.html*
// @run-at document-end
// @icon https://raw.githubusercontent.com/justrealmilk/destiny-icons/8b697d4529262a850d0c987ca78db86d3989850b/factions/faction_osiris.svg
// @grant none
// ==/UserScript==
const button = 'div.Reaction_reactionButton__3Vxvs';
setInterval(() => {
// Check if reaction exists and is in viewport
if (!document.querySelector(button) || !isInViewport(document.querySelector(button))) return;
console.log('Reaction added');
document.querySelector(button).click();
}, 3000);
function isInViewport(element) {
const rect = element.getBoundingClientRect();
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment