-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
59 lines (47 loc) · 1.71 KB
/
Copy pathmain.js
File metadata and controls
59 lines (47 loc) · 1.71 KB
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
const { app, BrowserWindow, ipcMain, session, screen } = require('electron');
const path = require('path');
const USER_AGENT = 'Mozilla/5.0 (PS4; Leanback Shell) Gecko/20100101 Firefox/65.0 LeanbackShell/01.00.01.75 Sony PS4/ (PS4, , no, CH)';
app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required');
app.commandLine.appendSwitch('ignore-gpu-blocklist');
app.commandLine.appendSwitch('enable-gpu-rasterization');
app.commandLine.appendSwitch('enable-zero-copy');
function createWindow() {
app.userAgentFallback = USER_AGENT;
session.defaultSession.webRequest.onBeforeSendHeaders(
{ urls: ['*://*.youtube.com/*', '*://*.googlevideo.com/*'] },
(details, callback) => {
details.requestHeaders['User-Agent'] = USER_AGENT;
callback({ cancel: false, requestHeaders: details.requestHeaders });
}
);
const { width, height } = screen.getPrimaryDisplay().bounds;
const win = new BrowserWindow({
width,
height,
fullscreen: true,
backgroundColor: '#0f0f0f',
autoHideMenuBar: true,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
contextIsolation: true,
nodeIntegration: false
}
});
win.webContents.setUserAgent(USER_AGENT);
win.loadURL('https://www.youtube.com/tv#/');
return win;
}
// Controller IPC handler
ipcMain.on('controller-key', (event, keyCode) => {
const win = BrowserWindow.fromWebContents(event.sender);
if (win && !win.isDestroyed()) {
win.webContents.sendInputEvent({ type: 'keyDown', keyCode });
win.webContents.sendInputEvent({ type: 'keyUp', keyCode });
}
});
app.whenReady().then(createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});