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 = () => { | const unstrictCSP = () => { | ||||||
|     console.log("Setting up CSP unstricter..."); |     console.log("Setting up CSP unstricter..."); | ||||||
| 
 | 
 | ||||||
|     electron.session.defaultSession.webRequest.onHeadersReceived(({responseHeaders}, done) => { |     electron.session.defaultSession.webRequest.onHeadersReceived(({responseHeaders, resourceType}, done) => { | ||||||
|         delete responseHeaders!["content-security-policy"]; |         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}); |         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 rawdata = fs.readFileSync(langConfigFile, "utf-8"); | ||||||
|     let parsed = JSON.parse(rawdata); |     let parsed = JSON.parse(rawdata); | ||||||
|     parsed["lang"] = language; |     parsed["lang"] = language; | ||||||
|     let toSave = JSON.stringify(parsed); |     let toSave = JSON.stringify(parsed, null, 4); | ||||||
|     fs.writeFileSync(langConfigFile, toSave, "utf-8"); |     fs.writeFileSync(langConfigFile, toSave, "utf-8"); | ||||||
| } | } | ||||||
| var language: string; | var language: string; | ||||||
|  | @ -209,10 +209,7 @@ export async function setWindowState(object: WindowState) { | ||||||
|     const userDataPath = app.getPath("userData"); |     const userDataPath = app.getPath("userData"); | ||||||
|     const storagePath = path.join(userDataPath, "/storage/"); |     const storagePath = path.join(userDataPath, "/storage/"); | ||||||
|     const saveFile = storagePath + "window.json"; |     const saveFile = storagePath + "window.json"; | ||||||
|     if (!fs.existsSync(saveFile)) { |     let toSave = JSON.stringify(object, null, 4); | ||||||
|         fs.writeFileSync(saveFile, "{}", "utf-8"); |  | ||||||
|     } |  | ||||||
|     let toSave = JSON.stringify(object); |  | ||||||
|     fs.writeFileSync(saveFile, toSave, "utf-8"); |     fs.writeFileSync(saveFile, toSave, "utf-8"); | ||||||
| } | } | ||||||
| export async function getWindowState(object: string) { | 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 rawdata = fs.readFileSync(getConfigLocation(), "utf-8"); | ||||||
|     let parsed = JSON.parse(rawdata); |     let parsed = JSON.parse(rawdata); | ||||||
|     parsed[object] = toSet; |     parsed[object] = toSet; | ||||||
|     let toSave = JSON.stringify(parsed); |     let toSave = JSON.stringify(parsed, null, 4); | ||||||
|     fs.writeFileSync(getConfigLocation(), toSave, "utf-8"); |     fs.writeFileSync(getConfigLocation(), toSave, "utf-8"); | ||||||
| } | } | ||||||
| export async function setConfigBulk(object: Settings) { | export async function setConfigBulk(object: Settings) { | ||||||
|     let toSave = JSON.stringify(object); |     let toSave = JSON.stringify(object, null, 4); | ||||||
|     fs.writeFileSync(getConfigLocation(), toSave, "utf-8"); |     fs.writeFileSync(getConfigLocation(), toSave, "utf-8"); | ||||||
| } | } | ||||||
| export async function checkIfConfigExists() { | export async function checkIfConfigExists() { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue