10 Commits

Author SHA1 Message Date
IndieKKY
ee1eaf9e08 chore: release 1.11.11 2024-10-19 15:21:47 +08:00
IndieKKY
cc732de8e6 fix csp 2024-10-19 15:21:24 +08:00
IndieKKY
cccf7e6149 chore: release 1.11.10 2024-10-16 09:08:09 +08:00
IndieKKY
30dc724ebb 断开连接提示 2024-10-16 09:07:49 +08:00
IndieKKY
51a7e998b9 chore: release 1.11.9 2024-10-13 21:14:44 +08:00
IndieKKY
556ccef4b2 代理推荐 2024-10-13 21:12:10 +08:00
IndieKKY
42b719fb98 语言文件 2024-10-13 21:12:04 +08:00
IndieKKY
fa66445466 chore: release 1.11.8 2024-10-12 14:01:32 +08:00
IndieKKY
d711b2abf8 bibigpt 2024-10-12 14:01:16 +08:00
IndieKKY
47fcb1de11 bibigpt 2024-10-12 14:01:07 +08:00
10 changed files with 67 additions and 32 deletions

View File

@@ -51,6 +51,9 @@ node版本18.15.0
注:`./push.sh`是作者自用脚本,可以忽略。 注:`./push.sh`是作者自用脚本,可以忽略。
提示本地edge开发调试可能有问题会报csp错误本地开发调试推荐用chrome。
构建后应该正常关键是fix.cjs里将use_dynamic_url设置为false的这个操作。
## 贡献指南 ## 贡献指南
欢迎贡献代码或提出改进建议!如果您希望为该项目做出贡献,请遵循以下步骤: 欢迎贡献代码或提出改进建议!如果您希望为该项目做出贡献,请遵循以下步骤:

View File

@@ -5,4 +5,11 @@ const fs = require('fs')
//copy index.html to sidepanel.html //copy index.html to sidepanel.html
fs.copyFileSync('./dist/index.html', './dist/sidepanel.html') fs.copyFileSync('./dist/index.html', './dist/sidepanel.html')
//set all use_dynamic_url to false
const manifest = require('./dist/manifest.json')
manifest.web_accessible_resources.forEach(resource => {
resource.use_dynamic_url = false
})
fs.writeFileSync('./dist/manifest.json', JSON.stringify(manifest, null, 2))
console.log('fix.js done'); console.log('fix.js done');

View File

