CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
ProdigyPNP

CoCalc is a real-time collaborative commercial alternative to JupyterHub and Overleaf that provides Jupyter Notebooks, LaTeX documents, and SageMath.

GitHub Repository: ProdigyPNP/ProdigyMathGameHacking
Path: blob/master/PHEx/firefox/disableIntegrity.js
Views: 720
1
/**
2
* disableIntegrity.js
3
*
4
* Currently maintained by ProdigyPNP
5
* Original author: Prodigy-Hacking
6
* Contributors: hostedposted, gemsvido, Eris
7
* File has been updated for Firefox
8
*/
9
10
(async () => {
11
12
/** Get an item from the browser local storage. */
13
function get(key) {
14
return new Promise(resolve => {
15
browser.storage.local.get([key], result => {
16
resolve(result[key]);
17
});
18
});
19
}
20
21
/** Custom P-NP URL from popup.js */
22
const url = await get("url");
23
24
/** Use Custom P-NP URL. */
25
const checked = await get("checked");
26
27
/** P-NP URL to use. Code: (If url exists and checked is true, then use url. Else, get a domain from infinite zero.) */
28
const redirectorDomain = (url && checked) ? url : (await (await fetch("https://infinitezero.net/domain")).text()).valueOf();
29
30
31
32
33
/*-----------------------------------------------*
34
* *
35
* INJECT GAME.MIN.JS *
36
* *
37
------------------------------------------------*/
38
39
40
async function insertCode () {
41
try {
42
/** P-NP Loader. If you're using a custom URL, then you have the ?force attribute. */
43
const request = await (await fetch(`https://infinitezero.net/eval${(url && checked) ? "?force=" + url : ""}`)).text();
44
document.documentElement.setAttribute("onreset", `${request}\nSW.Load.decrementLoadSemaphore();`);
45
document.documentElement.dispatchEvent(new CustomEvent("reset"));
46
document.documentElement.removeAttribute("onreset");
47
} catch (e) {
48
alert("Failed to load the hacks. Error:\n" + e.message);
49
}
50
}
51
52
if (!window.scriptIsInjected) {
53
54
55
insertCode().catch((err) => {
56
swal.fire({
57
title: "Could not insert gamemin",
58
html: err,
59
icon: "error"
60
});
61
});
62
63
64
65
66
67
/*-----------------------------------------------*
68
* *
69
* LATEST PHEx VERSION *
70
* *
71
------------------------------------------------*/
72
73
74
/** User's version of PHEx */
75
const pluginVersion = browser.runtime.getManifest().version;
76
77
/** Latest version of PHEx. */
78
const supportedVersion = (await (await fetch(`${redirectorDomain}/version`)).text());
79
80
81
/** Checks for plugin version. If outdated, triggers dialog box */
82
if (pluginVersion !== supportedVersion) {
83
const res = confirm(`PHEx is outdated. If you experience any errors, please update.\n\Your Version: ${pluginVersion}\nLatest Version: ${supportedVersion}`);
84
if (res) location = "https://github.com/ProdigyPNP/ProdigyMathGameHacking/blob/master/meta/wiki/UPDATING.md";
85
}
86
87
88
89
90
91
/*-----------------------------------------------*
92
* *
93
* DISABLE INTEGRITY *
94
* *
95
------------------------------------------------*/
96
97
98
/** Remove integrity attributes from scripts and links. */
99
console.groupCollapsed("[PHEx] integrity patches");
100
[...document.getElementsByTagName("script"), ...document.getElementsByTagName("link")].forEach(element => {
101
if (element.hasAttribute("integrity")) {
102
console.log("[PHEx] " + element.getAttribute("integrity"));
103
element.removeAttribute("integrity");
104
}
105
});
106
console.groupEnd("[PHEx] integrity patches");
107
/** End disable integrity */
108
109
110
111
112
/** Script is now injected. */
113
window.scriptIsInjected = true;
114
}
115
})();
116
117