higherlower "hack"

useless hack for higherorlowergame.com

נכון ליום 14-02-2025. ראה הגרסה האחרונה.

// ==UserScript==
// @name         higherlower "hack"
// @description  useless hack for higherorlowergame.com
// @icon         https://i.imgur.com/ORAaPzD.png
// @version      1

// @author       VillainsRule
// @namespace    https://github.com/VillainsRule/HigherLowerHack

// @match        *://*.higherorlowergame.com/*
// @run-at       document-start
// @grant        none
// ==/UserScript==

Object._values = Object.values
Object.values = function (obj) {
    if (Object.prototype.toString.call(obj) === "[object Module]") {
        let keys = Object.keys(obj);
        window.answers = obj[keys[0]];
        console.log('got answers', window.answers);
    }

    return Object._values(obj);
}

HTMLElement.prototype._addEventListener = HTMLElement.prototype.addEventListener;
HTMLElement.prototype.addEventListener = function (event, listener) {
    if (this.classList.contains('playfield-pane-container')) {
        console.log('new round has started, attempting to detect two options...');

        let headers = document.querySelectorAll('.playfield-pane__heading');
        let alpha = headers[0].innerText;
        let beta = headers[1].innerText;

        console.log('found two options', alpha, beta);

        let alphaTrack = answers.find((a) => a.title == alpha);
        let betaTrack = answers.find((a) => a.title == beta);

        console.log('found option tracks', alphaTrack, betaTrack);

        if (alphaTrack.playCount > betaTrack.playCount) window.correctIndex = 0;
        else window.correctIndex = 1;

        console.log('decided correctIndex', window.correctIndex);

        setTimeout(() => {
            document.querySelectorAll('.playfield-pane__heading')[window.correctIndex].style.backgroundColor = 'green';
            document.querySelectorAll('.playfield-pane__heading')[+!window.correctIndex].style.backgroundColor = 'red';

            console.log('updated DOM');
        }, 750);
    }

    return HTMLElement.prototype._addEventListener.call(this, event, listener);
}