|
@@ -42,17 +42,17 @@ class Webshot extends CallableInstance<[LazyMediaItem[], (...args) => void, numb
|
|
|
constructor(
|
|
|
wsUrl: string, mode: number,
|
|
|
getCookies: () => Cookies,
|
|
|
- onready?: (doOnNewPage?: typeof Webshot.prototype.performOnNewPage) => void
|
|
|
+ onready: (doOnNewPage?: typeof Webshot.prototype.performOnNewPage) => void
|
|
|
) {
|
|
|
super('webshot');
|
|
|
// tslint:disable-next-line: no-conditional-assignment
|
|
|
// eslint-disable-next-line no-cond-assign
|
|
|
if (this.mode = mode) {
|
|
|
- onready();
|
|
|
+ if (onready) onready();
|
|
|
} else {
|
|
|
this.getCookies = getCookies;
|
|
|
this.wsUrl = wsUrl;
|
|
|
- this.connect(() => onready(this.performOnNewPage));
|
|
|
+ this.connect(() => onready && onready(this.performOnNewPage));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -132,11 +132,12 @@ class Webshot extends CallableInstance<[LazyMediaItem[], (...args) => void, numb
|
|
|
logger.warn(`navigation timed out at ${getTimerTime()} ms`);
|
|
|
return null;
|
|
|
})
|
|
|
- // hide header, footer, "more options" button, like and share count, carousel navigator, and comments
|
|
|
+ // hide header, footer, "more options" button, like and share count, carousel navigator, 2nd avatar, and comments
|
|
|
.then(() => page.addStyleTag({content:
|
|
|
- 'nav,footer,header+div,header+div+div>div>div+div,article button,canvas,' +
|
|
|
- 'article section,article section+div>ul>:not(div),li [tabindex="0"] div:not(:first-child){display:none!important} ' +
|
|
|
- 'section+div{overflow:hidden} section+*>*{position:relative!important} article{border-bottom:1px solid!important}',
|
|
|
+ 'nav,footer,header+div,header+div+div>div>div+div,article button,canvas,article section,article section+div>ul>:not(div),' +
|
|
|
+ 'article section+div>ul>div [role="button"],li [tabindex="0"] div:not(:first-child){display:none!important} ' +
|
|
|
+ 'section+div{overflow:hidden} section+*>*{position:relative!important} article{border-bottom:1px solid!important} ' +
|
|
|
+ 'article section+div>ul>div>li{padding:6px 2px 12px!important}',
|
|
|
}))
|
|
|
.then(() => page.addStyleTag({
|
|
|
content: '*{font-family:-apple-system,".Helvetica Neue DeskInterface",Hiragino Sans,Hiragino Sans GB,sans-serif!important}',
|
|
@@ -149,7 +150,7 @@ class Webshot extends CallableInstance<[LazyMediaItem[], (...args) => void, numb
|
|
|
time = document.querySelector('article section~div>a>time');
|
|
|
if (time) {
|
|
|
time.innerHTML = time.title + ' ' + new Date(time.dateTime).toLocaleTimeString().slice(0, -3);
|
|
|
- time.parentElement.parentElement.style.margin = '-24px 0 12px';
|
|
|
+ time.parentElement.parentElement.style.margin = '-24px 2px 12px';
|
|
|
}
|
|
|
}))
|
|
|
.then(() => chainPromises(morePostProcessings.map(func => () => func(page))))
|