

const {
    BrowserWindow,
    session
}         = require('electron');

const crunch = require('./../crunchyroll')

class browser {
    constructor(url){
        console.log("TEST")
        this.window = new BrowserWindow({
            width: 500,
            height: 500,
            show: true,
            frame: true,
            icon: global.dir + '/app.ico'
        })
        setInterval(function(){
            session.defaultSession.cookies.get({url:'http://crunchyroll.com'}, (error, cookies) => {
              //console.log(error, cookies)
              crunch.session_save(cookies);
            })
        },3000)
        var window = this.window
        window.loadURL(url)
        window.once('ready-to-show', () => {

        })

        this.window.on('closed', () => {
          window = null;
        });
    }
}

module.exports = browser;
