diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2021-08-15 15:11:16 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2021-08-15 15:11:16 -0400 |
| commit | dc62c38201ab9cae15cfab6591514df8e48025e2 (patch) | |
| tree | ea10150e4b34677d5ec2f265f8e40a70c014da4d /index.js | |
| parent | 5fcb2c40b38cde03044532ebe0e42e6d21fa10c7 (diff) | |
| download | YouTube-TV-Client-dc62c38201ab9cae15cfab6591514df8e48025e2.tar.gz YouTube-TV-Client-dc62c38201ab9cae15cfab6591514df8e48025e2.tar.bz2 YouTube-TV-Client-dc62c38201ab9cae15cfab6591514df8e48025e2.zip | |
putting cookies on its own function
Diffstat (limited to 'index.js')
| -rw-r--r-- | index.js | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -10,6 +10,12 @@ function createWindow() { win.loadURL('https://youtube.com/tv'); } +function fetchCookie(){ + session.defaultSession.cookies.get({ + url: 'https://youtube.com/tv' + }); +} + function cookieDump(cookies) { var buffer = '[' for (let cookie of cookies) { @@ -28,9 +34,7 @@ app.whenReady().then(() => { console.log("Started YouTube TV Client 2.0"); createWindow(); - session.defaultSession.cookies.get({ - url: 'https://youtube.com/tv' - }); + 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'; @@ -46,9 +50,7 @@ app.whenReady().then(() => { app.on('window-all-closed', function () { if (process.platform !== 'darwin') app.quit(); - session.defaultSession.cookies.get({ - url: 'https://youtube.com/tv' - }) + fetchCookie() .then((cookies) => { cookieDump(cookies); console.log("Wrote Cookies"); |
