BetterFap - Fap Gauntlet

Fap Gauntlet for BetterFap

Від 28.04.2017. Дивіться остання версія.

  1. // ==UserScript==
  2. // @name BetterFap - Fap Gauntlet
  3. // @author Goog
  4. // @description Fap Gauntlet for BetterFap
  5. // @namespace http://reikitech.me/
  6. // @include https://test.betterfap.com/view/*
  7. // @include https://betterfap.com/view/*
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
  9. // @require http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js
  10. // @grant unsafeWindow
  11. // @version 0.0.1.80170419190753
  12. // ==/UserScript==
  13.  
  14. //WARNING: SPAGHETTI AHEAD
  15.  
  16. // ideas: time should be set to webm length, webm should repeat x times based on time, skip all nonimages/webms, fix shitty imgur and tumblr viewer embeds
  17.  
  18. // fuck the rules, here are some global vars
  19. var firstStart = true;
  20. var isPlaying = false;
  21. var currViewObj = null;
  22. var timeFapped = 0;
  23. var currFPS = 0;
  24. var denialMode = false;
  25. var dildoMode = false;
  26. var canCum = null;
  27. var currIntensity = null;
  28. var currDilInt = null;
  29. var currDilSpeed = null;
  30. var randTime = 1000;
  31. var changedNormally = null;
  32. var dildoStuff = [];
  33.  
  34. var intensities = [
  35. 'Deathgrip', //10
  36. 'Very Hard', //15
  37. 'Hard', //15
  38. 'Medium', //20
  39. 'Light', //15
  40. 'Very Light', //15
  41. 'Feather Light' //10
  42. ];
  43.  
  44. var dildoIntensities = [
  45. 'Rub outside',
  46. 'Prod',
  47. 'Just the tip',
  48. 'Normal Thrusts',
  49. 'Deep thrusts',
  50. 'All the way'
  51. ];
  52.  
  53. var dildoSpeed = [
  54. 'Slow',
  55. 'Moderate',
  56. 'Fast'
  57. ];
  58.  
  59. var fapsPerSec = [
  60. 0.5,
  61. 1,
  62. 2,
  63. 3,
  64. 4,
  65. 5
  66. ];
  67.  
  68. var context = new AudioContext();
  69. var o = context.createOscillator();
  70. o.type = "sawtooth";
  71. o.connect(context.destination);
  72. o.frequency.value = 0;
  73.  
  74. function getRandomInt(min, max) {
  75. return Math.floor(Math.random() * (max - min + 1)) + min;
  76. }
  77.  
  78. function getRandomFPS() {
  79. var rand = getRandomInt(0, 5);
  80. return fapsPerSec[rand];
  81. }
  82.  
  83. function getCumState() { // 1 in 10 chance to be allowed to cum
  84. if (getRandomInt(1, 10) == 1) {
  85. canCum = true;
  86. } else {
  87. canCum = false;
  88. }
  89. return canCum;
  90. }
  91.  
  92. function getCumText() {
  93. if (canCum == true) {
  94. cumText = "You can cum.";
  95. } else {
  96. cumText = "Do not cum.";
  97. }
  98. return cumText;
  99. }
  100.  
  101. // autistically defined percent chances for each intensity, no equal chances here (except for 4 of them)
  102.  
  103. function getRandomIntensity() {
  104. var rand = getRandomInt(1, 100);
  105. var x = 2000;
  106. if (rand <= 10) { // 10% for Feather Light
  107. x = 0;
  108. } else if (rand > 10 && rand <= 25) { // 15% for Very Light
  109. x = 1;
  110. } else if (rand > 25 && rand <= 40) { // 15% for Light
  111. x = 2;
  112. } else if (rand > 40 && rand <= 60) { // 20% for Medium
  113. x = 3;
  114. } else if (rand > 60 && rand <= 75) { // 15% for Hard
  115. x = 4;
  116. } else if (rand > 75 && rand <= 90) { // 15% for Very Hard
  117. x = 5;
  118. } else if (rand > 90) { // 10% for Deathgrip
  119. x = 6;
  120. }
  121.  
  122. return intensities[x];
  123. }
  124.  
  125. // made it get only multiples of 10, no more 33 seconds of fapping #trueautism
  126. function getRandTime(randFPS) {
  127. randTime = 30000;
  128.  
  129. if (randFPS == 0.5) {
  130. randTime = getRandomInt(1, 2) * 10;
  131. } else if (randFPS == 1) {
  132. randTime = getRandomInt(1, 3) * 10;
  133. } else if (randFPS == 2) {
  134. randTime = getRandomInt(1, 4) * 10;
  135. } else if (randFPS == 3) {
  136. randTime = getRandomInt(1, 5) * 10;
  137. } else if (randFPS == 4) {
  138. randTime = getRandomInt(1, 4) * 10;
  139. } else if (randFPS == 5) {
  140. randTime = getRandomInt(1, 2) * 10;
  141. }
  142.  
  143. return randTime;
  144. }
  145.  
  146. function getDildoSpeed() {
  147. var rand = getRandomInt(0,2);
  148. return dildoSpeed[rand];
  149. }
  150.  
  151. function getDildoIntensities() {
  152. var rand = getRandomInt(0,5);
  153. return dildoIntensities[rand];
  154. }
  155.  
  156. function getNewFapData() { // sets the next image's fap data
  157.  
  158. i = 0;
  159. currIntensity = getRandomIntensity();
  160. currFPS = getRandomFPS();
  161. randTime = getRandTime(currFPS) + 1;
  162. getCumState();
  163. currDilInt = getDildoIntensities();
  164. currDilSpeed = getDildoSpeed();
  165.  
  166. // it's fucking hard to maintain a feather-light touch four or five times a second, so let's not.
  167.  
  168. if ((currFPS == 5 || currFPS == 4) && currIntensity == 'Feather Light') {
  169. do {
  170. currIntensity = getRandomIntensity();
  171. currFPS = getRandomFPS();
  172. } while ((currFPS == 5 || currFPS == 4) && currIntensity == 'Feather Light');
  173. }
  174.  
  175. if (isPlaying) {
  176. o.frequency.value = currFPS;
  177. }
  178. }
  179.  
  180. function remakeDialog() {
  181.  
  182. $('#FapDialog').dialog('open');
  183.  
  184. document.querySelector('div[id="FapDialog"]').innerHTML = "Starting...";
  185.  
  186. if (remakeDialog.interval) {
  187. clearInterval(remakeDialog.interval);
  188. }
  189.  
  190. // set the first image's length, faps per sec, etc
  191.  
  192. i = 0;
  193. currIntensity = getRandomIntensity();
  194. currFPS = getRandomFPS();
  195. randTime = getRandTime(currFPS); // every randtime after this has +1 so that the numbers show as multiples of ten on the first stroke instead of 10x + 9 which was annoying my autism greatly
  196. getCumState();
  197. currDilInt = getDildoIntensities();
  198. currDilSpeed = getDildoSpeed();
  199.  
  200. // it's fucking hard to maintain a feather-light touch four or five times a second, so let's not.
  201.  
  202. if ((currFPS == 5 || currFPS == 4) && currIntensity == 'Feather Light') {
  203. do {
  204. currIntensity = getRandomIntensity();
  205. currFPS = getRandomFPS();
  206. } while ((currFPS == 5 || currFPS == 4) && currIntensity == 'Feather Light');
  207.  
  208. }
  209.  
  210. if (isPlaying) { // if the user has the audio helper enabled, change it to match current FPS
  211. o.frequency.value = currFPS;
  212. }
  213.  
  214. currViewObj = unsafeWindow.AppState.viewing;
  215.  
  216. remakeDialog.interval = setInterval(
  217. function oneSecTimer() {
  218.  
  219. if (denialMode === false && dildoMode === false) {
  220. document.querySelector('div[id="FapDialog"]').innerHTML = currIntensity + "<br />" + currFPS + "/sec, " + (randTime - i);
  221. } else if (denialMode === true && dildoMode === false) {
  222. document.querySelector('div[id="FapDialog"]').innerHTML = currIntensity + "<br />" + currFPS + "/sec, " + (randTime - i) + "<br />" + getCumText();
  223. } else if (denialMode === false && dildoMode === true) {
  224. document.querySelector('div[id="FapDialog"]').innerHTML = currDilInt + "<br />" + currDilSpeed + ", " + (randTime - i);
  225. } else if (denialMode === true && dildoMode === true) {
  226. document.querySelector('div[id="FapDialog"]').innerHTML = currDilInt + "<br />" + currDilSpeed + ", " + (randTime - i) + "<br />" + getCumText();
  227. }
  228. if (randTime - i <= 1) { // aka if the time ticked down normally to 0, go to next image and get new fap data
  229.  
  230. getNewFapData();
  231.  
  232. //****next image function****
  233.  
  234. var $ = unsafeWindow.jQuery;
  235.  
  236. window.top.postMessage({
  237. action: 'next',
  238. cr: $.cookie().cr
  239. }, window.top.location.protocol + window.top.location.host);
  240. setTimeout(function () {
  241. currViewObj = unsafeWindow.AppState.viewing;
  242. }, 1000);
  243.  
  244. //****
  245.  
  246. changedNormally = true;
  247.  
  248. } else if ((currViewObj != unsafeWindow.AppState.viewing) && !(changedNormally)) { // if the user skipped their current image (or hit backspace or the image changed literally at all)
  249.  
  250. currViewObj = unsafeWindow.AppState.viewing;
  251.  
  252. getNewFapData();
  253. }
  254.  
  255. i = i + 1;
  256. timeFapped = timeFapped + 1;
  257.  
  258. if (i > 2) {
  259. changedNormally = false;
  260. }
  261.  
  262. },
  263. 1000);
  264. }
  265.  
  266. setTimeout(function () { // thanks for not having a sleep function js //update: using GS's built in wait until document loaded @thing breaks jquery on the site, weird
  267.  
  268. $("body").append('<div id="FapDialog" style="font-size:400%; color: #00FF00">Press t to start!</div>');
  269.  
  270. //--- Activate the dialog.
  271.  
  272. $("#FapDialog").dialog({
  273. position: {
  274. my: "left top",
  275. at: "left top",
  276. of: window
  277. },
  278. modal: false,
  279. height: 400,
  280. width: 400,
  281. title: "Fap Gauntlet (click here to drag!) ----> ",
  282. zIndex: 83666 //-- This number doesn't need to get any higher.
  283.  
  284.  
  285. }).prev(".ui-dialog-titlebar").css("background", "rgba(0, 0, 0, 0.4)");
  286.  
  287. $("#FapDialog").dialog().prev(".ui-widget-header").css("font-size", "140%");
  288.  
  289. // keybinds cause I can't make a fucking button work to save my erection
  290. $(document).keypress(function (e) {
  291. if (e.which == 116 || e.keyCode == 116) {
  292. remakeDialog();
  293. }
  294. });
  295.  
  296. $('div#FapDialog').on('dialogclose', function (event) { // when close is pressed
  297. clearInterval(remakeDialog.interval);
  298. o.frequency.value = 0;
  299. alert("Stopping, press t to bring me back!");
  300. timeFapped = 0;
  301. });
  302.  
  303. $(document).keypress(function (e) { // if c pressed
  304. if ((e.which == 99 || e.keyCode == 99) && $('#FapDialog').is(':visible')) {
  305. o.frequency.value = 0;
  306. isPlaying = false;
  307. alert('You lasted ' + timeFapped + ' seconds!');
  308. clearInterval(remakeDialog.interval);
  309. timeFapped = 0;
  310. }
  311. });
  312.  
  313. $(document).keypress(function (e) { // if m pressed
  314. if (e.which == 109 || e.keyCode == 109) {
  315. o.frequency.value = 0;
  316. isPlaying = false;
  317. }
  318.  
  319. });
  320.  
  321. $(document).keypress(function (e) { // if n pressed
  322. if ((e.which == 110 || e.keyCode == 110) && $('#FapDialog').is(':visible') && isPlaying === false) {
  323. if (firstStart) {
  324. alert('Tempo helper enabled! Press m to mute!');
  325. o.start();
  326. firstStart = false;
  327. }
  328. o.frequency.value = currFPS;
  329. isPlaying = true;
  330. }
  331. });
  332.  
  333. $(document).keypress(function (e) { // if b pressed (b stands for bully)
  334. if (e.which == 98 || e.keyCode == 98) {
  335.  
  336. if (denialMode) {
  337. alert('Denial mode disabled!');
  338. denialMode = false;
  339. } else {
  340. alert('Denial mode enabled! There are now prompts regarding whether you are allowed to cum to any given image, if it says you can cum then you can! If it says you cant and you edge, hands off for the next two images!');
  341. denialMode = true;
  342. }
  343. }
  344. });
  345. $(document).keypress(function (e) { // if v pressed (v stands for me running out of appropriate keys)
  346. if (e.which == 118 || e.keyCode == 118) {
  347.  
  348. if (dildoMode) {
  349. alert('Dildo mode disabled!');
  350. dildoMode = false;
  351. } else {
  352. alert('Dildo mode disabled! ...Fag');
  353. dildoMode = true;
  354. }
  355. }
  356. });
  357.  
  358. }, 2000);