Faction Vault Balance Display

Displays faction vault balance for anyone!

  1. // ==UserScript==
  2. // @name Faction Vault Balance Display
  3. // @namespace dingus
  4. // @version 1.0
  5. // @description Displays faction vault balance for anyone!
  6. // @author dingus [3188789]
  7. // @license dingus [3188789]
  8. // @grant GM_addStyle
  9. // @grant GM_getValue
  10. // @grant GM_setValue
  11. // @include https://www.torn.com/*
  12. // @exclude https://https://www.torn.com/war.php?step=rankreport*
  13. // @noframes
  14. // ==/UserScript==
  15. (function() {
  16. 'use strict';
  17. var formatter = new Intl.NumberFormat('en-US', {
  18. style: 'currency',
  19. currency: 'USD',
  20. maximumFractionDigits: 0
  21. });
  22. var userid = 'USER ID HERE'
  23. $.ajax({
  24. url: 'https://api.torn.com/faction',
  25. data: {
  26. selections: 'donations',
  27. key: 'YOUR API KEY'
  28. },
  29. beforeSend: function () {
  30. },
  31. success: function (data) {
  32. var money = data;
  33. console.log("Faction Balance Amount: " + money.donations[userid].money_balance);
  34. var resultsDiv = $(`
  35. <div class="point-block___to3YE" style="white-space: nowrap; font-size: 12px; display: inline-block; font-weight: 700; width: 47px";>
  36. ${money.donations[userid].money_balance !== null && money.donations[userid].money_balance !== 0 ? `
  37. <div style="margin-top: 3px;">
  38. <span>Faction: </span>
  39. <span style="font-size: 12.8px; color: #82c91e; font-weight: 400;">${formatter.format(money.donations[userid].money_balance)}</span>
  40. </div>` : ''}
  41. </div>
  42. `);
  43. var targetNode = $('div[class^=points]');
  44. if (targetNode.length)
  45. targetNode.append(resultsDiv);
  46. else
  47. console.error("TM script => Target node not found.");
  48. },
  49. complete: function () {
  50. },
  51. error: function () {
  52. console.log('There was an error. Please try again.');
  53. }
  54. });
  55. GM_addStyle(`
  56. .tmJsonMashupResults {
  57. color: black;
  58. background: #f9fff9;
  59. margin-top: 10px;
  60. padding: 1.4ex 1.3ex;
  61. border: 1px double gray;
  62. border-radius: 1ex;
  63. }
  64. `);
  65. })();