Torn Custom Plane Image

Sets a custom plane image on the Torn Travel page.

目前為 2025-03-15 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Torn Custom Plane Image
// @namespace    http://tampermonkey.net/
// @version      1
// @description  Sets a custom plane image on the Torn Travel page.
// @author       TR0LL [2561502]
// @match        https://www.torn.com/page.php?sid=travel
// @match        https://www.torn.com/preferences.php
// @grant        GM_setValue
// @grant        GM_getValue
// @license      Proprietary
// ==/UserScript==

(function() {
    'use strict';

    const defaultImage = "https://i.pinimg.com/originals/98/5e/ad/985ead90bd841958d2bb4b09ca60d123.gif";

    function replacePlaneImage() {
        const planeImage = document.querySelector('.planeImage___Kbn3b');
        if (!planeImage) return;

        const customImage = GM_getValue('permanentPlaneImage') || defaultImage;
        planeImage.src = customImage;

        // Center the image
        planeImage.style.position = 'absolute';
        planeImage.style.top = '50%';
        planeImage.style.left = '50%';
        planeImage.style.transform = 'translate(-50%, -50%)';
        planeImage.style.maxWidth = '778px';
        planeImage.style.maxHeight = '300px';
        planeImage.style.width = 'auto';
        planeImage.style.height = 'auto';
    }

    function addImageButton() {
        if (!window.location.href.startsWith("https://www.torn.com/preferences.php")) return;

        const imageButton = document.createElement('button');
        imageButton.textContent = 'Set Plane Image';
        imageButton.style.padding = '8px 12px';
        imageButton.style.margin = '5px';
        imageButton.style.cursor = 'pointer';
        imageButton.style.backgroundColor = '#3498db';
        imageButton.style.color = 'white';
        imageButton.style.border = 'none';
        imageButton.style.borderRadius = '3px';
        imageButton.style.fontSize = '14px';

        // Position the button on the right side of the screen
        imageButton.style.position = 'fixed';
        imageButton.style.top = '50%';
        imageButton.style.right = '20px'; // Adjust this value to change the distance from the right
        imageButton.style.transform = 'translateY(-50%)';
        imageButton.style.zIndex = '9999'; // Ensure it's above other elements

        imageButton.addEventListener('click', () => {
            const imageUrl = prompt("Please enter the image URL");
            if (imageUrl){
                GM_setValue('permanentPlaneImage', imageUrl);
                replacePlaneImage();
            }
        });

        document.body.appendChild(imageButton);
    }

    replacePlaneImage();
    addImageButton();

    const observer = new MutationObserver(mutations => {
        replacePlaneImage();
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
})();