You've already forked bilibili-subtitle
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8c867a381a | ||
![]() |
fbcc751c5c | ||
![]() |
4896722d1f | ||
![]() |
ce2a2da6f5 | ||
![]() |
368f5d721c | ||
![]() |
21e2ca958c | ||
![]() |
149653ffac | ||
![]() |
f977b5e238 | ||
![]() |
c13ef4597b | ||
![]() |
65026f62af | ||
![]() |
bcff8b4f90 |
10
README.md
10
README.md
@@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
- [chrome商店](https://chrome.google.com/webstore/detail/bciglihaegkdhoogebcdblfhppoilclp)
|
- [chrome商店](https://chrome.google.com/webstore/detail/bciglihaegkdhoogebcdblfhppoilclp)
|
||||||
- [edge商店](https://microsoftedge.microsoft.com/addons/detail/lignnlhlpiefmcjkdkmfjdckhlaiajan)
|
- [edge商店](https://microsoftedge.microsoft.com/addons/detail/lignnlhlpiefmcjkdkmfjdckhlaiajan)
|
||||||
- [firefox商店](https://addons.mozilla.org/zh-CN/firefox/addon/bilibili-subtitle)
|
|
||||||
|
|
||||||
## 使用说明
|
## 使用说明
|
||||||
|
|
||||||
@@ -46,13 +45,14 @@ github: [IndieKKY](https://github.com/IndieKKY)
|
|||||||
node版本:18.15.0
|
node版本:18.15.0
|
||||||
包管理器:pnpm
|
包管理器:pnpm
|
||||||
|
|
||||||
- 本地调试:`pnpm run dev`,然后加载`dist`目录。
|
- 本地调试:`pnpm run dev`,然后浏览器扩展管理页面,开启开发者模式,再加载已解压的扩展程序,选择`dist`目录。
|
||||||
- 打生产包:`pnpm run build`,然后加载`dist`目录。
|
- 打生产包:`pnpm run build`,然后浏览器扩展管理页面,开启开发者模式,再加载已解压的扩展程序,选择`dist`目录。
|
||||||
|
|
||||||
注:`./push.sh`是作者自用脚本,可以忽略。
|
注:`./push.sh`是作者自用脚本,可以忽略。
|
||||||
|
|
||||||
提示:本地edge开发调试可能有问题,会报csp错误!本地开发调试推荐用chrome。
|
提示:最新版浏览器安全方面有更新,开发调试可能有问题,会报csp错误!
|
||||||
构建后应该正常,关键是fix.cjs里将use_dynamic_url设置为false的这个操作。
|
暂时的解决办法是`pnpm run dev`运行起来后,手动将`dist/manifest.json`文件里的web_accessible_resources里的use_dynamic_url都修改为false,然后浏览器扩展管理页面点击重载一下,就能正常(是@crxjs/vite-plugin依赖的问题,这个依赖很长时间没更新了,这个bug也没修复,暂时没发现更好的解决办法)。
|
||||||
|
构建后正常,关键是fix.cjs里将use_dynamic_url设置为false的这个操作。
|
||||||
|
|
||||||
## 贡献指南
|
## 贡献指南
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"name": "bilibili-subtitle",
|
"name": "bilibili-subtitle",
|
||||||
"version": "1.11.11",
|
"version": "1.11.14",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "哔哩哔哩字幕列表",
|
"description": "哔哩哔哩字幕列表",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
@@ -7,13 +7,17 @@ const getServerUrl = (serverUrl?: string) => {
|
|||||||
if (serverUrl.endsWith('/')) {
|
if (serverUrl.endsWith('/')) {
|
||||||
serverUrl = serverUrl.slice(0, -1)
|
serverUrl = serverUrl.slice(0, -1)
|
||||||
}
|
}
|
||||||
|
//如果serverUrl不以/vxxx结尾,则添加/v1
|
||||||
|
if (!/\/v\d+$/.test(serverUrl.toLowerCase())) {
|
||||||
|
serverUrl += '/v1'
|
||||||
|
}
|
||||||
return serverUrl
|
return serverUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
export const handleChatCompleteTask = async (task: Task) => {
|
export const handleChatCompleteTask = async (task: Task) => {
|
||||||
const data = task.def.data
|
const data = task.def.data
|
||||||
const serverUrl = getServerUrl(task.def.serverUrl)
|
const serverUrl = getServerUrl(task.def.serverUrl)
|
||||||
const resp = await fetch(`${serverUrl}/v1/chat/completions`, {
|
const resp = await fetch(`${serverUrl}/chat/completions`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
@@ -83,8 +83,8 @@ const Header = (props: {
|
|||||||
}
|
}
|
||||||
}}>
|
}}>
|
||||||
<div className='shrink-0 flex items-center'>
|
<div className='shrink-0 flex items-center'>
|
||||||
<img src="bibijun.png" alt="Logo" className="w-auto h-6 ml-2 mr-1" />
|
{/* <img src="bibijun.png" alt="Logo" className="w-auto h-6 ml-2 mr-1" /> */}
|
||||||
{/* <span className='shrink-0 text-[15px] font-medium pl-1 pr-[14px]'>字幕列表</span> */}
|
<span className='shrink-0 text-[15px] font-medium pl-[16px] pr-[14px]'>字幕列表</span>
|
||||||
<MoreBtn placement={'right-start'}/>
|
<MoreBtn placement={'right-start'}/>
|
||||||
</div>
|
</div>
|
||||||
<div className='flex gap-0.5 items-center mr-[16px]'>
|
<div className='flex gap-0.5 items-center mr-[16px]'>
|
||||||
|
@@ -210,7 +210,7 @@ const SegmentCard = (props: {
|
|||||||
}, [dispatch])
|
}, [dispatch])
|
||||||
|
|
||||||
return <div
|
return <div
|
||||||
className={classNames('border border-base-300 bg-base-200/25 rounded flex flex-col m-1.5 p-1.5 gap-1 shadow', showCurrent && 'shadow-primary')}>
|
className={classNames('border border-base-300 bg-base-200/25 rounded flex flex-col m-1.5 p-1.5 gap-1', showCurrent && 'shadow shadow-md')}>
|
||||||
<div className='relative flex justify-center min-h-[20px]'>
|
<div className='relative flex justify-center min-h-[20px]'>
|
||||||
{segments != null && segments.length > 0 &&
|
{segments != null && segments.length > 0 &&
|
||||||
<div className='absolute left-0 top-0 bottom-0 text-xs select-none flex-center desc'>
|
<div className='absolute left-0 top-0 bottom-0 text-xs select-none flex-center desc'>
|
||||||
|
@@ -265,7 +265,7 @@ export const SUMMARIZE_THRESHOLD = 100
|
|||||||
export const SUMMARIZE_LANGUAGE_DEFAULT = 'cn'
|
export const SUMMARIZE_LANGUAGE_DEFAULT = 'cn'
|
||||||
export const SUMMARIZE_ALL_THRESHOLD = 5
|
export const SUMMARIZE_ALL_THRESHOLD = 5
|
||||||
export const ASK_ENABLED_DEFAULT = true
|
export const ASK_ENABLED_DEFAULT = true
|
||||||
export const DEFAULT_SERVER_URL_OPENAI = 'https://api.openai.com'
|
export const DEFAULT_SERVER_URL_OPENAI = 'https://api.openai.com/v1'
|
||||||
export const CUSTOM_MODEL_TOKENS = 16385
|
export const CUSTOM_MODEL_TOKENS = 16385
|
||||||
|
|
||||||
export const MODEL_TIP = '推荐gpt-4o-mini,能力强,价格低,token上限大'
|
export const MODEL_TIP = '推荐gpt-4o-mini,能力强,价格低,token上限大'
|
||||||
|
@@ -167,7 +167,7 @@ const debug = (...args: any[]) => {
|
|||||||
ctime = pages[0].ctime
|
ctime = pages[0].ctime
|
||||||
author = pages[0].owner?.name
|
author = pages[0].owner?.name
|
||||||
title = pages[0].part
|
title = pages[0].part
|
||||||
await fetch(`https://api.bilibili.com/x/player/v2?aid=${aid}&cid=${cid}`, { credentials: 'include' }).then(res => res.json()).then(res => {
|
await fetch(`https://api.bilibili.com/x/player/wbi/v2?aid=${aid}&cid=${cid}`, { credentials: 'include' }).then(res => res.json()).then(res => {
|
||||||
subtitles = res.data.subtitle.subtitles
|
subtitles = res.data.subtitle.subtitles
|
||||||
})
|
})
|
||||||
} else {//bvxxx
|
} else {//bvxxx
|
||||||
@@ -179,7 +179,7 @@ const debug = (...args: any[]) => {
|
|||||||
author = res.data.owner?.name
|
author = res.data.owner?.name
|
||||||
pages = res.data.pages
|
pages = res.data.pages
|
||||||
})
|
})
|
||||||
await fetch(`https://api.bilibili.com/x/player/v2?aid=${aid}&cid=${cid}`, { credentials: 'include' }).then(res => res.json()).then(res => {
|
await fetch(`https://api.bilibili.com/x/player/wbi/v2?aid=${aid}&cid=${cid}`, { credentials: 'include' }).then(res => res.json()).then(res => {
|
||||||
subtitles = res.data.subtitle.subtitles
|
subtitles = res.data.subtitle.subtitles
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -226,15 +226,18 @@ const debug = (...args: any[]) => {
|
|||||||
lastAid = aid
|
lastAid = aid
|
||||||
lastCid = cid
|
lastCid = cid
|
||||||
if (aid && cid) {
|
if (aid && cid) {
|
||||||
fetch(`https://api.bilibili.com/x/player/v2?aid=${aid}&cid=${cid}`, {
|
fetch(`https://api.bilibili.com/x/player/wbi/v2?aid=${aid}&cid=${cid}`, {
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
})
|
})
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(res => {
|
.then(res => {
|
||||||
// console.log('refreshSubtitles: ', aid, cid, res)
|
//remove elements with empty subtitle_url
|
||||||
|
res.data.subtitle.subtitles = res.data.subtitle.subtitles.filter((item: any) => item.subtitle_url)
|
||||||
|
if (res.data.subtitle.subtitles.length > 0) {
|
||||||
runtime.injectMessaging.sendApp('SET_INFOS', {
|
runtime.injectMessaging.sendApp('SET_INFOS', {
|
||||||
infos: res.data.subtitle.subtitles
|
infos: res.data.subtitle.subtitles
|
||||||
})
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -119,16 +119,6 @@ export const getSummaryStr = (summary: Summary) => {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getServerUrl = (serverUrl?: string) => {
|
|
||||||
if (!serverUrl) {
|
|
||||||
return 'https://api.openai.com'
|
|
||||||
}
|
|
||||||
if (serverUrl.endsWith('/')) {
|
|
||||||
serverUrl = serverUrl.slice(0, -1)
|
|
||||||
}
|
|
||||||
return serverUrl
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getModel = (envData: EnvData) => {
|
export const getModel = (envData: EnvData) => {
|
||||||
if (envData.model === 'custom') {
|
if (envData.model === 'custom') {
|
||||||
return envData.customModel
|
return envData.customModel
|
||||||
|
@@ -3,7 +3,11 @@ module.exports = {
|
|||||||
darkMode: 'class',
|
darkMode: 'class',
|
||||||
content: ["./src/**/*.{js,ts,jsx,tsx}"],
|
content: ["./src/**/*.{js,ts,jsx,tsx}"],
|
||||||
theme: {
|
theme: {
|
||||||
extend: {},
|
extend: {
|
||||||
|
fontSize: {
|
||||||
|
xs: '13px',
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
require('tailwind-scrollbar-hide'),
|
require('tailwind-scrollbar-hide'),
|
||||||
|
Reference in New Issue
Block a user