-
Notifications
You must be signed in to change notification settings - Fork 0
/
inject.js
165 lines (147 loc) · 5.29 KB
/
inject.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
let njaTitle = "OGame Ninja";
$(document).ready(function () {
let currentUrl = document.location.href;
let descriptionMeta = $("meta[name=description]").attr("content");
if (descriptionMeta.startsWith(njaTitle)) {
addViewportTag();
if (!window.matchMedia('(max-device-width: 576px)').matches) {
$("#logs > .data").css("overflow", "hidden");
return;
}
currentUrl = currentUrl.replace(/http[s]{0,1}:\/\/[^\/]+/, "");
if (currentUrl.match(/^\/$/)) {
startPage();
} else if (currentUrl.match(/^\/bots\/\d+$/)) {
botPage();
} else if (currentUrl.match(/^\/bots\/\d+\/brain$/)) {
brainPage();
} else if (currentUrl.match(/^\/bots\/\d+\/defender$/)) {
defenderPage();
} else if (currentUrl.match(/^\/bots\/\d+\/scanner$/)) {
scannerPage();
} else if (currentUrl.match(/^\/bots\/\d+\/hunter$/)) {
hunterPage();
} else if (currentUrl.match(/^\/bots\/\d+\/farmer(\?.*){0,1}$/)) {
farmerPage();
} else if (currentUrl.match(/^\/bots\/\d+\/phalanx(\?.*){0,1}$/)) {
phalanxPage();
} else if (currentUrl.match(/^\/bots\/\d+\/farmer\/sessions\/\d+(\?.*){0,1}$/)) {
farmerDetailPage();
} else if (currentUrl.match(/^\/bots\/\d+\/activities(\?.*){0,1}$/)) {
activitiesPage();
} else if (currentUrl.match(/^\/bots\/\d+\/logs(\?.*){0,1}$/)) {
logsPage();
} else if (currentUrl.match(/^\/bots\/\d+\/settings(\?.*){0,1}$/)) {
settingsPage();
} else if (currentUrl.match(/^\/bots\/\d+\/flights(\?.*){0,1}$/)) {
flightsPage();
} else if (currentUrl.match(/^\/bots\/\d+\/browser(\?.*){0,1}$/)) {
browserPage();
} else if (currentUrl.match(/^\/bots\/\d+\/expeditions(\?.*){0,1}$/)) {
expeditionsPage();
} else if (currentUrl.match(/^\/bots\/\d+\/messages(\/[^\/]+){0,1}(\?.*){0,1}$/)) {
messagesPage();
} else {
console.log(currentUrl);
}
}
});
function botPage() {
$("body").attr("id", "botpage");
$("body").addClass("botpage");
fixBotNavigation();
}
function brainPage() {
$("body").attr("id", "brainpage");
$("body").addClass("brainpage");
$("table").wrap("<div class=\"table-wrap\"></div>");
fixBotNavigation();
}
function defenderPage() {
$("body").attr("id", "defenderpage");
$("body").addClass("defenderpage");
$("table").wrap("<div class=\"table-wrap\"></div>");
fixBotNavigation();
}
function scannerPage() {
$("body").attr("id", "scannerpage");
$("body").addClass("scannerpage");
fixBotNavigation();
}
function hunterPage() {
$("body").attr("id", "hunterpage");
$("body").addClass("hunterpage");
$("table").wrap("<div class=\"table-wrap\"></div>");
fixBotNavigation();
}
function farmerPage() {
$("body").attr("id", "farmerpage");
$("body").addClass("farmerpage");
$("table").wrap("<div class=\"table-wrap\"></div>");
fixBotNavigation();
}
function phalanxPage() {
$("body").attr("id", "phalanxpage");
$("body").addClass("farmerpage");
fixBotNavigation();
}
function farmerDetailPage() {
$("body").attr("id", "farmerdetailpage");
$("body").addClass("farmerdetailpage");
$("table").wrap("<div class=\"table-wrap\"></div>");
fixBotNavigation();
}
function activitiesPage() {
$("body").attr("id", "activitiespage");
$("body").addClass("activitiespage");
$("table").wrap("<div class=\"table-wrap\"></div>");
fixBotNavigation();
}
function logsPage() {
$("body").attr("id", "logspage");
$("body").addClass("logspage");
fixBotNavigation();
}
function settingsPage() {
$("body").attr("id", "settingspage");
$("body").addClass("settingspage");
fixBotNavigation();
}
function flightsPage() {
$("body").attr("id", "flightspage");
$("body").addClass("flightspage");
$("table").wrap("<div class=\"table-wrap\"></div>");
$("div.table-wrap:nth-child(1) > table:nth-child(1)").attr("id", "flighttargets");
$("#flighttargets > tbody:nth-child(1) > tr:nth-child(3) > td:nth-child(1)").html("Geschw.");
fixBotNavigation();
}
function browserPage() {
$("body").attr("id", "browserpage");
$("body").addClass("browserpage");
}
function startPage() {
$("body").attr("id", "startpage");
}
function expeditionsPage() {
$("body").attr("id", "expeditionspage");
$("table").wrap("<div class=\"table-wrap\"></div>");
fixBotNavigation();
}
function messagesPage() {
$("body").attr("id", "messagespage");
$("table").wrap("<div class=\"table-wrap\"></div>");
fixBotNavigation();
}
function fixBotNavigation() {
let origHref = $("#app .row .list-group > a.active").attr("href");
$("#app .row .list-group > a:not(.active)").hide();
$("#app .row .list-group > a.active").attr("href", "javascript:void(0)");
$("#app .row .list-group > a.active").click(function () {
$("#app .row .list-group > a:not(.active)").show(function () {
$("#app .row .list-group > a.active").attr("href", origHref);
});
});
}
function addViewportTag() {
$('head').append('<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">');
}