Tools4Torn

description

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Tools4Torn
// @namespace    namespace
// @version      0.5
// @description  description
// @author       Legaci
// @match        *.torn.com/*
// @grant        GM_xmlhttpRequest
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js
// ==/UserScript==

GM_xmlhttpRequest ( {
    method:     "POST",
    url:        "https://www.torn.com/sidebarAjaxAction.php?q=getSidebarData",
    onload:     function (response) {
        const data = JSON.parse(response.response);

        const XanaxData = data.statusIcons.icons.drug_cooldown;

        var today = new Date();
        var cooldown = new Date(XanaxData.timerExpiresAt * 1000);
        var diffMs = (cooldown - today); // milliseconds between now
        var diffDays = Math.floor(diffMs / 86400000); // days
        var diffHrs = Math.floor((diffMs % 86400000) / 3600000); // hours
        var diffMins = Math.round(((diffMs % 86400000) % 3600000) / 60000); // minutes

        var box = '<div style="height:30px; display:block;">Xanax Cooldown Ends in: '+diffHrs + ' hours, ' + diffMins + ' minutes </div>';

        $( ".content-title" ).prepend( box );
    }
});