Dog Tag Hunter

Shows Attacks won and lost since the start of DogTag Competition

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Dog Tag Hunter
// @namespace    namespace
// @version      1.2
// @description  Shows Attacks won and lost since the start of DogTag Competition 
// @author       Llyfr
// @match        https://www.torn.com/profiles.php*
// @license      MIT
// @grant        none
// ==/UserScript==



(function() {
    'use strict';

    let API = ""
    
    const time_start = 1652702400 // start of the competition 
    const time_end = 1653566400 // end of the competition 
    const unixTime = Math.floor(Date.now() / 1000); // Get Current time

    // If the API is empty, inform user and quit
    if(API == "") 
    {
        document.getElementsByClassName("title-black top-round")[1].innerText = `Missing API Key, Please enter it in the code`
        return;
    }

    // If the competition didn't started yet, it closes program. No need to waste API calls :)
    if(time_start > unixTime || time_end < unixTime)
    {
        return;
    }

    //Gets the profile ID from url 
    let url = window.location.href
    let id = url.slice(url.indexOf("ID=") + 3)
 

    var request = new XMLHttpRequest();
    request.open('GET', `https://api.torn.com/user/${id}?selections=personalstats&stat=attackswon,defendslost&key=${API}`)
    request.send();
    request.onload = ()=>
    {
        let data_now = JSON.parse(request.responseText).personalstats;

            request.open('GET', `https://api.torn.com/user/${id}?selections=personalstats&stat=attackswon,defendslost&timestamp=${time_start}&key=${API}`);
            request.send()
    
            request.onload = ()=> 
            {
                let data_old = JSON.parse(request.responseText).personalstats
                let attacks = data_now.attackswon - data_old.attackswon
                let defends = data_now.defendslost - data_old.defendslost
    
                // console.log(data_now,data_old) // For Debug
    
                document.getElementsByClassName("title-black top-round")[1].innerText = `Wins: ${attacks} | Defeats: ${defends}`
            }   
}
})();