Torn Custom Race Simplifier

Make it easier and faster to make custom races.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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();
        }
    });
})();