CoCalc is a real-time collaborative commercial alternative to JupyterHub and Overleaf that provides Jupyter Notebooks, LaTeX documents, and SageMath.
CoCalc is a real-time collaborative commercial alternative to JupyterHub and Overleaf that provides Jupyter Notebooks, LaTeX documents, and SageMath.
Path: blob/master/PHEx/firefox/background.js
Views: 720
/**1* background.js2*3* modified by gemsvidø for firefox support4*/5678/** CSP and X-Frame headers */9const HEADERS_TO_STRIP_LOWERCASE = [10"content-security-policy",11"x-frame-options",12];1314// Remove CSP and X-Frame headers on all Prodigy domains15browser.webRequest.onHeadersReceived.addListener(16details => ({17responseHeaders: details.responseHeaders.filter(header => !HEADERS_TO_STRIP_LOWERCASE.includes(header.name.toLowerCase()))18}),19{ urls: ["*://*.prodigygame.com/*"] },20["blocking", "responseHeaders"]21);22232425262728/** Set a value in the local storage */29function set(key, value) {30browser.storage.local.set({ [key]: value });31};3233/** Get a value from the local storage */34function get(key) {35return new Promise(resolve => {36browser.storage.local.get([key], result => {37resolve(result[key]);38})39})40};41424344// Redirect Requests45browser.webRequest.onBeforeRequest.addListener(async details => {4647/** Custom P-NP URL */48const url = await get("url");4950/** Use custom URL */51const checked = await get("checked");5253/** P-NP URL to be used */54const redirectorDomain = (url && checked) ? url : await (await fetch("https://infinitezero.net/domain")).text();555657// If hacks are offline, show an alert58if (details.url.startsWith("https://code.prodigygame.com/code/") && details.url.includes("/game.min.js")) {59fetch("https://raw.githubusercontent.com/ProdigyPNP/ProdigyMathGameHacking/master/PHEx/status.json").then(response => response.json()).then(async data => {60if (data.offline == true) {6162if (swal) {63swal.fire({64title: "Oh no!",65html: `Our hacks are currently having some issues, and we're working on it.`,66icon: "error"67});68} else {69const res = confirm(`Uh Oh! Hacks look to be down. Hit OK to go to our discord to get updates on when they'll go back up!`);70if (res) location = "https://dsc.gg/ProdigyPNP";71}72}73});7475// Block game.min.js76browser.webRequest.onBeforeRequest.addListener(77_ => ({ cancel: true }),78{ urls: ["*://code.prodigygame.com/code/*"] },79["blocking"],80);8182// see disableIntegrity.js, we append the new game.min to the document83return { cancel: true };8485// Public gamemin86} else if (details.url.startsWith("https://code.prodigygame.com/js/public-game")) {878889const hash = new String(details.url.split("public-game-")[1].split(".")[0]).valueOf();90console.log("Public gamemin hash: " + hash)9192// add a redirectUrl header which should redirect public gamemin to our hacked public gamemin.93return {94redirectUrl: `${redirectorDomain}/public-game.min.js?hash=${hash}&updated=${Date.now()}`95};96}979899}, {100101// Block gamemin and public gamemin102urls: [103"*://code.prodigygame.com/code/*/game.min.js*",104"*://code.prodigygame.com/js/public-game-*.min.js*"105],106types: ["main_frame", "sub_frame", "stylesheet", "script", "image", "font", "object", "xmlhttprequest", "ping", "csp_report", "media", "websocket", "other"],107}, ["blocking"]);108109