您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
This script adds a one click training function to company training.
当前为
// ==UserScript== // @author Xiphias[187717] // @name Torn City - One click Company training by Xiphias[187717] // @description This script adds a one click training function to company training. // @include http://www.torn.com/companies.php* // @include http://torn.com/companies.php* // @include https://www.torn.com/companies.php* // @include https://torn.com/companies.php* // @version 1.0.0 // @namespace https://gf.qytechs.cn/users/3898 // ==/UserScript== var emplUrl = 'step=trainemp&ID='; $('body') .ajaxComplete(function (e, xhr, settings) { var url = settings.url; if (url.indexOf(emplUrl) >= 0) { var employeeID = getIDFromUrl(url); addTrainXTimesButton(employeeID); } }); /** * @param url {String} Employee train href */ function getIDFromUrl(url) { var idRegex = /ID=(\d+)/; var match = idRegex.exec(url); if (match) { return match[1]; } else { return '0'; } } function addTrainXTimesButton(employeeID) { var newElements = '<span style="position: relative; left: 2px; border-right: 2px solid #444; margin-right: -2px;"></span><a id="trainXtimesBtn' + employeeID + '" href="#nogo" style="position: relative; left: 10px;"><b>Train times.</b></a><input style="position: relative; padding-left: 3px; left: -50px; background-color: #ebebeb; height: 18px; width: 18px;" placeholder="20" id="trainXtimesInput' + employeeID + '" ></span>'; $('.train-info.confirm.p10') .find('[href*="trainemp2&ID=' + employeeID + '"]') .parent() .append(newElements); $('#trainXtimesBtn' + employeeID) .on('click', function () { var times = getTimesToTrain(employeeID); repeatTrains(employeeID, times); }); } function sendTrainRequest(employeeID) { $.get('companies.php?rfcv' + getCookie('rfc_v'), { step: 'trainemp2', ID: employeeID }, function (data) { console.log(data); }); } function repeatTrains(employeeID, times) { var i = 0, howManyTimes = times; if (times == 0) return; function f() { sendTrainRequest(employeeID); i++; if (i < howManyTimes) { setTimeout(f, 500); } } f(); } function getTimesToTrain(employeeID) { var timesString = $('#trainXtimesInput' + employeeID) .val(); try { if (timesString.length==0 || timesString == "undefined") { return 20; } times = parseInt(timesString); if (times > 20) { return 20; } else if (times < 0) { return 0; } else if (times >= 0 && times <= 20){ return times; } else { return 0; } } catch (e) { console.log(e); return 0; } }
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址