-
Notifications
You must be signed in to change notification settings - Fork 168
/
frozen_cookies.js
98 lines (93 loc) · 3.61 KB
/
frozen_cookies.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
// Global Variables
var lastCompatibleVersion = 2.031;
if (Game.version > lastCompatibleVersion) {
console.log(
"WARNING: The Cookie Clicker version is newer than this version of Frozen Cookies."
);
console.log(
"This version of Frozen Cookies has only been tested through Cookie Clicker version " +
lastCompatibleVersion
);
console.log(
"There may be incompatibilities, undesirable effects, bugs, shifts in reality, immoral behavior, and who knows what else."
);
}
var scriptElement =
document.getElementById("frozenCookieScript") !== null
? document.getElementById("frozenCookieScript")
: document.getElementById("modscript_frozen_cookies");
var baseUrl = scriptElement !== null
? scriptElement.getAttribute("src").replace(/\/frozen_cookies\.js$/, "")
: "https://icehawk78.github.io/FrozenCookies/";
var FrozenCookies = {
baseUrl: baseUrl,
branch: "Main-",
version: "2.0.0",
};
// Load external libraries
var script_list = [
"https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js",
"https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css",
"https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js",
"https://cdnjs.cloudflare.com/ajax/libs/jcanvas/20.1.1/min/jcanvas.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/jquery.jqplot.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/jquery.jqplot.min.css",
"https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.canvasTextRenderer.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.canvasAxisLabelRenderer.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.canvasAxisTickRenderer.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.trendline.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.highlighter.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.logAxisRenderer.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/jqPlot/1.0.9/plugins/jqplot.cursor.min.js",
FrozenCookies.baseUrl + "/fc_preferences.js",
FrozenCookies.baseUrl + "/cc_upgrade_prerequisites.js",
FrozenCookies.baseUrl + "/fc_main.js",
FrozenCookies.baseUrl + "/fc_button.js",
FrozenCookies.baseUrl + "/fc_spellpredict.js",
FrozenCookies.baseUrl + "/fc_infobox.js",
];
FrozenCookies.loadInterval = setInterval(function () {
if (Game && Game.ready) {
clearInterval(FrozenCookies.loadInterval);
FrozenCookies.loadInterval = 0;
fcInit();
}
}, 1000);
function loadScript(id) {
if (id >= script_list.length) {
registerMod("frozen_cookies"); // when the mod is registered, the save data is passed in the load function
} else {
var url = script_list[id];
if (/\.js$/.exec(url)) {
$.getScript(url, function () {
loadScript(id + 1);
});
} else if (/\.css$/.exec(url)) {
$("<link>")
.attr({
rel: "stylesheet",
type: "text/css",
href: url,
})
.appendTo($("head"));
loadScript(id + 1);
} else {
console.log("Error loading script: " + url);
loadScript(id + 1);
}
}
}
function fcInit() {
var jquery = document.createElement("script");
jquery.setAttribute("type", "text/javascript");
jquery.setAttribute("src", "https://code.jquery.com/jquery-3.6.0.min.js");
jquery.setAttribute(
"integrity",
"sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
);
jquery.setAttribute("crossorigin", "anonymous");
jquery.onload = function () {
loadScript(0);
};
document.head.appendChild(jquery);
}