Guest User

Untitled

a guest
Oct 3rd, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.66 KB | None | 0 0
  1. var money;
  2. var robux;
  3. var robuxItemCost;
  4. var robuxAmount;
  5. var robuxValue = 0.0035;
  6. var currency;
  7. var nf = new Intl.NumberFormat();
  8.  
  9. window.onload = function () {
  10.  
  11. robuxAmount = document.getElementById("nav-robux-amount").innerHTML;
  12.  
  13. robuxCalculate();
  14. robuxItemCalculate()
  15.  
  16.  
  17. }
  18.  
  19. function robuxItemCalculate() {
  20. chrome.storage.local.get(['robuxitemcheckbox'], function(result) {
  21. if (result.robuxitemcheckbox === true){
  22. if(document.body.contains(document.getElementsByClassName("text-robux-lg wait-for-i18n-format-render")[0])){
  23. chrome.storage.local.get(['currency'], function(result) {
  24. currency = result.currency;
  25. });
  26. robuxItemCost = document.getElementsByClassName("text-robux-lg wait-for-i18n-format-render")[0].innerHTML;
  27. robuxItemCost = robuxItemCost.replace(/,/g, '');
  28. money = robuxValue * robuxItemCost;
  29.  
  30. let demo = () => {
  31. money = parseFloat(money);
  32. money = money.toFixed(2);
  33. let rate = fx(money).from("USD").to(currency);
  34. money = rate.toFixed(2);
  35. money = nf.format(money);
  36. document.getElementsByClassName("text-robux-lg wait-for-i18n-format-render")[0].innerHTML = '$' + money + ' ' + currency;
  37. }
  38.  
  39. fetch('https://api.exchangeratesapi.io/latest')
  40. .then((resp) => resp.json())
  41. .then((data) => fx.rates = data.rates)
  42. .then(demo);
  43. }
  44. }
  45. });
  46. }
  47.  
  48. function robuxCalculate() {
  49. chrome.storage.local.get(['robuxamountcheckbox'], function(result) {
  50. if (result.robuxamountcheckbox === true){
  51. chrome.storage.local.get(['currency'], function(result) {
  52. currency = result.currency;
  53. });
  54. robux = document.getElementById("nav-robux-amount").innerHTML;
  55. robux = robux.replace(/,/g, '');
  56. money = robuxValue * robux;
  57.  
  58. let demo = () => {
  59. money = parseFloat(money);
  60. money = money.toFixed(2);
  61. let rate = fx(money).from("USD").to(currency);
  62. money = rate.toFixed(2);
  63. money = nf.format(money);
  64. document.getElementById("nav-robux-amount").innerHTML = '$' + money + ' ' + currency;
  65. if(!isNaN(money)){
  66. //setTimeout(document.getElementById("nav-robux-amount").innerHTML = '$' + money + ' ' + currency, 1000);
  67. //document.getElementById("nav-robux-amount").innerHTML = '$' + money + ' ' + currency;
  68. }
  69. }
  70.  
  71. fetch('https://api.exchangeratesapi.io/latest')
  72. .then((resp) => resp.json())
  73. .then((data) => fx.rates = data.rates)
  74. .then(demo)
  75. }
  76. });
  77. }
  78.  
  79. //Calculating currency stuff I copied from a website
  80. (function(root, undefined) {
  81.  
  82. var fx = function(obj) {
  83. return new fxWrapper(obj);
  84. };
  85.  
  86. fx.version = '0.2';
  87.  
  88. var fxSetup = root.fxSetup || {
  89. rates : {},
  90. base : ""
  91. };
  92.  
  93. fx.rates = fxSetup.rates;
  94.  
  95. fx.base = fxSetup.base;
  96.  
  97. fx.settings = {
  98. from : fxSetup.from || fx.base,
  99. to : fxSetup.to || fx.base
  100. };
  101.  
  102. var convert = fx.convert = function(val, opts) {
  103. if (typeof val === 'object' && val.length) {
  104. for (var i = 0; i< val.length; i++ ) {
  105. val[i] = convert(val[i], opts);
  106. }
  107. return val;
  108. }
  109.  
  110. opts = opts || {};
  111.  
  112. if( !opts.from ) opts.from = fx.settings.from;
  113. if( !opts.to ) opts.to = fx.settings.to;
  114.  
  115. return val * getRate( opts.to, opts.from );
  116. };
  117.  
  118. var getRate = function(to, from) {
  119. var rates = fx.rates;
  120.  
  121. rates[fx.base] = 1;
  122.  
  123. if ( !rates[to] || !rates[from] ) throw "fx error";
  124.  
  125. if ( from === fx.base ) {
  126. return rates[to];
  127. }
  128.  
  129. if ( to === fx.base ) {
  130. return 1 / rates[from];
  131. }
  132.  
  133. return rates[to] * (1 / rates[from]);
  134. };
  135.  
  136.  
  137. var fxWrapper = function(val) {
  138. if ( typeof val === "string" ) {
  139. this._v = parseFloat(val.replace(/[^0-9-.]/g, ""));
  140. this._fx = val.replace(/([^A-Za-z])/g, "");
  141. } else {
  142. this._v = val;
  143. }
  144. };
  145.  
  146. var fxProto = fx.prototype = fxWrapper.prototype;
  147.  
  148. fxProto.convert = function() {
  149. var args = Array.prototype.slice.call(arguments);
  150. args.unshift(this._v);
  151. return convert.apply(fx, args);
  152. };
  153.  
  154. fxProto.from = function(currency) {
  155. var wrapped = fx(convert(this._v, {from: currency, to: fx.base}));
  156. wrapped._fx = fx.base;
  157. return wrapped;
  158. };
  159.  
  160. fxProto.to = function(currency) {
  161. return convert(this._v, {from: this._fx ? this._fx : fx.settings.from, to: currency});
  162. };
  163.  
  164. if (typeof exports !== 'undefined') {
  165. if (typeof module !== 'undefined' && module.exports) {
  166. exports = module.exports = fx;
  167. }
  168. exports.fx = fx;
  169. } else if (typeof define === 'function' && define.amd) {
  170. define([], function() {
  171. return fx;
  172. });
  173. } else {
  174. fx.noConflict = (function(previousFx) {
  175. return function() {
  176. root.fx = previousFx;
  177. fx.noConflict = undefined;
  178. return fx;
  179. };
  180. })(root.fx);
  181.  
  182. root['fx'] = fx;
  183. }
  184.  
  185. }(this));
Add Comment
Please, Sign In to add comment