Skip to content

Commit

Permalink
feat: bili player
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Jul 3, 2024
1 parent 9f10928 commit 2d0537b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/main/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ export function createWindow(
},
)

window.webContents.session.webRequest.onBeforeRequest(async (details, callback) => {
const { url } = details

if (url.startsWith("https://s1.hdslb.com/bfs/seed/jinkela/short/player/player-util.js")) {
callback({
cancel: false,
redirectURL: `https://assets.follow.is/player-util.js`,
})
} else {
callback({ cancel: false })
}
})

return window
}

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/lib/url-to-iframe.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const urlToIframe = (url?: string | null) => {
if (url?.match(/\/\/www.bilibili.com\/video\/BV\w+/)) {
return `https://player.bilibili.com/player.html?${new URLSearchParams({
return `https://www.bilibili.com/blackboard/newplayer.html?${new URLSearchParams({
isOutside: "true",
autoplay: "true",
danmaku: "true",
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/modules/entry-column/video-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function VideoItem({ entryId, entryPreview, translation }: UniversalItemP
// eslint-disable-next-line @eslint-react/dom/no-missing-iframe-sandbox
<iframe
src={iframeSrc}
className={cn("pointer-events-none aspect-video w-full shrink-0 rounded-md bg-black object-cover", isActive && "rounded-b-none")}
className={cn("aspect-video w-full shrink-0 rounded-md bg-black object-cover", isActive && "rounded-b-none")}
/>
) : (
<Image
Expand Down

0 comments on commit 2d0537b

Please sign in to comment.