File tree Expand file tree Collapse file tree 3 files changed +13
-10
lines changed
Expand file tree Collapse file tree 3 files changed +13
-10
lines changed Original file line number Diff line number Diff line change 120120 var rpcinfo ;
121121 function discordrpc ( ) {
122122 try {
123- rpcinfo = document . getElementById ( "content-frame" ) . contentWindow . window . rpcinfo ;
123+ // Try to get RPC info from the iframe content
124+ const frameWindow = document . getElementById ( "content-frame" ) . contentWindow ;
125+ if ( frameWindow && frameWindow . rpcinfo ) {
126+ rpcinfo = frameWindow . rpcinfo ;
127+ // Update the Discord RPC status in the main process
128+ if ( window . electronAPI && window . electronAPI . updateRpcStatus ) {
129+ window . electronAPI . updateRpcStatus ( rpcinfo ) ;
130+ }
131+ }
124132 } catch ( error ) {
125- console . error ( 'Error in discordrpc:' , error ) ;
133+ // Silently handle cross-origin errors or other issues
134+ // This is expected when the iframe contains external content
126135 }
127136 }
128137 setInterval ( discordrpc , 15000 ) ;
Original file line number Diff line number Diff line change @@ -77,14 +77,7 @@ ipcMain.handle('window-is-maximized', (event) => {
7777} ) ;
7878
7979ipcMain . handle ( 'get-rpc-info' , async ( event ) => {
80- if ( ! win ) return '' ;
81- try {
82- const status = await win . webContents . executeJavaScript ( 'window.rpcinfo || ""' ) ;
83- currentStatus = status || 'Playing Sploder' ;
84- return status ;
85- } catch ( error ) {
86- return '' ;
87- }
80+ return currentStatus ;
8881} ) ;
8982
9083ipcMain . handle ( 'update-rpc-status' , ( event , status ) => {
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
77 closeWindow : ( ) => ipcRenderer . invoke ( 'window-close' ) ,
88 isWindowMaximized : ( ) => ipcRenderer . invoke ( 'window-is-maximized' ) ,
99 getRpcInfo : ( ) => ipcRenderer . invoke ( 'get-rpc-info' ) ,
10+ updateRpcStatus : ( status ) => ipcRenderer . invoke ( 'update-rpc-status' , status ) ,
1011 onWindowStateChange : ( callback ) => {
1112 ipcRenderer . on ( 'window-state-change' , ( _ , isMaximized ) => {
1213 callback ( isMaximized ) ;
You can’t perform that action at this time.
0 commit comments