mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 11:21:46 +00:00
fix: renderer plugin load timing
MAGIC OF JAVASCRIPT
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { contextBridge, ipcRenderer, IpcRendererEvent } from 'electron';
|
||||
import { contextBridge, ipcRenderer, IpcRendererEvent, webFrame } from 'electron';
|
||||
import is from 'electron-is';
|
||||
|
||||
import config from './config';
|
||||
@ -54,4 +54,18 @@ contextBridge.exposeInMainWorld(
|
||||
process.env.ELECTRON_RENDERER_URL,
|
||||
);
|
||||
|
||||
ipcRenderer.invoke('load-renderer-plugins');
|
||||
const [path, script] = ipcRenderer.sendSync('get-renderer-script') as [string | null, string];
|
||||
let blocked = true;
|
||||
if (path) {
|
||||
webFrame.executeJavaScriptInIsolatedWorld(0, [
|
||||
{
|
||||
code: script,
|
||||
url: path,
|
||||
},
|
||||
], true, () => blocked = false);
|
||||
} else {
|
||||
webFrame.executeJavaScript(script, true, () => blocked = false);
|
||||
}
|
||||
|
||||
// HACK: Wait for the script to be executed
|
||||
while (blocked);
|
||||
|
||||
Reference in New Issue
Block a user