Cheat

Like pb&j on a rainy day

当前为 2016-04-23 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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);
})();