Skip to content

Commit cef7f32

Browse files
committed
Make PHEx compatible with opera webstore?
1 parent 0634d60 commit cef7f32

File tree

9 files changed

+50
-21
lines changed

9 files changed

+50
-21
lines changed

PHEx/build/extension.crx

24.1 KB
Binary file not shown.

PHEx/build/extension.xpi

24.8 KB
Binary file not shown.

PHEx/build/extension.zip

24.8 KB
Binary file not shown.

PHEx/src/background.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ browser.webRequest.onBeforeRequest.addListener(async details => {
3232
if (details.url.startsWith("https://code.prodigygame.com/code/") && details.url.includes("/game.min.js")) {
3333
fetch("https://raw.githubusercontent.com/ProdigyPNP/ProdigyMathGameHacking/master/PHEx/status.json").then(response => response.json()).then(async data => {
3434
if (data.offline == true) {
35-
eval(await (await fetch("https://unpkg.com/sweetalert2")).text())
35+
3636
if (swal) {
3737
swal.fire({
3838
title: "Oh no!",

PHEx/src/disableIntegrity.js

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
(async () => {
2+
3+
/** Get an item from the chrome local storage. */
24
function get(key) {
35
return new Promise(resolve => {
46
chrome.storage.local.get([key], result => {
@@ -7,37 +9,47 @@
79
});
810
}
911

12+
/** Custom P-NP URL from popup.js */
13+
const url = await get("url");
1014

15+
/** Use Custom P-NP URL. */
16+
const checked = await get("checked");
1117

12-
if (!window.scriptIsInjected) {
13-
// get options from local
14-
const url = await get("url");
15-
const checked = await get("checked");
16-
const redirectorDomain = (url && checked) ? url : "https://infinitezero.net/eval";
17-
18+
/** P-NP URL to use. Code: (If url exists and checked is true, then use url. Else, get a domain from infinite zero.) */
19+
const redirectorDomain = (url && checked) ? url : (await (await fetch("https://infinitezero.net/domain")).text()).valueOf();
1820

21+
/** The hash for game.min.js */
22+
const hash = "sha256-" + (await (await fetch(`${redirectorDomain}/hash?updated=${Date.now()}`)).text()).valueOf();
23+
1924

20-
21-
window.scriptIsInjected = true;
25+
if (!window.scriptIsInjected) {
26+
27+
28+
var rs4 = new String().valueOf();
2229

2330
function redirectorCheck() {
31+
2432
fetch(`${redirectorDomain}/game.min.js?updated=${Date.now()}`)
2533
.then(res => res.text())
2634
.then(response => {
35+
36+
rs4 = response;
2737
console.log("[PHEx] Connection to server was Successful!");
2838
console.log(redirectorDomain);
2939

3040
// <script src="https://code.prodigygame.com/code/3-13-0/game.min.js?v=3-13-0" onload="SW.Load.onGameLoad();" crossorigin="anonymous"></script>
3141
// we cancel the real game.min, and just append ours
3242
// a messy solution for sure, but this should only be a bandaid on a bulletwound
3343
const injectedScript = document.createElement("script");
34-
injectedScript.innerHTML = response;
44+
45+
46+
47+
injectedScript.innerHTML = new String(rs4.valueOf());
3548

3649
document.body.append(injectedScript);
3750
})
3851
.catch(async (error) => {
3952
// If fetch spits out error, trigger dialog box
40-
eval(await (await fetch('https://unpkg.com/sweetalert2')).text());
4153
if (swal) {
4254
swal.fire({
4355
title: "Oh no!",
@@ -50,25 +62,38 @@
5062
}
5163
});
5264
}
65+
66+
/** Run the redirectorCheck() function with a 1-second delay. */
5367
setTimeout(redirectorCheck, 1000);
5468

69+
/** User's version of PHEx */
5570
const pluginVersion = chrome.runtime.getManifest().version;
71+
72+
/** Latest version of PHEx. */
5673
const supportedVersion = (await (await fetch(`${redirectorDomain}/version`)).text());
57-
// Checks for plugin version. If outdated, triggers dialog box.
74+
75+
76+
/** Checks for plugin version. If outdated, triggers dialog box */
5877
if (pluginVersion !== supportedVersion) {
59-
const res = confirm("PHEx is outdated. If you experience any errors, please update.");
78+
const res = confirm(`PHEx is outdated. If you experience any errors, please update.\n\Your Version: ${pluginVersion}\nLatest Version: ${supportedVersion}`);
6079

6180
if (res) location = "https://github.com/ProdigyPNP/ProdigyMathGameHacking/blob/master/meta/wiki/UPDATING.md";
6281
}
6382

64-
// Disable integrity
83+
84+
/** Remove integrity attributes from scripts and links. */
6585
console.groupCollapsed("[PHEx] integrity patches");
66-
[...document.getElementsByTagName("script"), ...document.getElementsByTagName("link")].forEach(v => {
67-
if (v.integrity) {
68-
console.log("[PHEx] " + v.integrity);
69-
v.removeAttribute("integrity");
86+
[...document.getElementsByTagName("script"), ...document.getElementsByTagName("link")].forEach(element => {
87+
if (element.hasAttribute("integrity")) {
88+
console.log("[PHEx] " + element.getAttribute("integrity"));
89+
element.removeAttribute("integrity");
7090
}
7191
});
7292
console.groupEnd("[PHEx] integrity patches");
93+
/** End disable integrity */
94+
95+
96+
/** Script is now injected. */
97+
window.scriptIsInjected = true;
7398
}
7499
})();

PHEx/src/manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Prodigy Hacking Extension | PHEx",
3-
"version": "2.2.0",
3+
"version": "2.2.1",
44
"description": "Free and open source hacks for Prodigy Math Game",
55
"permissions": [
66
"webRequest",
@@ -16,12 +16,12 @@
1616
"128": "assets/x128.png"
1717
},
1818
"background": {
19-
"scripts": ["background.js"],
19+
"scripts": ["background.js", "swal/sweetalert2.all.min.js"],
2020
"persistent": true
2121
},
2222
"content_scripts": [{
2323
"matches": ["https://math.prodigygame.com/*"],
24-
"js": ["disableIntegrity.js"]
24+
"js": ["disableIntegrity.js", "swal/sweetalert2.all.min.js"]
2525
}],
2626
"browser_action": {
2727
"default_popup": "popup.html"

PHEx/src/swal/SOURCE.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/sweetalert2/sweetalert2

PHEx/src/swal/sweetalert2.all.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PHEx/src/swal/sweetalert2.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)