Vault Value Display

vault value display

当前为 2023-02-16 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Vault Value Display
// @namespace    Madwolf
// @version      0.2
// @description vault value display
// @author       MadWolf [376657]
// @license      MadWolf [376657]
// @grant        GM_getValue
// @grant        GM_setValue
// @include      https://www.torn.com/*
// ==/UserScript==

function GM_addStyle(css) {
    const style = document.getElementById("GM_addStyleBy8626") || (function() {
      const style = document.createElement('style');
      style.type = 'text/css';
      style.id = "GM_addStyleBy8626";
      document.head.appendChild(style);
      return style;
    })();
    const sheet = style.sheet;
    sheet.insertRule(css, (sheet.rules || sheet.cssRules || []).length);
  }

  (function() {
      'use strict'
      var formatter = new Intl.NumberFormat('en-US', {
          style: 'currency',
          currency: 'USD',
          maximumFractionDigits: 0
      });

      $.ajax({
                  url: 'https://api.torn.com/user',

                  data: {
                      selections: 'money',
                      key: 'iBetYouLookedForMyKeyWolf!'
                  },

                  /**
                   * Show loader and update text before AJAX fires.
                   */
                  beforeSend: function () {
                      // self.loader.show().update('Preparing to gather all user items.');
                  },

                  /**
                   * Set up item in items object when scraped.
                   * @param data {object} | Torn API response.
                   */
                  success: function (data) {
                      var money = data;
                      console.log("Cayman bank money: " + money.cayman_bank);
                      console.log("Vault amount: " + money.vault_amount);
                      console.log("Daily networth: " + money.daily_networth);
                      console.log("City bank: " + money.city_bank.amount);
                      console.log(formatter.format(money.vault_amount));
                          var resultsDiv = $( `
          <p class="point-block___to3YE" style="white-space:nowrap">
          <span class="name___MTEAw">
          <span>Vault: <span STYLE="font-size:10.0pt; color:green"> ${formatter.format(money.vault_amount)}</span></span>
          </span>
          </p>
      ` );
                      var targetNd = $('div[class^=points]')
                      if (targetNd.length)
                          targetNd.append (resultsDiv);
                      else
                          console.error ("TM scrpt => Target node not found.");
                  },

                  /**
                   * Gather prices every selected interval (to not get API banned).
                   */
                  complete: function () {
  //                     var i = 0;

  //                     // If there are no items, stop script.
  //                     if ($.isEmptyObject(self.items)) {
  //                         self.loader.hide();
  //                         console.log('No items were scraped. Please try again.');
  //                     }

  //                     self.loader.update('All items gathered.');

  //                     _.each(pricer.items, function (value, key) {
  //                         setTimeout(function () {
  //                             self.getPrice(value.name, key);
  //                         }, options.interval.value * i);

  //                         i++;
  //                     });
                  },

                  /**
                   * If anything went wrong, hide the loader.
                   */
                  error: function () {
                      // self.loader.hide();
                      console.log('There was an error. Please try again.');
                  }
              });

      GM_addStyle ( `
      .tmJsonMashupResults {
          color: black;
          background: #f9fff9;
          margin-top: 10px;
          padding: 0.75ex 1.3ex;
          border: 1px double gray;
          border-radius: 1ex;
      }
  ` );

  })();