您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add the new number of crimes in the category to the result message
当前为
// ==UserScript== // @name Add crime stats to result // @namespace http://tampermonkey.net/ // @version 0.1 // @description Add the new number of crimes in the category to the result message // @author miros // @license MIT // @match https://www.torn.com/crimes.php* // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @grant none // ==/UserScript== // YOUR API KEY HERE - I think public level should be OK const API_KEY = ""; var nerve_to_cat = { 2: 'other', 3: 'selling_illegal_products', 4: 'theft', 5: 'theft', 6: 'theft', 7: 'theft', 8: 'drug_deals', 9: 'computer_crimes', 10: 'murder', 11: 'fraud_crimes', 12: 'auto_theft', 13: 'theft', 14: 'fraud_crimes', 15: 'theft', 16: 'selling_illegal_products', 17: 'fraud_crimes', 18 : 'computer_crimes', }; Object.defineProperty(String.prototype, 'capitalize', { value: function() { return this.charAt(0).toUpperCase() + this.slice(1); }, }); Object.defineProperty(String.prototype, 'cat_to_title', { value: function() { return this.split('_').map(element => { return element.capitalize() }).join(' '); } }); (function() { 'use strict'; //alert('running Add crime stats to result.user'); var intv = setInterval(function() { var message = document.querySelector('div.success-message'); if(! message){ return false; } //when element is found, clear the interval. clearInterval(intv); //alert('found message: [' + message.innerHTML + ']'); var nerve = document.querySelector('input[name="nervetake"]').getAttribute('value'); var cat = nerve_to_cat[nerve]; var title = cat.cat_to_title(); //alert('nerve is [' + nerve + '], category is [' + cat + ']') ; fetch('https://api.torn.com/user/' + API_KEY + '?selections=crimes&key=' + API_KEY) .then((response) => response.json()) .then((data) => message.innerHTML = message.innerHTML + '<span style="display: inline-block; float: right; color:aquamarine;">' + data.criminalrecord[cat] + ' ' + title + '</span>'); }, 300); })();