Greasy Fork 还支持 简体中文。

Stake.com Vault Script (2024 - WORKING)

Sends a percentage of your profits to the vault

  1. // ==UserScript==
  2. // @name Stake.com Vault Script (2024 - WORKING)
  3. // @description Sends a percentage of your profits to the vault
  4. // @description Updated to make it run on all official mirrors
  5. // @description If stake.com is blocked by your country, is lagging or has a bad performance, try one of their mirrorsites
  6. // @description Find all official mirrors at --> https://playstake.io/
  7. // @description Based on @Dauersendung script which is outdated
  8. // @description Tested with crypto display only (don't use USD, EUR, JPY, BRL, CAD, CNY, IDR, INR, KRW, MXN, PHP, RUB view)
  9. // @description Setup percentage to be saved at SAVE_AMOUNT (at the beginning of the script)
  10. // @description Running it in more than one tab might cause duplicated deposits to the vault
  11. // @version 1.5
  12. // @author William
  13. // @match https://stake.com/*
  14. // @match https://stake.bet/*
  15. // @match https://stake.games/*
  16. // @match https://staketr.com/*
  17. // @match https://staketr2.com/*
  18. // @match https://staketr3.com/*
  19. // @match https://staketr4.com/*
  20. // @match https://stake.bz/*
  21. // @run-at document-end
  22. // @namespace Stake.com Vault Script (2024 - WORKING)
  23. // ==/UserScript==
  24. (function() {
  25. const SAVE_AMOUNT = 0.10 //Percentage of the winnings, in decimal (Examples: 50% => 0.50, 75% => 0.75, 15% => 0.15, 10% => 0.10)
  26. const DISPLAY_VAULT_TOTAL = true; // If true it will display the VAULT TOTAL. If false it will display the SUM of deposits made since opened
  27. function getCookie(cname) {
  28. var name = cname + "=";
  29. var decodedCookie = decodeURIComponent(document.cookie);
  30. var ca = decodedCookie.split(';');
  31. for(var i = 0; i <ca.length; i++) {
  32. var c = ca[i];
  33. while (c.charAt(0) == ' ') {
  34. c = c.substring(1);
  35. }
  36. if (c.indexOf(name) == 0) {
  37. return c.substring(name.length, c.length);
  38. }
  39. }
  40. return "";
  41. }
  42. class StakeApi {
  43. constructor() {
  44. this._accessToken = getCookie("session").replace(/"/g, '');
  45. // this._accessToken = localStorage.getItem('session').replace(/"/g, '');
  46. }
  47. async call(body) {
  48. return fetch("https://stake.com/_api/graphql", {
  49. "credentials": "omit",
  50. "headers": {
  51. "content-type": "application/json",
  52. 'x-access-token': this._accessToken,
  53. 'x-lockdown-token': ""},
  54. "referrer": "https://stake.com/",
  55. "body": body,
  56. "method": "POST",
  57. "mode": "cors"
  58. });
  59. }
  60. async getBalances() {
  61. return this.call("{\"operationName\":\"UserVaultBalances\",\"variables\":{},\"query\":\"query UserVaultBalances {\\n user {\\n id\\n balances {\\n available {\\n amount\\n currency\\n __typename\\n }\\n vault {\\n amount\\n currency\\n __typename\\n }\\n __typename\\n }\\n __typename\\n }\\n}\\n\"}");
  62. }
  63. async depositToVault(currency, amount) {
  64. var data = {
  65. operationName: "CreateVaultDeposit",
  66. variables: {
  67. currency: currency,
  68. amount: amount
  69. },
  70. query: "mutation CreateVaultDeposit($amount: Float!, $currency: CurrencyEnum!) {\n createVaultDeposit(amount: $amount, currency: $currency) {\n id\n amount\n currency\n user {\n id\n balances {\n available {\n amount\n currency\n __typename\n }\n vault {\n amount\n currency\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n}\n"
  71. };
  72. return this.call(JSON.stringify(data));
  73. }
  74. }
  75. // let balanceSelector = 'header .styles__Cashier-puey40-2.dMSTdD .styles__Content-rlm06o-1.ixoRjG';
  76. let balanceSelector = '.navigation .balance-toggle .currency span.content span';
  77. var oldBal = '';
  78. let activeCurrency;
  79. const stakeApi = new StakeApi();
  80. function getCurrency() {
  81. return getCookie("currency_currency").replace(/"/g, '');
  82. // return JSON.parse(localStorage.getItem("v2_currency")).currency;
  83. }
  84. function updateCurrency() {
  85. let c = getCurrency();
  86. if(c != activeCurrency) {
  87. activeCurrency = c;
  88. return true;
  89. }
  90. return false;
  91. }
  92. class Wing {
  93. constructor() {
  94. this._element = document.createElement("span");
  95. this._element.id = "wingElm";
  96. this._element.innerText = "0.00000000";
  97. if (DISPLAY_VAULT_TOTAL) {
  98. this.setVaultBalance();
  99. }
  100. // document.querySelector(".styles__Wrap-rlm06o-0.bGSyHm").insertBefore(this._element, null);
  101. document.querySelector(".navigation .balance-toggle .currency").insertBefore(this._element, null);
  102. this._element.title = "Deposited to vault";
  103. }
  104. setVaultBalance() {
  105. stakeApi.getBalances().then((r) => r.json()).then((response) => {
  106. updateCurrency();
  107. let balance = response.data.user.balances.find(x => x.vault.currency == activeCurrency);
  108. if(balance) {
  109. this._element.innerText = balance.vault.amount.toFixed(8);
  110. }
  111. });
  112. }
  113. update(amount) {
  114. console.log('updating');
  115. if (DISPLAY_VAULT_TOTAL) {
  116. this._element.innerText = amount.toFixed(8);
  117. } else {
  118. this._element.innerText = (parseFloat(this._element.innerText) + amount).toFixed(8);
  119. }
  120. }
  121. reset() {
  122. console.log('reseting');
  123. if (DISPLAY_VAULT_TOTAL) {
  124. this.setVaultBalance();
  125. } else {
  126. this._element.innerText = "0.00000000";
  127. }
  128. }
  129. }
  130. let wing;
  131. function init(){
  132. if (document.readyState === 'complete') {
  133. var oldBal = document.querySelector(balanceSelector).innerText;
  134. var curBalEle = document.querySelector(balanceSelector).innerText;
  135. wing = new Wing();
  136. function tresor() {
  137. oldBal = curBalEle
  138. if (oldBal = curBalEle) {
  139. function checkBalance() {
  140. var curBalEle = document.querySelector(balanceSelector);
  141. if(updateCurrency()) { // if currency was changed return
  142. wing.reset();
  143. oldBal = document.querySelector(balanceSelector).innerText;
  144. curBalEle = document.querySelector(balanceSelector).innerText;
  145. return;
  146. }
  147. if(document.querySelectorAll(balanceSelector).length > 0) {
  148. curBalEle = document.querySelector(balanceSelector).innerText;
  149. if(curBalEle != '') {
  150. if (curBalEle > oldBal) {
  151. var depositAmount = ((curBalEle - oldBal) * SAVE_AMOUNT);
  152. if (depositAmount >= 1e-8) {
  153. oldBal = (parseFloat(curBalEle) - parseFloat(depositAmount)).toFixed(8);
  154. stakeApi.depositToVault(activeCurrency, depositAmount).then((r) => r.json()).then((response) => {
  155. if (DISPLAY_VAULT_TOTAL) {
  156. try {
  157. let cvd = response.data.createVaultDeposit;
  158. let balanceObject = cvd.user.balances.find(x => x.vault.currency == cvd.currency);
  159. wing.update(balanceObject.vault.amount);
  160. } catch (err) {
  161. console.log('Error trying to read vault balance');
  162. wing.update(depositAmount);
  163. }
  164. } else {
  165. wing.update(depositAmount);
  166. }
  167. });
  168. }
  169. }
  170. }
  171. }
  172. }
  173. window.setInterval(checkBalance, 751); //timerspeed read send to tresor
  174. } else {
  175. tresor(); //if different balance run func tresor
  176. }
  177. }
  178. var myTimer = setTimeout(tresor, 5500);
  179. } else {
  180. setTimeout(init, 5000);
  181. }
  182. };
  183. init();
  184. })();