mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
Fix github raw css links, make jsons human readable (#299)
This commit is contained in:
parent
1f369dae11
commit
18ba2ec477
2 changed files with 15 additions and 9 deletions
|
@ -4,8 +4,17 @@ import {getConfig} from "../utils";
|
|||
const unstrictCSP = () => {
|
||||
console.log("Setting up CSP unstricter...");
|
||||
|
||||
electron.session.defaultSession.webRequest.onHeadersReceived(({responseHeaders}, done) => {
|
||||
delete responseHeaders!["content-security-policy"];
|
||||
electron.session.defaultSession.webRequest.onHeadersReceived(({responseHeaders, resourceType}, done) => {
|
||||
if (!responseHeaders) return done({});
|
||||
|
||||
if (resourceType === "mainFrame") {
|
||||
delete responseHeaders["content-security-policy"];
|
||||
} else if (resourceType === "stylesheet") {
|
||||
// Fix hosts that don't properly set the css content type, such as
|
||||
// raw.githubusercontent.com
|
||||
responseHeaders["content-type"] = ["text/css"];
|
||||
}
|
||||
|
||||
done({responseHeaders});
|
||||
});
|
||||
};
|
||||
|
|
11
src/utils.ts
11
src/utils.ts
|
@ -141,7 +141,7 @@ export async function setLang(language: string) {
|
|||
let rawdata = fs.readFileSync(langConfigFile, "utf-8");
|
||||
let parsed = JSON.parse(rawdata);
|
||||
parsed["lang"] = language;
|
||||
let toSave = JSON.stringify(parsed);
|
||||
let toSave = JSON.stringify(parsed, null, 4);
|
||||
fs.writeFileSync(langConfigFile, toSave, "utf-8");
|
||||
}
|
||||
var language: string;
|
||||
|
@ -209,10 +209,7 @@ export async function setWindowState(object: WindowState) {
|
|||
const userDataPath = app.getPath("userData");
|
||||
const storagePath = path.join(userDataPath, "/storage/");
|
||||
const saveFile = storagePath + "window.json";
|
||||
if (!fs.existsSync(saveFile)) {
|
||||
fs.writeFileSync(saveFile, "{}", "utf-8");
|
||||
}
|
||||
let toSave = JSON.stringify(object);
|
||||
let toSave = JSON.stringify(object, null, 4);
|
||||
fs.writeFileSync(saveFile, toSave, "utf-8");
|
||||
}
|
||||
export async function getWindowState(object: string) {
|
||||
|
@ -267,11 +264,11 @@ export async function setConfig(object: string, toSet: any) {
|
|||
let rawdata = fs.readFileSync(getConfigLocation(), "utf-8");
|
||||
let parsed = JSON.parse(rawdata);
|
||||
parsed[object] = toSet;
|
||||
let toSave = JSON.stringify(parsed);
|
||||
let toSave = JSON.stringify(parsed, null, 4);
|
||||
fs.writeFileSync(getConfigLocation(), toSave, "utf-8");
|
||||
}
|
||||
export async function setConfigBulk(object: Settings) {
|
||||
let toSave = JSON.stringify(object);
|
||||
let toSave = JSON.stringify(object, null, 4);
|
||||
fs.writeFileSync(getConfigLocation(), toSave, "utf-8");
|
||||
}
|
||||
export async function checkIfConfigExists() {
|
||||
|
|
Loading…
Reference in a new issue