Greasy Fork 还支持 简体中文。

Vault Value Display

vault value display

  1. // ==UserScript==
  2. // @name Vault Value Display
  3. // @namespace Madwolf
  4. // @version 0.5
  5. // @description vault value display
  6. // @author MadWolf [376657]
  7. // @license MadWolf [376657]
  8. // @grant GM_getValue
  9. // @grant GM_setValue
  10. // @include https://www.torn.com/*
  11. // ==/UserScript==
  12.  
  13. function GM_addStyle(css) {
  14. const style = document.getElementById("GM_addStyleBy8626") || (function() {
  15. const style = document.createElement('style');
  16. style.type = 'text/css';
  17. style.id = "GM_addStyleBy8626";
  18. document.head.appendChild(style);
  19. return style;
  20. })();
  21. const sheet = style.sheet;
  22. sheet.insertRule(css, (sheet.rules || sheet.cssRules || []).length);
  23. }
  24.  
  25. (function() {
  26. 'use strict'
  27. var formatter = new Intl.NumberFormat('en-US', {
  28. style: 'currency',
  29. currency: 'USD',
  30. maximumFractionDigits: 0
  31. });
  32.  
  33. $.ajax({
  34. url: 'https://api.torn.com/user',
  35.  
  36. data: {
  37. selections: 'money',
  38. key: 'Your API Key Here'
  39. },
  40.  
  41. /**
  42. * Show loader and update text before AJAX fires.
  43. */
  44. beforeSend: function () {
  45. // self.loader.show().update('Preparing to gather all user items.');
  46. },
  47.  
  48. /**
  49. * Set up item in items object when scraped.
  50. * @param data {object} | Torn API response.
  51. */
  52. success: function (data) {
  53. var money = data;
  54. console.log("Cayman bank money: " + money.cayman_bank);
  55. console.log("Vault amount: " + money.vault_amount);
  56. console.log("Daily networth: " + money.daily_networth);
  57. console.log("City bank: " + money.city_bank.amount);
  58. console.log(formatter.format(money.vault_amount));
  59. var resultsDiv = $( `
  60. <p class="point-block___to3YE" style="white-space:nowrap; font-size:10pt; font-weight:bold">
  61. <span class="name___MTEAw">
  62. <span>Vault: <span STYLE="font-size:10pt; color:green; font-weight:bold"> ${formatter.format(money.vault_amount)}</span></span>
  63. </span>
  64. </p>
  65. ` );
  66. var targetNd = $('div[class^=points]')
  67. if (targetNd.length)
  68. targetNd.append (resultsDiv);
  69. else
  70. console.error ("TM scrpt => Target node not found.");
  71. },
  72.  
  73. /**
  74. * Gather prices every selected interval (to not get API banned).
  75. */
  76. complete: function () {
  77. // var i = 0;
  78.  
  79. // // If there are no items, stop script.
  80. // if ($.isEmptyObject(self.items)) {
  81. // self.loader.hide();
  82. // console.log('No items were scraped. Please try again.');
  83. // }
  84.  
  85. // self.loader.update('All items gathered.');
  86.  
  87. // _.each(pricer.items, function (value, key) {
  88. // setTimeout(function () {
  89. // self.getPrice(value.name, key);
  90. // }, options.interval.value * i);
  91.  
  92. // i++;
  93. // });
  94. },
  95.  
  96. /**
  97. * If anything went wrong, hide the loader.
  98. */
  99. error: function () {
  100. // self.loader.hide();
  101. console.log('There was an error. Please try again.');
  102. }
  103. });
  104.  
  105. GM_addStyle ( `
  106. .tmJsonMashupResults {
  107. color: black;
  108. background: #f9fff9;
  109. margin-top: 10px;
  110. padding: 0.75ex 1.3ex;
  111. border: 1px double gray;
  112. border-radius: 1ex;
  113. }
  114. ` );
  115.  
  116. })();