mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Add autoLike (#2354)
This commit is contained in:
parent
b81cfc0ba4
commit
60148c1110
1
registry/lib/components/utils/auto-like/index.md
Normal file
1
registry/lib/components/utils/auto-like/index.md
Normal file
@ -0,0 +1 @@
|
||||
进入视频 / 查看动态时, 自动点赞.
|
||||
53
registry/lib/components/utils/auto-like/index.ts
Normal file
53
registry/lib/components/utils/auto-like/index.ts
Normal file
@ -0,0 +1,53 @@
|
||||
import { defineComponentMetadata } from '@/components/define'
|
||||
import { forEachFeedsCard } from '@/components/feeds/api'
|
||||
import { select } from '@/core/spin-query'
|
||||
import { matchUrlPattern, playerReady } from '@/core/utils'
|
||||
import { feedsUrls, videoAndBangumiUrls } from '@/core/utils/urls'
|
||||
|
||||
const feedsLikeQueue = [] as HTMLElement[]
|
||||
export const component = defineComponentMetadata({
|
||||
name: 'autoLike',
|
||||
displayName: '自动点赞',
|
||||
tags: [componentsTags.utils, componentsTags.feeds, componentsTags.video],
|
||||
urlInclude: [...videoAndBangumiUrls, ...feedsUrls],
|
||||
options: {
|
||||
video: {
|
||||
defaultValue: true,
|
||||
displayName: '对视频点赞',
|
||||
},
|
||||
feed: {
|
||||
defaultValue: true,
|
||||
displayName: '对动态点赞',
|
||||
},
|
||||
},
|
||||
entry: async ({ settings: { options } }) => {
|
||||
if (options.video && videoAndBangumiUrls.some(url => matchUrlPattern(url))) {
|
||||
await playerReady()
|
||||
const likeButton = (await select(
|
||||
'.video-toolbar .like, .tool-bar .like-info, .video-toolbar-v1 .like',
|
||||
)) as HTMLSpanElement
|
||||
if (!likeButton || likeButton.classList.contains('on')) {
|
||||
return
|
||||
}
|
||||
likeButton.click()
|
||||
}
|
||||
if (options.feed && feedsUrls.some(url => matchUrlPattern(url))) {
|
||||
window.setInterval(() => {
|
||||
if (feedsLikeQueue.length === 0) {
|
||||
return
|
||||
}
|
||||
const button = feedsLikeQueue.shift()
|
||||
button?.click()
|
||||
}, 1000)
|
||||
forEachFeedsCard({
|
||||
added: card => {
|
||||
const likeButton = dq(card.element, '.bili-dyn-action.like') as HTMLElement
|
||||
if (!likeButton || likeButton.classList.contains('active')) {
|
||||
return
|
||||
}
|
||||
feedsLikeQueue.push(likeButton)
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
Loading…
Reference in New Issue
Block a user