Auto Click 'Pass' and 'Like' Buttons on boo.world

Click the 'Pass' button when pressing 'x' key and the 'Like' button when pressing 'd' key on boo.world

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Auto Click 'Pass' and 'Like' Buttons on boo.world
// @namespace    https://github.com/Maxhem2/BooWeb-MatchKeyboardSupport
// @version      1.0
// @description  Click the 'Pass' button when pressing 'x' key and the 'Like' button when pressing 'd' key on boo.world
// @match        https://boo.world/de/match
// @license MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let clicking = false; // Flag to track whether clicking is active

    // Add an event listener to listen for key presses
    window.addEventListener('keydown', function(event) {
        if (event.key === 'x' && !clicking) {
            clicking = true;
            clickUntilDOMChange('.action-button-large.clickable.hoverable.hover-grow-size-5.active-shrink-size img[src="/static/match_icons/pass.svg"]');
        } else if (event.key === 'd' && !clicking) {
            clicking = true;
            clickUntilDOMChange('.action-button-large.clickable.hoverable.hover-grow-size-5.active-shrink-size img[src="/static/match_icons/favorite.svg"]');
        }
    });

    function clickUntilDOMChange(selector) {
        const button = document.querySelector(selector);

        if (button) {
            const initialDOM = document.documentElement.outerHTML; // Get the initial DOM content

            const clickInterval = setInterval(() => {
                button.parentElement.click(); // Click the parent element containing the image

                // Check for DOM changes
                if (initialDOM !== document.documentElement.outerHTML) {
                    clicking = false; // Stop clicking
                    clearInterval(clickInterval);
                }
            }, 10); // Click every 10ms
        }
    }
})();