forked from Chromatically/Chro-MH
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMH - Sky Palace Slot Machine Tracker.js
100 lines (95 loc) · 4.11 KB
/
MH - Sky Palace Slot Machine Tracker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// ==UserScript==
// @name MH - Sky Palace Slot Machine Tracker
// @version 1.2
// @description Tracks Sky Palace Rolls
// @author Chromatical
// @match https://www.mousehuntgame.com/*
// @match https://apps.facebook.com/mousehunt/*
// @icon https://www.google.com/s2/favicons?domain=mousehuntgame.com
// @grant GM_xmlhttpRequest
// @require https://code.jquery.com/ui/1.12.1/jquery-ui.js
// @require https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js
// @connect self
// @connect script.google.com
// @connect script.googleusercontent.com
// @namespace https://greasyfork.org/users/748165
// ==/UserScript==
var debug = localStorage.getItem("Chro.sproll.debug") == 1? true : false;
$(document).ajaxComplete(function(event, jqxhr, settings){
var form = settings.data
success:{
if (form.includes("reroll_sky_palace")){
checkname();
parse(jqxhr.responseText);
}
}
})
function checkname(){
var randomName = localStorage.getItem("chro-sp-track");
if (randomName){
return;
} else {
randomName = makeid(6);
localStorage.setItem("chro-sp-track",randomName);
}
}
function parse(data){
var response = JSON.parse(data);
if (response.success == 1){
var board = response.adventure_board.sky_palace.island_mod_wheels;
var locked = Object.values(board.locked);
var values = Object.values(board.values);
var powerType = response.adventure_board.sky_palace.power_type.value;
var powerLock = response.adventure_board.sky_palace.power_type.is_locked;
var oculus = response.user.quests.QuestFloatingIslands.airship.oculus_level;
var randomName = localStorage.getItem("chro-sp-track");
const webAppUrl = 'https://script.google.com/macros/s/AKfycbx253Ma8UhqOgZi6DhkZQL1XVzAkn1abwhFPG72g9nuqzUN4YVA558w8WraKtGaGPrwbA/exec';
if (webAppUrl){
GM_xmlhttpRequest({
method: "POST",
url: webAppUrl,
data: JSON.stringify({
name : randomName,
oculus : oculus,
locked : locked,
values : values,
powertype : powerType,
powerlock : powerLock
}),
onload: function(response){
var div = document.createElement("div");
div.id = "sproll";
div.style.position = "fixed";
div.innerText = "Roll Data Submitted";
div.style.top = "10vh";
div.style.left = "35vw";
div.style.width = "140px";
div.style.height = "15px";
div.style.fontWeight = "bold";
div.style.backgroundColor = "lightgreen";
div.style.textAlign = "center";
div.style.padding = "13px 0";
div.style.border = "1px solid";
div.style.borderRadius = "10px";
div.style.zIndex = "9999";
document.body.appendChild(div);
$(div).fadeOut("slow");
if (debug) console.log("Sky Palace Rolls Data Submitted")
},
onerror: function(response){
if (debug) console.log("Sky Palace Rolls Data Submission Failed")
}
})
}
}
}
function makeid(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() *
charactersLength));
}
return result;
}