Skip to content

Commit

Permalink
video label on history pages
Browse files Browse the repository at this point in the history
  • Loading branch information
hanydd committed Jan 15, 2025
1 parent 8efcadd commit bab2fbd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/thumbnail-utils/thumbnail-selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const thumbnailSelectors: { [key: string]: ThumbnailSelector } = {
},
"historyPopup": {
// 历史视频弹出框
containerSelector: ".bili-header .right-entry .v-popover-wrap:nth-of-type(5) div.v-popover-content",
containerSelector: ".bili-header .right-entry .v-popover-wrap:nth-of-type(5)",
thumbnailSelector: "a.header-history-card",
},
"mainPageRecommendation": {
Expand Down Expand Up @@ -87,17 +87,25 @@ const thumbnailSelectors: { [key: string]: ThumbnailSelector } = {
containerSelector: ".search-page-wrapper",
thumbnailSelector: ".bili-video-card",
},
"oldHistory": {
// 旧历史页
containerSelector: ".list-contain",
thumbnailSelector: "li.history-record",
labelAnchorSelector: "a.preview img",
},
"history": {
// 历史页
containerSelector: ".main-content",
thumbnailSelector: ".history-card",
labelAnchorSelector: ".bili-cover-card__thumbnail > img",
},
};

const commonSelector = ["dynamicPopup", "favPopup", "historyPopup"];
const pageTypeSepecialSelector: { [key in PageType]: string[] } = {
[PageType.Main]: ["mainPageRecommendation"],
[PageType.History]: [],
[PageType.History]: ["history"],
[PageType.OldHistory]: ["oldHistory"],
[PageType.Video]: ["playerSideRecommendation", "playerListCard"],
[PageType.List]: ["listPlayerSideRecommendation", "listPlayerListCard"],
[PageType.Search]: ["search"],
Expand Down
2 changes: 1 addition & 1 deletion src/thumbnail-utils/thumbnailManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function checkPageForNewThumbnails() {
for (const { containerType, selector } of getThumbnailContainerElements(getPageType())) {
waitFor(() => document.querySelector(selector), 10000)
.then((thumbnailContainer) => labelNewThumbnails(thumbnailContainer, containerType))
.catch((err) => console.log(err));
.catch((err) => console.log("Fail to get ", selector, err));
}
}

Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export enum PageType {
Unknown = "unknown",
Main = "main",
History = "history",
OldHistory = "oldHistory",
Video = "video",
List = "list",
Search = "search",
Expand Down
4 changes: 3 additions & 1 deletion src/utils/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,10 @@ export function detectPageType(): void {
pageType = PageType.Video;
} else if (urlObject.pathname.startsWith("/list/")) {
pageType = PageType.List;
} else if (urlObject.pathname.startsWith("/account/history")) {
} else if (urlObject.pathname.startsWith("/history")) {
pageType = PageType.History;
} else if (urlObject.pathname.startsWith("/account/history")) {
pageType = PageType.OldHistory;
} else if (urlObject.pathname.startsWith("/bangumi/")) {
pageType = PageType.Anime;
} else {
Expand Down

0 comments on commit bab2fbd

Please sign in to comment.