-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnew-window.es
70 lines (63 loc) · 2.7 KB
/
new-window.es
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const remote = require('electron').remote || require('@electron/remote')
if (!require('electron').remote) {
require('electron').remote = remote
}
window.$ = param => document.querySelector(param)
window.$$ = param => document.querySelectorAll(param)
window.ROOT = remote.getGlobal('ROOT')
window.APPDATA_PATH = remote.getGlobal('APPDATA_PATH')
require('module').globalPaths.push(window.ROOT)
const config = (window.config = remote.require('./lib/config'))
require(`${window.ROOT}/views/env-parts/theme`)
try {
require(`${window.ROOT}/views/polyfills/react-i18next`)
} catch (e) {
// do nothing
}
require('./views')
const WindowManager = remote.require('./lib/window')
window.WindowManager = WindowManager
remote.getCurrentWebContents().on('dom-ready', () => {
if (process.platform === 'darwin') {
const div = document.createElement('div')
div.style.position = 'absolute'
div.style.top = 0
div.style.height = '23px'
div.style.width = '100%'
div.style['-webkit-app-region'] = 'drag'
div.style['pointer-events'] = 'none'
document.body.appendChild(div)
}
$('webview').addEventListener('dom-ready', () => {
if (config.get('poi.enableDMMcookie', false)) {
$('webview').executeJavaScript(`
document.cookie = "cklg=welcome;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=.dmm.com;path=/";
document.cookie = "cklg=welcome;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=.dmm.com;path=/netgame/";
document.cookie = "cklg=welcome;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=.dmm.com;path=/netgame_s/";
document.cookie = "ckcy=1;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=osapi.dmm.com;path=/";
document.cookie = "ckcy=1;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=203.104.209.7;path=/";
document.cookie = "ckcy=1;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=www.dmm.com;path=/netgame/";
document.cookie = "ckcy=1;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=log-netgame.dmm.com;path=/";
document.cookie = "ckcy=1;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=.dmm.com;path=/";
document.cookie = "ckcy=1;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=.dmm.com;path=/netgame/";
document.cookie = "ckcy=1;expires=Sun, 09 Feb 2019 09:00:09 GMT;domain=.dmm.com;path=/netgame_s/";
`)
const ua = $('webview')
.getWebContents()
.session.getUserAgent()
$('webview')
.getWebContents()
.session.setUserAgent(ua, 'ja-JP')
}
})
$('webview').addEventListener('new-window', e => {
const exWindow = WindowManager.createWindow({
realClose: true,
navigatable: true,
nodeIntegration: false,
})
exWindow.loadURL(e.url)
exWindow.show()
e.preventDefault()
})
})