temporary fix for the issue with opening app lab urls from the ad section

This commit is contained in:
Shane Harris
2021-12-11 13:38:48 +01:00
parent 0956a3b512
commit f5d45b997f
4 changed files with 28 additions and 12 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
<app-loading-spinner #spinner></app-loading-spinner>
<app-status-bar #status (getHelp)="getHelpModal.openModal(); helpStatus = $event; setExterHelp()"></app-status-bar>
<webview id="mainWebView" #webview httpreferrer="https://sdiequestvr.com" [attr.src]="webUrl" allowpopups [ngStyle]="{'left':webService.isWebviewOpen?'0':'-100%'}" class="bsaber-webview" ></webview>
<webview id="mainWebView" #webview httpreferrer="https://sdiequestvr.com" [attr.src]="webUrl" allowpopups [ngStyle]="{'left':webService.isWebviewOpen?'0':'-100%'}" class="bsaber-webview" partition='webview-partition'></webview>
<mz-modal #getHelpModal [fixedFooter]="true">
<mz-modal-header>
+13 -2
View File
@@ -1,6 +1,7 @@
import { Injectable, isDevMode } from '@angular/core';
import { AppService } from './app.service';
import { environment } from '../environments/environment';
import { OPEN_IN_SYSTEM_BROWSER_DOMAINS } from '../../../electron/external-urls';
@Injectable({
providedIn: 'root',
@@ -45,12 +46,22 @@ export class WebviewService {
.bsaber-tooltip.-sidequest-remove::after {
content: "Remove Custom Level";
}`;
let ses = this.appService.remote.session.fromPartition('webview-partition');
ses.webRequest.onBeforeRequest((details, callback) => {
let url = details.url;
const extUrl = new URL(url).host.toLowerCase();
if (OPEN_IN_SYSTEM_BROWSER_DOMAINS.includes(extUrl)) {
this.appService.electron.shell.openExternal(url);
callback({ cancel: true });
} else {
callback({});
}
});
this.webView.addEventListener('did-start-loading', e => {
//this.currentAddress = this.webView.getURL();
this.isWebviewLoading = true;
this.webView.insertCSS(customCss);
});
this.webView.addEventListener('did-navigate-in-page', () => {
this.webView.addEventListener('did-navigate-in-page', e => {
this.currentAddress = this.webView.getURL();
});
this.webView.addEventListener('did-stop-loading', async e => {