S.P.N.A.T.I.

spnati

  1. // ==UserScript==
  2. // @name S.P.N.A.T.I.
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.0.1
  5. // @description spnati
  6. // @author Exotik
  7. // @match https://faraway-vision.io/
  8. // @icon https://www.google.com/s2/favicons?domain=faraway-vision.io
  9. // @grant GM_addStyle
  10. // ==/UserScript==
  11.  
  12. function createButton(id, text, onClick)
  13. {
  14. var btn = document.createElement ('div');
  15. btn.innerHTML = '<button id="' + id + '" type="button">' + text + '</button>';
  16. btn.setAttribute ('id', 'buttons');
  17. document.body.appendChild(btn);
  18. document.getElementById (id).addEventListener (
  19. "click", onClick, false
  20. );
  21. }
  22.  
  23. createButton("stripPlayer1", "Strip player 1", stripPlayer1);
  24. createButton("stripPlayer2", "Strip player 2", stripPlayer2);
  25. createButton("stripPlayer3", "Strip player 3", stripPlayer3);
  26. createButton("stripPlayer4", "Strip player 4", stripPlayer4);
  27. createButton("stripAll", "Strip all", stripAll);
  28. createButton("stripAllNakedBtn", "Strip all naked", ButtonStripAllNaked);
  29. createButton("masturbatePlayer1", "Masturbate player 1", masturbatePlayer1);
  30. createButton("masturbatePlayer2", "Masturbate player 2", masturbatePlayer2);
  31. createButton("masturbatePlayer3", "Masturbate player 3", masturbatePlayer3);
  32. createButton("masturbatePlayer4", "Masturbate player 4", masturbatePlayer4);
  33. createButton("masturbateAll", "Masturbate all", masturbateAll);
  34. createButton("unlockAllEndings", "Unlock all endings", unlockAllEndings);
  35. createButton("randomBackgorund", "Random background", randomBackground);
  36.  
  37.  
  38. function stripAll() {stripAllOnce();}
  39. function stripPlayer1() {stripPlayer(1);}
  40. function stripPlayer2() {stripPlayer(2);}
  41. function stripPlayer3() {stripPlayer(3);}
  42. function stripPlayer4() {stripPlayer(4);}
  43. function masturbatePlayer1() {startMasturbation(1);}
  44. function masturbatePlayer2() {startMasturbation(2);}
  45. function masturbatePlayer3() {startMasturbation(3);}
  46. function masturbatePlayer4() {startMasturbation(4);}
  47. function masturbateAll() {masturbateAllPlayers();}
  48. function ButtonStripAllNaked()
  49. {
  50. ButtonClickAction("stripAllNaked");
  51. }
  52.  
  53. function ButtonClickAction (type) {
  54. switch(type)
  55. {
  56. case "stripAllNaked":
  57. stripAllNaked();
  58. }
  59. }
  60.  
  61. //--- Style our newly added elements using CSS.
  62. GM_addStyle ( `
  63. #myContainer {
  64. position: absolute;
  65. top: 0;
  66. left: 0;
  67. font-size: 20px;
  68. background: orange;
  69. border: 3px outset black;
  70. margin: 5px;
  71. opacity: 0.9;
  72. z-index: 1100;
  73. padding: 5px 20px;
  74. }
  75. #myButton {
  76. cursor: pointer;
  77. }
  78. #myContainer p {
  79. color: red;
  80. background: white;
  81. }
  82. ` );
  83. function stripAllNaked(){
  84. /*Strip everyone (except the PC) naked such that one round is left before they lose.*/
  85. stripAllToLevel(1);
  86. }
  87.  
  88. function stripAllOnce()
  89. {
  90. for (var i = 1; i < players.length; i++)
  91. {
  92. try { stripPlayer(i); } catch {}
  93. }
  94. }
  95.  
  96. function masturbateAllPlayers()
  97. {
  98. for (var i = 1; i < players.length; i++)
  99. {
  100. try { startMasturbation(i); } catch {}
  101. }
  102. }
  103.  
  104. function stripNaked(player){
  105. /*Strip all layers off of a given player (0 is the PC, 1-4 are NPCs).
  106. Params: player - Integer (0 is the PC, 1-4 are NPCs)
  107. */
  108. try { stripToLevel(player, 1); } catch {}
  109. }
  110.  
  111. function autoWin(){
  112. /*Automatically win.*/
  113. try { stripAllToLevel(0); } catch {}
  114. }
  115.  
  116. function stripAllToLevel(level){
  117. /*Strip all players (except the PC) down so that they have at most _level_ number of layers left.
  118. Params: level - Integer (The number of layers to leave left on a player.)
  119. */
  120. for(var i = 1; i < players.length; i++){
  121. try { stripToLevel(i, level); } catch {}
  122. }
  123. }
  124.  
  125. function stripToLevel(player, level){
  126. /*Strip a player down such that they only have (at most) a certain number of layers left.
  127. Params: player - Integer (0 is the PC, 1-4 are NPCs)
  128. level - Integer (The number of layers to leave left on a player.)
  129. */
  130. for (var c = countClothing(player); c >= level; c--){
  131. try { stripChoice(player); } catch {}
  132. }
  133. }
  134.  
  135. function countClothing(player){
  136. /* Count the clothing the player has remaining.
  137. Params: Player - integer (0 is the PC, 1-4 are NPCs)
  138. */
  139. var clothes = 0;
  140. for (var i = 0; i < players[player].clothing.length; i++) {
  141. if (players[player] && players[player].clothing[i]) {
  142. clothes++;
  143. }
  144. }
  145. return clothes;
  146. }
  147.  
  148. function multiStripChoice(player, times){
  149. /* Strip the indicated player of multiple layer.
  150. Params: Player - integer (0 is the PC, 1-4 are NPCs)
  151. times - integer (The number of layers to try to strip.)
  152. */
  153. for(var i = 0; (i < times) && (countClothing(player) != -1); i++){
  154. try { stripChoice(player); } catch {}
  155. }
  156. }
  157.  
  158. function stripChoice(player){
  159. /* Strip the indicated player of a single layer.
  160. Params: Player - integer (0 is the PC, 1-4 are NPCs)
  161. */
  162. try { stripPlayer(player); } catch {}
  163. try { updateAllGameVisuals(); } catch {}
  164. }
  165.  
  166. function randomBackground(){
  167. /*
  168. Choose a random background from those available.
  169. */
  170. //Note this randint helper function could either be inlined or broken out into an actual function.
  171. var randint = function(a,b){
  172. return (function(n,x){
  173. return Math.floor(Math.random()*(x-n)+n);
  174. })(Math.min(a,b), Math.max(a,b));
  175. };
  176. setBackground(function(){var a = randint(0,23); console.log(a); return a;}());
  177. }
  178.  
  179. function unlockAllEndings(){
  180. /*
  181. Unlocks all the endings in the gallery mode.
  182. NOTE: You can access the gallery by using the
  183. command "loadGalleryScreen()" from the main menu.
  184. */
  185. for(var i = 0; i < galleryEndings.length; i++)
  186. {
  187. try { galleryEndings[i].unlocked = true; } catch {}
  188. }
  189. }