Injector v4.6.0: Rid off CSP, code clean up

pull/8/head
Oj18 4 years ago
parent fcb034ef95
commit 699a11ee92

@ -1,5 +1,12 @@
# GooseMod Changelog
## v4.6.0 [2020-11-01]
- ### Tweaks
- No longer uses janky CSP bypass, instead now relies on it being disabled when GooseMod is injected
- Cleaned up some code, removed some now unneeded logging and some unnecessary old comments
## v4.5.0 [2020-10-31]
- ### Features

12
dist/index.js vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

@ -5,8 +5,6 @@ import * as Logger from './util/logger';
import WebpackModules from './util/discord/webpackModules';
import fixLocalStorage from './util/discord/fixLocalStorage';
import cspBypasser from './util/discord/cspBypasser';
import showToast from './ui/toast';
import confirmDialog from './ui/modals/confirm';
@ -19,8 +17,6 @@ import { startLoadingScreen, stopLoadingScreen, updateLoadingScreen, setThisScop
import * as Settings from './ui/settings';
// import { removeModuleUI, isSettingsOpen, closeSettings, openSettings, openSettingItem, reopenSettings, injectInSettings, checkSettingsOpenInterval, makeGooseModSettings, setThisScope as setThisScope2 } from './ui/settings';
import easterEggs from './ui/easterEggs';
import { importModule, importModules, bindHandlers, getModuleFiles, importModulesFull, setThisScope as setThisScope3 } from './moduleManager';
@ -30,12 +26,11 @@ import moduleStoreAPI from './moduleStore';
const scopeSetterFncs = [
setThisScope1,
Settings.setThisScope, // setThisScope2,
Settings.setThisScope,
setThisScope3,
setThisScope4,
moduleStoreAPI.setThisScope,
cspBypasser.setThisScope,
easterEggs.setThisScope,
Changelog.setThisScope,
@ -49,15 +44,7 @@ const importsToAssign = {
stopLoadingScreen,
updateLoadingScreen,
settings: Settings, /* removeModuleUI,
isSettingsOpen,
closeSettings,
openSettings,
openSettingItem,
reopenSettings,
injectInSettings,
checkSettingsOpenInterval,
makeGooseModSettings, */
settings: Settings,
importModule,
importModules,
@ -75,7 +62,6 @@ const importsToAssign = {
messageEasterEggs: easterEggs,
logger: Logger,
cspBypasser,
showToast,
confirmDialog,
moduleStoreAPI,
@ -93,31 +79,20 @@ const init = async function () {
let a = 1;
for (let x of scopeSetterFncs) {
console.log(a, x);
x(this);
a++;
};
await this.cspBypasser.init();
/*for (let p in toAssign) {
if (toAssign.hasOwnProperty(p)) {
}
}*/
this.settings.makeGooseModSettings();
// this.logger = Logger;
this.removed = false;
this.modules = {};
this.disabledModules = {};
this.lastVersion = localStorage.getItem('goosemodLastVersion');
this.version = '4.5.0';
this.version = '4.6.0';
this.versionHash = '<hash>'; // Hash of built final js file is inserted here via build script
if (this.lastVersion && this.lastVersion !== this.version) {
@ -136,55 +111,10 @@ const init = async function () {
// delete window.gmUntethered;
}
// this.webpackModules = WebpackModules;
// this.showToast = showToast;
this.showToast(`GooseMod v${this.version} (${this.versionHash.substring(0, 7)})`, {timeout: 1000});
// this.messageEasterEggs = easterEggs;
// this.confirmDialog = confirmDialog;
this.messageEasterEggs.interval = setInterval(this.messageEasterEggs.check, 1000);
/* Object.assign(this, {
startLoadingScreen,
stopLoadingScreen,
updateLoadingScreen
});
Object.assign(this, {
removeModuleUI,
isSettingsOpen,
closeSettings,
openSettings,
openSettingItem,
reopenSettings,
injectInSettings,
checkSettingsOpenInterval
});
this.cspBypasser = cspBypasser; */
/* Object.assign(this, {
importModule,
importModules,
bindHandlers,
getModuleFiles,
importModulesFull
});
Object.assign(this, {
saveModuleSettings,
clearModuleSetting,
clearSettings,
loadSavedModuleSetting,
loadSavedModuleSettings
});
this.moduleStoreAPI = moduleStoreAPI; */
this.saveInterval = setInterval(this.saveModuleSettings, 3000);
this.remove = () => {

@ -17,7 +17,8 @@ export default {
jsCache: JSCache,
updateModules: async () => {
goosemodScope.moduleStoreAPI.modules = (await goosemodScope.cspBypasser.json(`${goosemodScope.moduleStoreAPI.apiBaseURL}/modules.json?_=${Date.now()}`, false)).sort((a, b) => a.name.localeCompare(b.name));
goosemodScope.moduleStoreAPI.modules = (await (await fetch(`${goosemodScope.moduleStoreAPI.apiBaseURL}/modules.json?_=${Date.now()}`)).json())
.sort((a, b) => a.name.localeCompare(b.name));
},
importModule: async (moduleName) => {

@ -22,7 +22,7 @@ export const getJSForModule = async (moduleName) => {
if (cache[moduleName] && moduleInfo.version === cache[moduleName].version) {
return cache[moduleName].js;
} else {
const js = await goosemodScope.cspBypasser.text(`${moduleInfo.codeURL}?_=${Date.now()}`, false);
const js = await (await fetch(`${moduleInfo.codeURL}?_=${Date.now()}`)).text();
goosemodScope.moduleStoreAPI.jsCache.updateCache(moduleName, moduleInfo.version, js);

@ -32,7 +32,7 @@ export const show = async () => {
};
export const generate = async () => {
const changelog = await goosemodScope.cspBypasser.json(changelogURL, false);
const changelog = await (await fetch(changelogURL)).json();
version = changelog.version;

@ -1,74 +0,0 @@
let goosemodScope = {};
let noCSPFetch;
export default {
setThisScope: (scope) => {
goosemodScope = scope;
},
noCSPFetch: undefined,
init: async () => {
if (window.goosemod_noCSPFetch) {
noCSPFetch = window.goosemod_noCSPFetch;
delete window.goosemod_noCSPFetch;
return;
}
let el = document.createElement('object');
el.data = location.origin;
document.body.appendChild(el);
/*let script = document.createElement('script');
script.type = 'text/javascript';
let code = `
window.addEventListener('message', async (e) => {
const { url, type, useCORSProxy, useCache } = e.data;
if (!url) return;
const req = await fetch(url, {
cache: useCache ? 'default' : 'no-store'
});
e.source.postMessage({ verify: url, data: await req[type]() });
});`;
script.appendChild(document.createTextNode(code));
goosemodScope.cspBypasser.frame.contentDocument.head.appendChild(script);*/
noCSPFetch = el.contentWindow.fetch;
},
fetch: (url, type, useCORSProxy = true) => {
return new Promise(async (finalRes) => {
const sendURL = useCORSProxy ? `https://cors-anywhere.herokuapp.com/${url}` : url;
const sendType = type === 'img' ? 'blob' : type;
const req = await noCSPFetch(sendURL);
const resp = await req[sendType]();
if (type === 'img') {
resp = URL.createObjectURL(resp);
}
return finalRes(resp);
});
},
json: (url, useCORSProxy) => goosemodScope.cspBypasser.fetch(url, 'json', useCORSProxy),
text: (url, useCORSProxy) => goosemodScope.cspBypasser.fetch(url, 'text', useCORSProxy),
blob: (url, useCORSProxy) => goosemodScope.cspBypasser.fetch(url, 'blob', useCORSProxy),
image: (url, useCORSProxy) => goosemodScope.cspBypasser.fetch(url, 'img', useCORSProxy),
};
Loading…
Cancel
Save