diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2021-08-15 14:14:54 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2021-08-15 14:14:54 -0400 |
| commit | 19ff9be476e3e19c24abdf4fb3adda81dde877f9 (patch) | |
| tree | 4fcb7a605ea6ba13116c67c99619c624498807bf /index.js | |
| download | YouTube-TV-Client-19ff9be476e3e19c24abdf4fb3adda81dde877f9.tar.gz YouTube-TV-Client-19ff9be476e3e19c24abdf4fb3adda81dde877f9.tar.bz2 YouTube-TV-Client-19ff9be476e3e19c24abdf4fb3adda81dde877f9.zip | |
Inital commit
Diffstat (limited to 'index.js')
| -rw-r--r-- | index.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/index.js b/index.js new file mode 100644 index 0000000..9b43b3b --- /dev/null +++ b/index.js @@ -0,0 +1,54 @@ +const { app, BrowserWindow, session } = require('electron') +function createWindow() { + const win = new BrowserWindow({ + width: 800, + height: 600, + fullscreen: true, + autoHideMenuBar: true + }) + + win.loadURL('https://youtube.com/tv'); +} + +function cookieDump(cookies) { + var buffer = '[' + for (let cookie of cookies) { + console.log(cookie) + buffer += JSON.stringify(cookie) + buffer += "," + } + buffer = buffer.slice(0, -1) + "]" + fs.writeFile('cookies.json', buffer, function (err) { + if (err) return console.log(err); + console.log('Wrote cookies to file'); + }); +} + +app.whenReady().then(() => { + createWindow() + + session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => { + details.requestHeaders['User-Agent'] = 'Mozilla/5.0 (Linux; Tizen 2.3) AppleWebKit/538.1 (KHTML, like Gecko)Version/2.3 TV Safari/538.1'; + callback({ cancel: false, requestHeaders: details.requestHeaders }); + }); + + app.on('activate', function () { + if (BrowserWindow.getAllWindows().length === 0) createWindow() + }) + + }) + + +app.on('window-all-closed', function () { + if (process.platform !== 'darwin') app.quit() + session.defaultSession.cookies.get({ + url: 'https://youtube.com/tv' + }) + .then((cookies) => { + cookieDump(cookies) + console.log("Wrote Cookies") + }).catch((error) => { + console.log(error) + }) + +})
\ No newline at end of file |
