diff --git a/src/background/apis/videos.ts b/src/background/apis/videos.ts index 09e1184e..85ea829b 100644 --- a/src/background/apis/videos.ts +++ b/src/background/apis/videos.ts @@ -2,9 +2,10 @@ import browser from 'webextension-polyfill' import { APP_URL } from '.' export const setupVideosAPIs = () => { - browser.runtime.onMessage.addListener(message => { + browser.runtime.onMessage.addListener((message) => { /** Recommend Videos */ if (message.contentScriptQuery === 'getRecommendVideos') { + // https://github.com/indefined/UserScripts/blob/master/bilibiliHome/bilibiliHome.API.md#%E8%8E%B7%E5%8F%96%E9%A6%96%E9%A1%B5%E5%86%85%E5%AE%B9 const url = `${APP_URL}/x/feed/index?build=1&idx=${message.idx}&appkey=27eb53fc9058f8c3&access_key=${message.accessKey}` return fetch(url) .then(response => response.json()) diff --git a/src/components/VideoCard.vue b/src/components/VideoCard.vue new file mode 100644 index 00000000..2cdc307b --- /dev/null +++ b/src/components/VideoCard.vue @@ -0,0 +1,345 @@ + + + + + + + + {{ $t('home.video_removed') }} + + {{ $t('common.undo') }} + + + + + + + {{ calcCurrentTime(duration) }} + + + + + + + + + + + + + + + + {{ title }} + + + + + + + + + + + + + + {{ $t('home.not_interested_in') }} + + + + {{ reason.reason_name }} + + + + + + + {{ channelName }} + + + {{ numFormatter(viewCount) + }}{{ + language === LanguageType.English + ? ` ${$t('common.view', viewCount)}` + : $t('common.view', viewCount) + }} + • + {{ calcTimeSince(ctime * 1000) + }}{{ + language === LanguageType.English + ? ` ${$t('common.ago')}` + : $t('common.ago') + }} + + + + + + + + diff --git a/src/contentScripts/views/Home/RecommendContent.vue b/src/contentScripts/views/Home/RecommendContent.vue index 82d57996..9b75debe 100644 --- a/src/contentScripts/views/Home/RecommendContent.vue +++ b/src/contentScripts/views/Home/RecommendContent.vue @@ -69,67 +69,6 @@ export default defineComponent({ } } }, - gotoChannel(mid: number) { - window.open(`//space.bilibili.com/${mid}`) - }, - gotoVideo(uri: string) { - window.open(`/video/av${uri.split('/')[3]}`) - }, - submitDislike( - videoIndex: number, - reasonID: number, - goto: string, - id: string, - mid: string, - rid: string, - tagID: string, - ) { - browser.runtime - .sendMessage({ - contentScriptQuery: 'submitDislike', - accessKey: this.accessKey, - reasonID, - goto, - id, - mid, - rid, - tagID, - }) - .then((res) => { - if (res.code === 0) { - this.videoList[videoIndex].isDislike = true - this.videoList[videoIndex].selectedReasonID = reasonID - } - }) - }, - undoDislike( - videoIndex: number, - reasonID: number, - goto: string, - id: string, - mid: string, - rid: string, - tagID: string, - ) { - browser.runtime - .sendMessage({ - contentScriptQuery: 'undoDislike', - accessKey: this.accessKey, - reasonID, - goto, - id, - mid, - rid, - tagID, - }) - .then((res) => { - if (res.code === 0) { - this.videoList[videoIndex].isDislike = false - this.videoList[videoIndex].selectedReasonID = undefined - this.videoList[videoIndex].openControl = false - } - }) - }, onRefresh() { this.isLoading = true this.videoList = [] @@ -148,184 +87,25 @@ export default defineComponent({ m="lg:x-22 - - + - - - - {{ $t('home.video_removed') }} - - {{ $t('common.undo') }} - - - - - - - {{ calcCurrentTime(video.duration) }} - - - - - - - - - - - - - - - - {{ video.title }} - - - - - - - - - - - - - - {{ $t('home.not_interested_in') }} - - - - {{ reason.reason_name }} - - - - - - - {{ video.name }} - - - {{ numFormatter(video.play) - }}{{ - language === LanguageType.English - ? ` ${$t('common.view', video.play)}` - : $t('common.view', video.play) - }} - • - {{ calcTimeSince(new Date(video.ctime * 1000)) - }}{{ - language === LanguageType.English - ? ` ${$t('common.ago')}` - : $t('common.ago') - }} - - - - - - + :cover="video.cover" + :duration="video.duration" + :mid="video.mid" + :title="video.title" + :author-avatar="video.face" + :param="video.param" + :view-count="video.play" + :channel-name="video.name" + :ctime="video.ctime" + :dislike-reasons="video.dislike_reasons" + :goto="video.goto" + :tid="video.tid" + :tag="video.tag" + /> + @@ -370,83 +150,4 @@ export default defineComponent({ .list-leave-active { display: none; } - -.video-card { - @apply p-1 mb-8 rounded-$bew-radius duration-300 - relative - active:bg-$bew-fill-2; - - &.is-dislike { - > *:not(#dislike-control) { - @apply invisible pointer-events-none duration-0 transition-none; - } - } - - .cover-shadow { - @apply absolute top-0 left-0 w-full h-full filter -z-1 - pointer-events-none duration-600 rounded-$bew-radius opacity-70; - aspect-ratio: 16/9; - } - - &:hover .cover-shadow { - @apply blur-2xl transform; - } - - .thumbnail { - @apply w-full rounded-$bew-radius relative duration-300; - aspect-ratio: 16/9; - - .duration { - @apply absolute z-2 bottom-0 right-0 px-2 py-1 - m-1 rounded-$bew-radius text-xs - text-white - bg-black bg-opacity-60; - } - - .cover { - @apply w-full h-full bg-cover bg-center transform scale-110 duration-300 - absolute bg-$bew-fill-3; - aspect-ratio: 16/9; - } - } - - &:hover .thumbnail { - @apply transform scale-105; - } - - &:hover .cover { - @apply transform scale-100; - } - - .detail { - @apply flex mt-4; - - .avatar { - @apply mr-4 h-48px rounded-$bew-radius overflow-hidden - object-center object-cover - bg-$bew-fill-3; - } - - .meta { - @apply flex flex-col items-start '!w-full'; - - .video-title { - @apply text-lg max-h-13 overflow-hidden overflow-ellipsis whitespace-normal - text-$bew-text-1; - display: -webkit-box; - -webkit-box-orient: vertical; - -webkit-line-clamp: 2; - } - - .channel-name, - .video-info { - @apply text-base text-$bew-text-2; - } - - .channel-name { - @apply mt-2; - } - } - } -}
+ {{ $t('home.not_interested_in') }} +
- {{ $t('home.not_interested_in') }} -