BetterFap - Fap Gauntlet

Fap Gauntlet for BetterFap

Fra 28.04.2017. Se den seneste versjonen.

// ==UserScript==
// @name        BetterFap - Fap Gauntlet
// @author      Goog
// @description Fap Gauntlet for BetterFap
// @namespace   http://reikitech.me/
// @include     https://test.betterfap.com/view/*
// @include     https://betterfap.com/view/*
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require     http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js
// @grant       unsafeWindow
// @version 0.0.1.80170419190753
// ==/UserScript==

//WARNING: SPAGHETTI AHEAD

// 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

// fuck the rules, here are some global vars
var firstStart = true;
var isPlaying = false;
var currViewObj = null;
var timeFapped = 0;
var currFPS = 0;
var denialMode = false;
var dildoMode = false;
var canCum = null;
var currIntensity = null;
var currDilInt = null;
var currDilSpeed = null;
var randTime = 1000;
var changedNormally = null;
var dildoStuff = [];

var intensities = [
	'Deathgrip', //10
	'Very Hard', //15
	'Hard', //15
	'Medium', //20
	'Light', //15
	'Very Light', //15
	'Feather Light' //10
];

var dildoIntensities = [
	'Rub outside',
	'Prod',
	'Just the tip',
	'Normal Thrusts',
	'Deep thrusts',
	'All the way'
];

var dildoSpeed = [
	'Slow',
	'Moderate',
	'Fast'
];

var fapsPerSec = [
	0.5,
	1,
	2,
	3,
	4,
	5
];

var context = new AudioContext();
var o = context.createOscillator();
o.type = "sawtooth";
o.connect(context.destination);
o.frequency.value = 0;

function getRandomInt(min, max) {
	return Math.floor(Math.random() * (max - min + 1)) + min;
}

function getRandomFPS() {
	var rand = getRandomInt(0, 5);
	return fapsPerSec[rand];
}

function getCumState() { // 1 in 10 chance to be allowed to cum
	if (getRandomInt(1, 10) == 1) {
		canCum = true;
	} else {
		canCum = false;
	}
	return canCum;
}

function getCumText() {
	if (canCum == true) {
		cumText = "You can cum.";
	} else {
		cumText = "Do not cum.";
	}
	return cumText;
}

// autistically defined percent chances for each intensity, no equal chances here (except for 4 of them)

function getRandomIntensity() {
	var rand = getRandomInt(1, 100);
	var x = 2000;
	if (rand <= 10) { // 10% for Feather Light
		x = 0;
	} else if (rand > 10 && rand <= 25) { // 15% for Very Light
		x = 1;
	} else if (rand > 25 && rand <= 40) { // 15% for Light
		x = 2;
	} else if (rand > 40 && rand <= 60) { // 20% for Medium
		x = 3;
	} else if (rand > 60 && rand <= 75) { // 15% for Hard
		x = 4;
	} else if (rand > 75 && rand <= 90) { // 15% for Very Hard
		x = 5;
	} else if (rand > 90) { // 10% for Deathgrip
		x = 6;
	}

	return intensities[x];
}

// made it get only multiples of 10, no more 33 seconds of fapping #trueautism
function getRandTime(randFPS) {
	randTime = 30000;

	if (randFPS == 0.5) {
		randTime = getRandomInt(1, 2) * 10;
	} else if (randFPS == 1) {
		randTime = getRandomInt(1, 3) * 10;
	} else if (randFPS == 2) {
		randTime = getRandomInt(1, 4) * 10;
	} else if (randFPS == 3) {
		randTime = getRandomInt(1, 5) * 10;
	} else if (randFPS == 4) {
		randTime = getRandomInt(1, 4) * 10;
	} else if (randFPS == 5) {
		randTime = getRandomInt(1, 2) * 10;
	}

	return randTime;
}

function getDildoSpeed() {
	var rand = getRandomInt(0,2);
	return dildoSpeed[rand];
}

function getDildoIntensities() {
	var rand = getRandomInt(0,5);
	return dildoIntensities[rand];
}

function getNewFapData() { // sets the next image's fap data

	i = 0;
	currIntensity = getRandomIntensity();
	currFPS = getRandomFPS();
	randTime = getRandTime(currFPS) + 1;
	getCumState();
	currDilInt = getDildoIntensities();
	currDilSpeed = getDildoSpeed();

	// it's fucking hard to maintain a feather-light touch four or five times a second, so let's not.

	if ((currFPS == 5 || currFPS == 4) && currIntensity == 'Feather Light') {
		do {
			currIntensity = getRandomIntensity();
			currFPS = getRandomFPS();
		} while ((currFPS == 5 || currFPS == 4) && currIntensity == 'Feather Light');
	}

	if (isPlaying) {
		o.frequency.value = currFPS;
	}
}

