Implement support for DeArrow.

This commit is contained in:
Kavin
2023-07-19 01:40:12 +01:00
parent f5fbed04f5
commit b457eb5c70
4 changed files with 50 additions and 8 deletions

View File

@@ -137,8 +137,20 @@ export default {
},
loadMoreVideos() {
this.currentVideoCount = Math.min(this.currentVideoCount + this.videoStep, this.videosStore.length);
if (this.videos.length != this.videosStore.length)
if (this.videos.length != this.videosStore.length) {
const videoIds = this.videosStore
.slice(this.videos.length, this.currentVideoCount)
.map(video => video.url.substr(-11))
.sort();
if (this.getPreferenceBoolean("dearrow", false))
this.fetchDeArrowContent(videoIds).then(json => {
Object.keys(json).forEach(key => {
const video = this.videosStore.find(video => video.url.substr(-11) == key);
video.dearrow = json[key];
});
});
this.videos = this.videosStore.slice(0, this.currentVideoCount);
}
},
handleScroll() {
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - window.innerHeight) {
@@ -158,6 +170,11 @@ export default {
onFilterChange() {
this.setPreference("feedFilter", this.selectedFilter);
},
fetchDeArrowContent(videoIds) {
return this.fetchJson(this.apiUrl() + "/dearrow", {
videoIds: videoIds.join(","),
});
},
},
};
</script>