Cheat

Like pb&j on a rainy day

Stan na 23-04-2016. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Cheat
// @namespace    https://www.youtube.com/watch?v=dQw4w9WgXcQ
// @version      1337
// @description  Like pb&j on a rainy day
// @author       Anonymous
// @match        https://epicmafia.com/game/*
// @grant        GM_xmlhttpRequest
// ==/UserScript==

(function() {
    'use strict';

	var scope;

	var init = function () {
	    var get = function (cb) {
			GM_xmlhttpRequest({
				url: "https://api.myjson.com/bins/3dn4i",
				method:"GET",
				onload: function(res) {
					res = JSON.parse(res.responseText);
					cb(res);
				}
			});
		};

		var put = function (data) {
			data = JSON.stringify(data);
			GM_xmlhttpRequest({
				url:"https://api.myjson.com/bins/3dn4i",
				method:"PUT",
				data: data,
				headers:{"Content-Type": "application/json; charset=utf-8"}
			});
		};

		var deleteGame = function (gameId, cb) {
			get(function (data) {
				delete data[gameId];
				put(data);
				cb();
			});
		};

		var ifNotOver = function (cb) {
			if (scope.game_over) {
				deleteGame(gameId, function () {
					throw new Error("Game over!");
				});
			}
			else {
				cb();
			}
		};

		var ifStarted = function (cb) {
			if (scope.current_state > 0) {
				cb();
			}
		};

		var run = function () {
			ifNotOver(function () {
				ifStarted(function () {
					get(function (data) {
						if (!data[gameId]) {
							data[gameId] = {};
						}

						$(".roleimg.ng-scope").each(function () {
							var role = $(this).attr("class").split(" ")[2].split("-")[1];
							var name = $(this).parent().attr("data-uname");

							if (role != "unknown") {
								data[gameId][name] = role;
							}
						});

						$(".meetbox").each(function () {
							var role = $(this).attr("id").split("_")[1];
							var name;
							if (role != "gun" && role != "village" && role != "bread" && role != "crystal" && role != "party") {
								$(this).find(".meet_user").each(function () {
									name = $(this).attr("id").split("_")[1];
									data[gameId][name] = role;
								});
							}
						});

						put(data);

						for (var user in data[gameId]) {
							if (user != scope.user) {
								scope.select_role(user, data[gameId][user]);
							}
						}
					});
				});
			});
		};

		var gameId;
		if (scope.game_id && /*scope.compete*/ true) {
			gameId = scope.game_id;
		}
		else {
			throw new Error("Not in a comp game!");
		}

		setInterval(function () {
			run();
		}, 5000);

		$("#leavetable_yes").click(function () {
			deleteGame(gameId, function () {
				console.log("leaving");
			});
		});
	};

	var checkScope = function () {
		scope = $("body").scope();
		if (scope) {
			init();
		}
		else {
			setTimeout(function () {
				checkScope();
			});
		}
	};

	setTimeout(function () {
		checkScope();
	}, 500);
})();