This maybe works
This commit is contained in:
parent
4b2513330c
commit
51f28144d0
4 changed files with 36 additions and 12 deletions
|
@ -3,6 +3,7 @@ import * as path from "path";
|
|||
import { Store } from "./store";
|
||||
import { BrowserWindow as bw } from "./browserwindow";
|
||||
import { app, BrowserWindow, ipcMain } from "electron";
|
||||
import fetch from "electron-fetch";
|
||||
import ElectronStore from "electron-store";
|
||||
|
||||
export class utils {
|
||||
|
@ -77,6 +78,29 @@ export class utils {
|
|||
return bw.express;
|
||||
}
|
||||
|
||||
/**
|
||||
* MitM the electron fetch for a function that proxies github.
|
||||
* Written in TS so Maikiwi doesn't fuck up
|
||||
* @param url {string} URL param
|
||||
* @param opts {object} Other options
|
||||
*/
|
||||
static readonly _mirror: boolean = this.getStoreValue("advanced.experiments").includes('cider_mirror') ? true : false;
|
||||
static fetch(url: string, opts = {}) {
|
||||
if (this._mirror === true) {
|
||||
if (url.includes("api.github.com/")) {
|
||||
return fetch(url.replace("api.github.com/", "mirror.api.cider.sh/v2/api/"), opts);
|
||||
}
|
||||
else if (url.includes("raw.githubusercontent.com/")) {
|
||||
return fetch(url.replace("raw.githubusercontent.com/", "mirror.api.cider.sh/v2/raw/"), opts);
|
||||
}
|
||||
else {
|
||||
return fetch(url, opts);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return fetch(url, opts);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Fetches the i18n locale for the given language.
|
||||
* @param language {string} The language to fetch the locale for.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue