Torn Custom Race Simplifier

Make it easier and faster to make custom races.

您需要先安裝使用者腳本管理器擴展,如 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 Race Simplifier
// @version      0.5
// @description  Make it easier and faster to make custom races.
// @author       Xiphias[187717]
// @match        *www.torn.com/loader.php?sid=racing*
// @grant        none
// @namespace https://greasyfork.org/users/3898
// ==/UserScript==
var numberOfLaps = "1"; // Change this value to set number of laps.
var maxDrivers = "2"; // Change this value to set the number of maximum drivers.
var trackName = "Uptown"; // Change to desired track name

(function() {
    'use strict';
	$('body').ajaxComplete(function (e, xhr, settings) {
        var createCustomRaceSection = "section=createCustomRace";
		var url = settings.url;
		if (url.indexOf(createCustomRaceSection) >= 0) {
            var lapsInput = $('.laps-wrap > .input-wrap > input');
            lapsInput.attr('value', numberOfLaps);

            var maxDriversInput = $('.drivers-max-wrap div.input-wrap input');
            maxDriversInput.attr('value', maxDrivers);

            $('#select-racing-track').selectmenu();
            $('#select-racing-track-menu > li:contains(' + trackName+ ')').mouseup();
        }
    });
})();