This repository has been archived by the owner on Jun 23, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
4,171 additions
and
6,262 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { ipcRenderer, webFrame } from 'electron'; | ||
import { parse } from 'url'; | ||
import { getAPI } from '../api'; | ||
import { IpcExtension } from '../models/ipc-extension'; | ||
|
||
declare const global: any; | ||
|
||
global.isTab = false; | ||
|
||
let sessionId = -1; | ||
|
||
const arg = process.argv.find(x => x.startsWith('--session-id=')); | ||
|
||
if (arg) { | ||
try { | ||
sessionId = parseInt(arg.split('--session-id=')[1]); | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
} | ||
|
||
// https://github.com/electron/electron/issues/11290#issuecomment-362301961 | ||
Object.defineProperty(window.navigator, 'userAgent', { | ||
value: window.navigator.userAgent.replace(/Electron\/\S*\s/, ''), | ||
configurable: false, | ||
writable: false, | ||
}); | ||
|
||
ipcRenderer.setMaxListeners(0); | ||
|
||
const extensionId = parse(window.location.href).hostname; | ||
|
||
const extension: IpcExtension = ipcRenderer.sendSync( | ||
`get-extension-${sessionId}`, | ||
extensionId, | ||
); | ||
|
||
const updateBounds = () => { | ||
ipcRenderer.sendToHost( | ||
'webview-size', | ||
document.body.clientWidth, | ||
document.body.clientHeight, | ||
); | ||
}; | ||
|
||
window.addEventListener('DOMContentLoaded', () => { | ||
setTimeout(() => { | ||
updateBounds(); | ||
}); | ||
|
||
document.body.addEventListener('resize', () => { | ||
updateBounds(); | ||
}); | ||
}); | ||
|
||
window.addEventListener('blur', () => { | ||
ipcRenderer.sendToHost('webview-blur'); | ||
}); | ||
|
||
process.once('loaded', async () => { | ||
const api = getAPI(extension, sessionId); | ||
|
||
const w: any = await webFrame.executeJavaScript('window'); | ||
w.chrome = w.browser = w.webext = api; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.