Cheat

Like pb&j on a rainy day

目前為 2016-04-23 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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);
})();