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 {
537537 }
538538 }
539539 }
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+ }
540546 #callPromise( fn : string , ...args : DataTypes [ ] ) {
541547 -- this . #callPromiseID[ 0 ] ;
542548 const callId = this . #toUint16( this . #callPromiseID[ 0 ] ) ;
@@ -609,7 +615,8 @@ class WebuiBridge {
609615 this . #ws. close ( ) ;
610616 }
611617 this . #TokenAccepted = false ;
612- const host = window . location . hostname ;
618+ const scriptUrl = this . #getScriptUrl( ) ;
619+ const host = scriptUrl !== null ? scriptUrl . hostname : window . location . hostname ;
613620 const url = this . #secure ? ( 'wss://' + host ) : ( 'ws://' + host ) ;
614621 this . #ws = new WebSocket ( `${ url } :${ this . #port} /_webui_ws_connect` ) ;
615622 this . #ws. binaryType = 'arraybuffer' ;
You can’t perform that action at this time.
0 commit comments