Greasy Fork is available in English.

BCT Defaultor

Set BCT as the default flight method

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         BCT Defaultor
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Set BCT as the default flight method
// @author       Titanic_
// @license      MIT
// @match        https://www.torn.com/page.php?sid=travel*
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

    const bctSelector = 'input[name="travelType"][value="business"]';
    let hasCompleted = false;

    function selectBusinessClass() {
        const bctRadio = document.querySelector(bctSelector);

        if (!bctRadio) return false;

        if (!bctRadio.disabled && !bctRadio.checked) {
            bctRadio.click();
            hasCompleted = true;
            return true;
        }

        if (bctRadio.disabled || bctRadio.checked) {
            hasCompleted = true;
            return true;
        }

        if (bctRadio.disabled && !bctRadio.checked) console.error('[BCT] You dont have any BCT');

        return false;
    }

    const observer = new MutationObserver((mutations, obs) => {
        if (selectBusinessClass()) {
            obs.disconnect();
        }
    });

    const root = document.getElementById('travel-root');
    if (root) {
        observer.observe(root, {
            childList: true,
            subtree: true
        });

        selectBusinessClass();
    } else console.error('[BCT] Couldnt find #travel-root');

    setTimeout(() => {
        if (!hasCompleted) {
            observer.disconnect();
            console.log('[BCT] Timed out');
        }
    }, 10000);

})();