@@ -12,9 +12,10 @@ const [major, minor, patch, label = '0'] = version
.split(/[.-]/) .split(/[.-]/)
export default defineManifest(async (env) => ({ export default defineManifest(async (env) => ({
"name": "哔哔君 - bilibili哔哩哔哩字幕列表", "name": '__MSG_appName__',
"description": "显示B站视频的字幕列表,可点击跳转与下载字幕,并支持翻译和总结字幕!", "description": '__MSG_appDescription__',
"version": `${major}.${minor}.${patch}`, "version": `${major}.${minor}.${patch}`,
"default_locale": "zh_CN",
"manifest_version": 3, "manifest_version": 3,
"permissions": [ "permissions": [
"sidePanel", "sidePanel",
@@ -56,7 +57,7 @@ export default defineManifest(async (env) => ({
"resources": [ "resources": [
"index.html", "index.html",
], ],
"use_dynamic_url": true "use_dynamic_url": false
} }
] ]
})) }))

View File

@@ -1,7 +1,7 @@
{ {
"private": true, "private": true,
"name": "bilibili-subtitle", "name": "bilibili-subtitle",
"version": "1.11.7", "version": "1.11.11",
"type": "module", "type": "module",
"description": "哔哩哔哩字幕列表", "description": "哔哩哔哩字幕列表",
"main": "index.js", "main": "index.js",

View File

@@ -0,0 +1,8 @@
{
"appName": {
"message": "哔哔君 - bilibili哔哩哔哩字幕列表"
},
"appDescription": {
"message": "显示B站视频的字幕列表,可点击跳转与下载字幕,并支持翻译和总结字幕!"
}
}

BIN
public/bibigpt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@@ -39,6 +39,7 @@ import Ask from './Ask'
import { v4 } from 'uuid' import { v4 } from 'uuid'
import RateExtension from '../components/RateExtension' import RateExtension from '../components/RateExtension'
import ApiKeyReminder from './ApiKeyReminder' import ApiKeyReminder from './ApiKeyReminder'
import useMessaging from '@/messaging/layer2/useMessaging'
const Body = () => { const Body = () => {
const dispatch = useAppDispatch() const dispatch = useAppDispatch()
@@ -65,6 +66,7 @@ const Body = () => {
// const fontSize = useAppSelector(state => state.env.envData.fontSize) // const fontSize = useAppSelector(state => state.env.envData.fontSize)
const searchText = useAppSelector(state => state.env.searchText) const searchText = useAppSelector(state => state.env.searchText)
const asks = useAppSelector(state => state.env.asks) const asks = useAppSelector(state => state.env.asks)
const {disconnected} = useMessaging()
// const recommendIdx = useMemo(() => random(0, 3), []) // const recommendIdx = useMemo(() => random(0, 3), [])
const showSearchInput = useMemo(() => { const showSearchInput = useMemo(() => {
return (segments != null && segments.length > 0) && (envData.searchEnabled ? envData.searchEnabled : (envData.askEnabled ?? ASK_ENABLED_DEFAULT)) return (segments != null && segments.length > 0) && (envData.searchEnabled ? envData.searchEnabled : (envData.askEnabled ?? ASK_ENABLED_DEFAULT))
@@ -262,6 +264,10 @@ const Body = () => {
{searchText && <button className='absolute top-1 right-2 btn btn-ghost btn-xs btn-circle text-base-content/75' onClick={onClearSearchText}><AiOutlineCloseCircle /></button>} {searchText && <button className='absolute top-1 right-2 btn btn-ghost btn-xs btn-circle text-base-content/75' onClick={onClearSearchText}><AiOutlineCloseCircle /></button>}
</div>} </div>}
{disconnected && <div className='flex flex-col justify-center items-center gap-2 text-sm bg-red-400 rounded mx-2'>
<span className='flex items-center gap-1 text-white'><AiOutlineCloseCircle className='text-white' /></span>
</div>}
{/* auto scroll btn */} {/* auto scroll btn */}
{!autoScroll && <div {!autoScroll && <div
className='absolute z-[999] top-[96px] right-6 tooltip tooltip-left cursor-pointer rounded-full bg-primary/25 hover:bg-primary/75 text-primary-content p-1.5 text-xl' className='absolute z-[999] top-[96px] right-6 tooltip tooltip-left cursor-pointer rounded-full bg-primary/25 hover:bg-primary/75 text-primary-content p-1.5 text-xl'
@@ -304,22 +310,22 @@ const Body = () => {
{/* </button>} */} {/* </button>} */}
{/* </div> */} {/* </div> */}
<div className='flex flex-col'> <div className='flex flex-col'>
{/* <div className='flex flex-col items-center text-center py-2 mx-4 border-t border-t-base-300'> */} <div className='flex flex-col items-center text-center py-2 mx-4 border-t border-t-base-300'>
{/* <div className='font-semibold text-accent flex items-center gap-1'><img src='/bibigpt.png' */} <div className='font-semibold text-accent flex items-center gap-1'><img src='/bibigpt.png'
{/* alt='BibiGPT logo' */} alt='BibiGPT logo'
{/* className='w-8 h-8'/>BibiGPT */} className='w-8 h-8'/>BibiGPT
{/* </div> */} </div>
{/* <div className='text-sm px-2 desc'>这是<span className='text-amber-600 font-semibold text-base'>网页</span>版的字幕列表,支持<span */} <div className='text-sm px-2 desc'><span className='text-amber-600 font-semibold text-base'></span><span
{/* className='font-semibold'>任意</span>视频提取字幕总结(包括没有字幕的视频) */} className='font-semibold'></span>
{/* </div> */} </div>
{/* <div className='flex gap-2'> */} <div className='flex gap-2'>
{/* <a title='BibiGPT' href='https://bibigpt.co/r/bilibili' */} <a title='BibiGPT' href='https://bibigpt.co/r/bilibili'
{/* onClick={(e) => { */} onClick={(e) => {
{/* e.preventDefault() */} e.preventDefault()
{/* openUrl('https://bibigpt.co/r/bilibili') */} openUrl('https://bibigpt.co/r/bilibili')
{/* }} className='link text-sm text-accent'>✨ BibiGPT ✨</a> */} }} className='link text-sm text-accent'> BibiGPT </a>
{/* </div> */} </div>
{/* </div> */} </div>
<div className='flex flex-col items-center text-center py-2 mx-4 border-t border-t-base-300'> <div className='flex flex-col items-center text-center py-2 mx-4 border-t border-t-base-300'>
<div className='font-semibold text-accent flex items-center gap-1'><img src='/youtube-caption.png' <div className='font-semibold text-accent flex items-center gap-1'><img src='/youtube-caption.png'
alt='youtube caption logo' alt='youtube caption logo'

View File

@@ -25,6 +25,7 @@ class Layer1Protocol<L1Req = any, L1Res = any> {
private timeout: number private timeout: number
private requests: Map<string, { resolve: (value: L1Res) => void, reject: (reason?: any) => void, timer: number }> private requests: Map<string, { resolve: (value: L1Res) => void, reject: (reason?: any) => void, timer: number }>
private handler: Handler<L1Req, L1Res> private handler: Handler<L1Req, L1Res>
public disconnected: boolean = false
constructor(handler: Handler<L1Req, L1Res>, port: chrome.runtime.Port, autoDispose = true, timeout = 30000) { // 默认超时 30 秒 constructor(handler: Handler<L1Req, L1Res>, port: chrome.runtime.Port, autoDispose = true, timeout = 30000) { // 默认超时 30 秒
this.port = port; this.port = port;
@@ -82,6 +83,7 @@ class Layer1Protocol<L1Req = any, L1Res = any> {
} }
dispose() { dispose() {
this.disconnected = true
this.port.onMessage.removeListener(this._messageListener); this.port.onMessage.removeListener(this._messageListener);
if (this.port.onDisconnect) { if (this.port.onDisconnect) {
this.port.onDisconnect.removeListener(this.dispose); this.port.onDisconnect.removeListener(this.dispose);

View File

@@ -1,12 +1,18 @@
import { msgWaiter } from './useMessagingService' import { msgWaiter } from './useMessagingService'
import { useCallback } from 'react' import { useCallback, useState } from 'react'
import Layer1Protocol from '../layer1/Layer1Protocol' import Layer1Protocol from '../layer1/Layer1Protocol'
import { L2ReqMsg, L2ResMsg, TAG_TARGET_INJECT } from '../const' import { L2ReqMsg, L2ResMsg, TAG_TARGET_INJECT } from '../const'
const useMessaging = <AllExtensionMessagesType extends ExtensionMessage, AllInjectMessagesType extends InjectMessage>() => { const useMessaging = <AllExtensionMessagesType extends ExtensionMessage, AllInjectMessagesType extends InjectMessage>() => {
const [disconnected, setDisconnected] = useState(false)
const sendExtension = useCallback(async <M extends AllExtensionMessagesType | MessagingExtensionMessages, K extends M['method']>(method: K, params?: Extract<M, { method: K }>['params']): Promise<Extract<M, { method: K }>['return']> => { const sendExtension = useCallback(async <M extends AllExtensionMessagesType | MessagingExtensionMessages, K extends M['method']>(method: K, params?: Extract<M, { method: K }>['params']): Promise<Extract<M, { method: K }>['return']> => {
// wait // wait
const pmh = await msgWaiter.wait() as Layer1Protocol<L2ReqMsg, L2ResMsg> const pmh = await msgWaiter.wait() as Layer1Protocol<L2ReqMsg, L2ResMsg>
if (pmh.disconnected) {
setDisconnected(true)
throw new Error('disconnected')
}
// send message // send message
const res = await pmh.sendMessage({ const res = await pmh.sendMessage({
from: 'app', from: 'app',
@@ -30,7 +36,8 @@ const useMessaging = <AllExtensionMessagesType extends ExtensionMessage, AllInje
return { return {
sendExtension, sendExtension,
sendInject sendInject,
disconnected
} }
} }

View File

@@ -27,7 +27,7 @@ import toast from 'react-hot-toast'
import {useBoolean, useEventTarget} from 'ahooks' import {useBoolean, useEventTarget} from 'ahooks'
import {useEventChecked} from '@kky002/kky-hooks' import {useEventChecked} from '@kky002/kky-hooks'
import { useMessage } from '@/hooks/message' import { useMessage } from '@/hooks/message'
import { FaChevronDown, FaChevronUp } from 'react-icons/fa' import { FaChevronDown, FaChevronUp, FaGripfire } from 'react-icons/fa'
const OptionCard = ({ title, children, defaultExpanded = true }: { title: React.ReactNode; children: React.ReactNode; defaultExpanded?: boolean }) => { const OptionCard = ({ title, children, defaultExpanded = true }: { title: React.ReactNode; children: React.ReactNode; defaultExpanded?: boolean }) => {
const [isExpanded, setIsExpanded] = useState(defaultExpanded); const [isExpanded, setIsExpanded] = useState(defaultExpanded);
@@ -261,14 +261,15 @@ const OptionsPage = () => {
<div><a className='link link-primary' <div><a className='link link-primary'
onClick={() => setServerUrlValue(DEFAULT_SERVER_URL_OPENAI)} onClick={() => setServerUrlValue(DEFAULT_SERVER_URL_OPENAI)}
rel='noreferrer'></a></div> rel='noreferrer'></a></div>
{/* <div className='flex justify-center font-semibold'>【第三方代理】</div> */} <div className='flex justify-center font-semibold'></div>
{/* <div>代理网址:<a className='link link-primary' href='https://api.openai-up.com/register?aff=varM' */} <div><a className='link link-primary' href='https://api.kksj.org/register?aff=ucVc'
{/* target='_blank' */} target='_blank'
{/* rel="noreferrer">点击访问</a></div> */} rel="noreferrer">访</a></div>
{/* <div>服务器地址:<a className='link link-primary' */} <div><a className='link link-primary'
{/* onClick={() => setServerUrlValue('https://api.openai-up.com')} */} onClick={() => setServerUrlValue('https://api.kksj.org')}
{/* rel='noreferrer'>点击设置</a></div> */} rel='noreferrer'></a></div>
{/* <div className='text-amber-600 flex justify-center items-center'><FaGripfire/>目前价格不到官方价格的6折<FaGripfire/></div> */} <div className='text-amber-600 flex justify-center items-center'><FaGripfire/>0.91(1/8)<FaGripfire/></div>
<div className='text-amber-600 flex justify-center items-center'><FaGripfire/>访🪜<FaGripfire/></div>
</div> </div>
</div>} </div>}
{(!aiTypeValue || aiTypeValue === 'openai') && <FormItem title='模型选择' htmlFor='modelSel' tip='注意不同模型有不同价格与token限制'> {(!aiTypeValue || aiTypeValue === 'openai') && <FormItem title='模型选择' htmlFor='modelSel' tip='注意不同模型有不同价格与token限制'>