Displaycase Value

Display the total value of items in the displaycase

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Displaycase Value
// @namespace    com.torn.GamingAnonymous
// @version      1.1
// @description  Display the total value of items in the displaycase
// @author       GamingAnonymous
// @match        *.torn.com/displaycase.php*
// @grant        none
// ==/UserScript==

// Your API Key
var apiKey = "yourAPIKey";
var worthTotal = 0;

(function() {
    'use strict';
    console.log("API Key: " + apiKey);

    // get the ID of the displaycase you are currently viewing
    let currentPage = window.location.href;
    let urlElements = currentPage.split('/');
    let currentPageUserID = urlElements[urlElements.length - 1];
    console.log(currentPageUserID);

    // Get the information from the API for this displaycase
    let url = 'https://api.torn.com/user/' + currentPageUserID + '?selections=display&key=' + apiKey;
    fetch(url)
        .then(res => res.json())
        .then((out) => {
        for(let i = 0; i < out.display.length; i++)
        {
            // Add up the worth of the items
            worthTotal += out.display[i].market_price;
        }

        // Display the worth formatted with commas
        window.alert("This display case is worth: $" + worthTotal.toLocaleString(undefined));
    })
    .catch(err => console.error(err));
})();