Right Sided Combat

Moves the weapon/item panel from the left side of the attack screen to the right of the character model.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

Advertisement:

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

Advertisement:

// ==UserScript==
// @name Right Sided Combat
// @namespace right-sided-combat
// @version 1.0.3
// @author peas [3400805]
// @description Moves the weapon/item panel from the left side of the attack screen to the right of the character model.
// @match https://www.torn.com/page.php?sid=attack*
// @run-at document-end
// @license MIT
// ==/UserScript==


(function () {
    'use strict';

    function isAttackPage() {
        return window.location.href.indexOf('sid=attack') !== -1;
    }

    var repositioned = false;
    var pollTimer    = null;

    function reposition() {
        if (repositioned || !isAttackPage()) return;

        // The fight layout container uses CSS module naming: playerArea___HASH
        // Match on the stable "playerArea" prefix — the hash suffix changes per deploy
        var playerArea = document.querySelector('[class*="playerArea"]');
        if (!playerArea || playerArea.children.length < 2) return;

        // Identify which child is the weapons panel and which is the character/fight panel.
        // The character panel contains "start fight"; the weapons panel doesn't.
        var weaponsPanel = null;
        var fightPanel   = null;

        for (var i = 0; i < playerArea.children.length; i++) {
            var child = playerArea.children[i];
            if (child.textContent.toLowerCase().indexOf('start fight') !== -1) {
                fightPanel = child;
            } else {
                weaponsPanel = child;
            }
        }

        if (!weaponsPanel || !fightPanel) return;

        // Ensure container stays in horizontal flex layout
        playerArea.style.flexDirection = 'row';

        // appendChild moves weaponsPanel to the end → right side of character
        playerArea.appendChild(weaponsPanel);

        repositioned = true;
    }

    function startPolling() {
        if (!isAttackPage()) return;
        repositioned = false;
        clearInterval(pollTimer);

        pollTimer = setInterval(function () {
            if (repositioned) { clearInterval(pollTimer); return; }
            reposition();
        }, 200);

        setTimeout(function () { clearInterval(pollTimer); }, 15000);
    }

    function onNavigate() {
        repositioned = false;
        startPolling();
    }

    startPolling();
    window.addEventListener('hashchange', onNavigate);
    window.addEventListener('popstate',   onNavigate);

    var lastUrl = window.location.href;
    setInterval(function () {
        if (window.location.href !== lastUrl) {
            lastUrl = window.location.href;
            onNavigate();
        }
    }, 500);

})();