-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathuserscript.js
50 lines (45 loc) · 1.2 KB
/
userscript.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
// ==UserScript==
// @name $USERSCRIPT_NAME
// @namespace http://www.margonem.pl/
// @version 5.0.0
// @description Addon for the Nerthus game server in Margonem
// @author Kris Aphalon, Aldi
// @match https://nerthus.margonem.pl/
// @icon $USERSCRIPT_ICON_URL
// ==/UserScript==
(function () {
function start() {
const gameInterface = document.cookie
.split("; ")
.find((row) => row.startsWith("interface="))
?.split("=")[1];
if (!gameInterface) {
setTimeout(() => start(), 500);
return;
}
let src;
switch (gameInterface) {
case "ni": {
src = NI_VERSION_URL;
break;
}
case "si": {
src = SI_VERSION_URL;
break;
}
default: {
const errorMsg =
"Nerthus addon couldn't detect your interface. " +
"Try restarting your game or clearing cookies. " +
"If this error persists, submit a bug on Nerthus's forum.";
this.error?.(errorMsg);
console.error(errorMsg);
return;
}
}
const script = document.createElement("script");
script.src = src;
document.head.appendChild(script);
}
start();
})();