Random target

Opens a random page of inactives

2024-10-23 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Random target
// @namespace    http://tampermonkey.net/
// @version      2024-10-23
// @description  Opens a random page of inactives
// @author       BollePapzak
// @match        https://www.torn.com/*
// @icon         https://torn.com/favicon.ico
// @grant        GM_registerMenuCommand
// @grant        GM_setValue
// @grant        GM_getValue
// @license      MIT
// ==/UserScript==

console.log('randomtarget userscript loaded')

const maxLevelKey = 'maxLevel';
const maxLevelDefault = 50;

function getRandomInt(min, max) {
  const minCeiled = Math.ceil(min);
  const maxFloored = Math.floor(max);
  return Math.floor(Math.random() * (maxFloored - minCeiled) + minCeiled); // The maximum is exclusive and the minimum is inclusive
}

GM_registerMenuCommand('Update max level', () => {
    let userInput = prompt("Enter preferred max level", GM_getValue(maxLevelKey, maxLevelDefault));
    if (userInput !== null) {
        const parsedNumber = Number.parseInt(userInput);
        if (isNaN(parsedNumber)) {
            alert(`${userInput} is not a valid number`)
            return
        }
        GM_setValue(maxLevelKey, parsedNumber);
    }
})

GM_registerMenuCommand('Goto random target list', () => {
    const maxLevel = GM_getValue(maxLevelKey, maxLevelDefault);
    const pageStart = getRandomInt(100 * 25, 55000*25);
    const url = `https://www.torn.com/page.php?sid=UserList&levelFrom=1&levelTo=${maxLevel}&lastAction=7#start=${pageStart}`;
    window.location.replace(url);
})