File tree Expand file tree Collapse file tree 3 files changed +738
-700
lines changed Expand file tree Collapse file tree 3 files changed +738
-700
lines changed Original file line number Diff line number Diff line change @@ -537,6 +537,12 @@ class WebuiBridge {
537
537
}
538
538
}
539
539
}
540
+ #getScriptUrl( ) {
541
+ const scripts = Array . from ( document . scripts )
542
+ . filter ( s => s . src !== null && s . src . startsWith ( 'http' ) && s . src . endsWith ( 'webui.js' ) )
543
+ . map ( s => s . src ) ;
544
+ return scripts . length === 0 ? null : new URL ( scripts [ 0 ] ) ;
545
+ }
540
546
#callPromise( fn : string , ...args : DataTypes [ ] ) {
541
547
-- this . #callPromiseID[ 0 ] ;
542
548
const callId = this . #toUint16( this . #callPromiseID[ 0 ] ) ;
@@ -609,7 +615,8 @@ class WebuiBridge {
609
615
this . #ws. close ( ) ;
610
616
}
611
617
this . #TokenAccepted = false ;
612
- const host = window . location . hostname ;
618
+ const scriptUrl = this . #getScriptUrl( ) ;
619
+ const host = scriptUrl !== null ? scriptUrl . hostname : window . location . hostname ;
613
620
const url = this . #secure ? ( 'wss://' + host ) : ( 'ws://' + host ) ;
614
621
this . #ws = new WebSocket ( `${ url } :${ this . #port} /_webui_ws_connect` ) ;
615
622
this . #ws. binaryType = 'arraybuffer' ;
You can’t perform that action at this time.
0 commit comments