|
@@ -134,6 +134,7 @@ const retryOnError = (doWork, onRetry) => new Promise(resolve => {
|
|
});
|
|
});
|
|
class default_1 {
|
|
class default_1 {
|
|
constructor(opt) {
|
|
constructor(opt) {
|
|
|
|
+ this.webshotCookies = [];
|
|
this.launch = () => {
|
|
this.launch = () => {
|
|
this.webshot = new webshot_1.default(this.wsUrl, this.mode, () => this.webshotCookies, () => setTimeout(this.work, this.workInterval * 1000));
|
|
this.webshot = new webshot_1.default(this.wsUrl, this.mode, () => this.webshotCookies, () => setTimeout(this.work, this.workInterval * 1000));
|
|
};
|
|
};
|
|
@@ -259,15 +260,13 @@ class default_1 {
|
|
this.mode = opt.mode;
|
|
this.mode = opt.mode;
|
|
this.wsUrl = opt.wsUrl;
|
|
this.wsUrl = opt.wsUrl;
|
|
const cookiesFilePath = path.resolve(this.webshotCookiesLockfile);
|
|
const cookiesFilePath = path.resolve(this.webshotCookiesLockfile);
|
|
- if (fs.existsSync(cookiesFilePath)) {
|
|
|
|
- try {
|
|
|
|
- this.webshotCookies = JSON.parse(fs.readFileSync(cookiesFilePath, 'utf8'));
|
|
|
|
- logger.info(`loaded webshot cookies from file ${this.webshotCookiesLockfile}`);
|
|
|
|
- }
|
|
|
|
- catch (err) {
|
|
|
|
- logger.warn(`failed to load webshot cookies from file ${this.webshotCookiesLockfile}: `, err);
|
|
|
|
- logger.warn('cookies will be saved to this file when needed');
|
|
|
|
- }
|
|
|
|
|
|
+ try {
|
|
|
|
+ this.webshotCookies = JSON.parse(fs.readFileSync(cookiesFilePath, 'utf8'));
|
|
|
|
+ logger.info(`loaded webshot cookies from file ${this.webshotCookiesLockfile}`);
|
|
|
|
+ }
|
|
|
|
+ catch (err) {
|
|
|
|
+ logger.warn(`failed to load webshot cookies from file ${this.webshotCookiesLockfile}: `, err.message);
|
|
|
|
+ logger.warn('cookies will be saved to this file when needed');
|
|
}
|
|
}
|
|
exports.browserLogin = (page) => {
|
|
exports.browserLogin = (page) => {
|
|
logger.warn('blocked by login dialog, trying to log in manually...');
|
|
logger.warn('blocked by login dialog, trying to log in manually...');
|