diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2021-08-15 15:48:45 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2021-08-15 15:48:45 -0400 |
| commit | 2f46fd68adffb44105b727bf1b389a9cb5a93ed7 (patch) | |
| tree | 6c52080d5b7f7924d2214a20405ab82db4c154ca /index.js | |
| parent | 895c5f2855b1124133d9d676960db94906b065ea (diff) | |
| download | YouTube-TV-Client-2f46fd68adffb44105b727bf1b389a9cb5a93ed7.tar.gz YouTube-TV-Client-2f46fd68adffb44105b727bf1b389a9cb5a93ed7.tar.bz2 YouTube-TV-Client-2f46fd68adffb44105b727bf1b389a9cb5a93ed7.zip | |
add more verbose options
Diffstat (limited to 'index.js')
| -rw-r--r-- | index.js | 38 |
1 files changed, 9 insertions, 29 deletions
@@ -1,45 +1,33 @@ const { app, BrowserWindow, session } = require('electron') +const userAgent = "Mozilla/5.0 (Linux; Tizen 2.3) AppleWebKit/538.1 (KHTML, like Gecko)Version/2.3 TV Safari/538.1"; +const URL = "https://youtube.com/tv" + function createWindow() { const win = new BrowserWindow({ - width: 800, - height: 600, fullscreen: true, autoHideMenuBar: true }) - win.loadURL('https://youtube.com/tv'); + win.loadURL(URL); + console.log("Loading " + URL) } function fetchCookie(){ + console.log("Fetching cookies...") session.defaultSession.cookies.get({ - url: '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'); + url: URL }); } - app.whenReady().then(() => { console.log("Started YouTube TV Client 2.0"); createWindow(); - fetchCookie(); 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'; + details.requestHeaders['User-Agent'] = userAgent; callback({ cancel: false, requestHeaders: details.requestHeaders }); }); + console.log("User Agent has been set to \"" + userAgent + "\"") app.on('activate', function () { if (BrowserWindow.getAllWindows().length === 0) createWindow(); @@ -50,12 +38,4 @@ app.whenReady().then(() => { app.on('window-all-closed', function () { if (process.platform !== 'darwin') app.quit(); - fetchCookie() - .then((cookies) => { - cookieDump(cookies); - console.log("Wrote Cookies"); - }).catch((error) => { - console.log(error); - }); - });
\ No newline at end of file |
