Torn.com Align Sell Action Right & Auto Close

Aligns the sell action text to the right and auto-clicks the Close button on Torn.com item page

2025-02-21 기준 버전입니다. 최신 버전을 확인하세요.

// ==UserScript==
// @name         Torn.com Align Sell Action Right & Auto Close
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Aligns the sell action text to the right and auto-clicks the Close button on Torn.com item page
// @author       Slaterz [2479416]
// @match        https://www.torn.com/item.php*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to align text to the right
    function alignSellActionText() {
        const sellActElements = document.querySelectorAll('.action-wrap.sell-act');
        sellActElements.forEach(element => {
            element.style.textAlign = 'right';
        });
    }

    // Function to auto-click the "Close" button
    function autoClickClose() {
        const closeButton = document.querySelector('.action-wrap.sell-act .close-act');
        if (closeButton) {
            closeButton.click();
            console.log('Clicked the close button automatically.');
        }
    }

    // Combine both functions
    function handleSellAction() {
        alignSellActionText();
        autoClickClose();
    }

    // Run the function when the page loads
    window.addEventListener('load', handleSellAction);

    // Run the function when the page content changes (for Torn's dynamic content)
    const observer = new MutationObserver(handleSellAction);
    observer.observe(document.body, { childList: true, subtree: true });
})();