|
@@ -13,6 +13,7 @@ let webConfig = {
|
|
|
webSecurity: false,
|
|
webSecurity: false,
|
|
|
contextIsolation: true,
|
|
contextIsolation: true,
|
|
|
nodeIntegration: false,
|
|
nodeIntegration: false,
|
|
|
|
|
+ allowRunningInsecureContent: true, // 允许不安全内容
|
|
|
preload: path.join(__dirname, "preload.js")
|
|
preload: path.join(__dirname, "preload.js")
|
|
|
},
|
|
},
|
|
|
autoHideMenuBar: true
|
|
autoHideMenuBar: true
|
|
@@ -21,6 +22,9 @@ let webConfig = {
|
|
|
// 全屏
|
|
// 全屏
|
|
|
// fullscreen: true
|
|
// fullscreen: true
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
// 判断是否有特殊配置文件
|
|
// 判断是否有特殊配置文件
|
|
|
console.log(__dirname + "\\config.json")
|
|
console.log(__dirname + "\\config.json")
|
|
|
if (fs.existsSync("./config.json")) {
|
|
if (fs.existsSync("./config.json")) {
|
|
@@ -139,29 +143,44 @@ function createWindow () {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// This method will be called when Electron has finished
|
|
|
|
|
-// initialization and is ready to create browser windows.
|
|
|
|
|
-// Some APIs can only be used after this event occurs.
|
|
|
|
|
-app.whenReady().then(() => {
|
|
|
|
|
- session.defaultSession.webRequest.onBeforeRequest(xxx_filter, (details, callback) => {
|
|
|
|
|
- callback({ redirectURL: webConfig.redirectURL});
|
|
|
|
|
- })
|
|
|
|
|
- session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
|
|
|
|
|
- const responseHeaders = details.responseHeaders;
|
|
|
|
|
|
|
+function setupCSPRemoval(ses) {
|
|
|
|
|
+ ses.webRequest.onHeadersReceived((details, callback) => {
|
|
|
|
|
+ const responseHeaders = details.responseHeaders || {};
|
|
|
|
|
+
|
|
|
|
|
+ const cspHeaders = [
|
|
|
|
|
+ 'content-security-policy',
|
|
|
|
|
+ 'Content-Security-Policy',
|
|
|
|
|
+ 'content-security-policy-report-only',
|
|
|
|
|
+ 'x-content-security-policy',
|
|
|
|
|
+ 'x-webkit-csp'
|
|
|
|
|
+ ];
|
|
|
|
|
|
|
|
- // 删除 CSP
|
|
|
|
|
- delete responseHeaders['content-security-policy'];
|
|
|
|
|
- delete responseHeaders['Content-Security-Policy'];
|
|
|
|
|
|
|
+ cspHeaders.forEach(header => {
|
|
|
|
|
+ if (responseHeaders[header]) {
|
|
|
|
|
+ console.log('Removing', header, 'from', details.url);
|
|
|
|
|
+ delete responseHeaders[header];
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
callback({ cancel: false, responseHeaders });
|
|
callback({ cancel: false, responseHeaders });
|
|
|
});
|
|
});
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// This method will be called when Electron has finished
|
|
|
|
|
+// initialization and is ready to create browser windows.
|
|
|
|
|
+// Some APIs can only be used after this event occurs.
|
|
|
|
|
+app.whenReady().then(() => {
|
|
|
// 判断是否无缓存
|
|
// 判断是否无缓存
|
|
|
if (webConfig.noCache) {
|
|
if (webConfig.noCache) {
|
|
|
console.log('无缓存模式!')
|
|
console.log('无缓存模式!')
|
|
|
webConfig.webPreferences.partition = 'persist:Session' + Math.round(Math.random()*100000)
|
|
webConfig.webPreferences.partition = 'persist:Session' + Math.round(Math.random()*100000)
|
|
|
|
|
+
|
|
|
} else {
|
|
} else {
|
|
|
webConfig.webPreferences.partition = 'persist:owoApp'
|
|
webConfig.webPreferences.partition = 'persist:owoApp'
|
|
|
}
|
|
}
|
|
|
|
|
+ // 去掉安全措施
|
|
|
|
|
+ const partitionSession = session.fromPartition(webConfig.webPreferences.partition);
|
|
|
|
|
+ setupCSPRemoval(partitionSession);
|
|
|
createWindow()
|
|
createWindow()
|
|
|
|
|
|
|
|
app.on('activate', function () {
|
|
app.on('activate', function () {
|