function remakeDialog() {

	$('#FapDialog').dialog('open');

	document.querySelector('div[id="FapDialog"]').innerHTML = "Starting...";

	if (remakeDialog.interval) {
		clearInterval(remakeDialog.interval);
	}

	// set the first image's length, faps per sec, etc

	i = 0;
	currIntensity = getRandomIntensity();
	currFPS = getRandomFPS();
	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
	getCumState();
	currDilInt = getDildoIntensities();
	currDilSpeed = getDildoSpeed();

	// it's fucking hard to maintain a feather-light touch four or five times a second, so let's not.

	if ((currFPS == 5 || currFPS == 4) && currIntensity == 'Feather Light') {
		do {
			currIntensity = getRandomIntensity();
			currFPS = getRandomFPS();
		} while ((currFPS == 5 || currFPS == 4) && currIntensity == 'Feather Light');

	}

	if (isPlaying) { // if the user has the audio helper enabled, change it to match current FPS
		o.frequency.value = currFPS;
	}

	currViewObj = unsafeWindow.AppState.viewing;

	remakeDialog.interval = setInterval(
			function oneSecTimer() {

			if (denialMode === false && dildoMode === false) {
				document.querySelector('div[id="FapDialog"]').innerHTML = currIntensity + "<br />" + currFPS + "/sec, " + (randTime - i);
			} else if (denialMode === true && dildoMode === false) {
				document.querySelector('div[id="FapDialog"]').innerHTML = currIntensity + "<br />" + currFPS + "/sec, " + (randTime - i) + "<br />" + getCumText();
			} else if (denialMode === false && dildoMode === true) {
				document.querySelector('div[id="FapDialog"]').innerHTML = currDilInt + "<br />" + currDilSpeed + ", " + (randTime - i);
			} else if (denialMode === true && dildoMode === true) {
				document.querySelector('div[id="FapDialog"]').innerHTML = currDilInt + "<br />" + currDilSpeed + ", " + (randTime - i) + "<br />" + getCumText();
			} 
			if (randTime - i <= 1) { // aka if the time ticked down normally to 0, go to next image and get new fap data

				getNewFapData();

				//****next image function****

				var $ = unsafeWindow.jQuery;

				window.top.postMessage({
					action: 'next',
					cr: $.cookie().cr
				}, window.top.location.protocol + window.top.location.host);
				setTimeout(function () {
					currViewObj = unsafeWindow.AppState.viewing;
				}, 1000);

				//****

				changedNormally = true;

			} else if ((currViewObj != unsafeWindow.AppState.viewing) && !(changedNormally)) { // if the user skipped their current image (or hit backspace or the image changed literally at all)

				currViewObj = unsafeWindow.AppState.viewing;

				getNewFapData();
			}

			i = i + 1;
			timeFapped = timeFapped + 1;

			if (i > 2) {
				changedNormally = false;
			}

		},
			1000);
}

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

	$("body").append('<div id="FapDialog" style="font-size:400%; color: #00FF00">Press t to start!</div>');

	//--- Activate the dialog.

	$("#FapDialog").dialog({
		position: {
			my: "left top",
			at: "left top",
			of: window
		},
		modal: false,
		height: 400,
		width: 400,
		title: "Fap Gauntlet (click here to drag!) ----> ",
		zIndex: 83666 //-- This number doesn't need to get any higher.


	}).prev(".ui-dialog-titlebar").css("background", "rgba(0, 0, 0, 0.4)");

	$("#FapDialog").dialog().prev(".ui-widget-header").css("font-size", "140%");

	// keybinds cause I can't make a fucking button work to save my erection
	
	$(document).keypress(function (e) {
		if (e.which == 116 || e.keyCode == 116) {
			remakeDialog();
		}
	});

	$('div#FapDialog').on('dialogclose', function (event) { // when close is pressed
		clearInterval(remakeDialog.interval);
		o.frequency.value = 0;
		alert("Stopping, press t to bring me back!");
		timeFapped = 0;
	});

	$(document).keypress(function (e) { // if c pressed
		if ((e.which == 99 || e.keyCode == 99) && $('#FapDialog').is(':visible')) {
			o.frequency.value = 0;
			isPlaying = false;
			alert('You lasted ' + timeFapped + ' seconds!');
			clearInterval(remakeDialog.interval);
			timeFapped = 0;
		}
	});

	$(document).keypress(function (e) { // if m pressed
		if (e.which == 109 || e.keyCode == 109) {
			o.frequency.value = 0;
			isPlaying = false;
		}

	});

	$(document).keypress(function (e) { // if n pressed
		if ((e.which == 110 || e.keyCode == 110) && $('#FapDialog').is(':visible') && isPlaying === false) {
			if (firstStart) {
				alert('Tempo helper enabled! Press m to mute!');
				o.start();
				firstStart = false;
			}
			o.frequency.value = currFPS;
			isPlaying = true;
		}
	});

	$(document).keypress(function (e) { // if b pressed (b stands for bully)
		if (e.which == 98 || e.keyCode == 98) {

			if (denialMode) {
				alert('Denial mode disabled!');
				denialMode = false;
			} else {
				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!');
				denialMode = true;
			}
		}
	});
	
	$(document).keypress(function (e) { // if v pressed (v stands for me running out of appropriate keys)
		if (e.which == 118 || e.keyCode == 118) {

			if (dildoMode) {
				alert('Dildo mode disabled!');
				dildoMode = false;
			} else {
				alert('Dildo mode disabled! ...Fag');
				dildoMode = true;
			}
		}
	});

}, 2000);