Tools4Torn

description

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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 );
    }
});