Merge pull request #2 from jimliang/main

Add support for javlibrary
This commit is contained in:
Asimov
2025-05-29 10:46:22 +12:00
committed by GitHub
2 changed files with 34 additions and 28 deletions

View File

@@ -5,7 +5,7 @@ import { addOrUpdateNavigationButtons, hideNavigationButtons } from '../../compo
const STORAGE_KEY = 'feature_enabled';
export default defineContentScript({
matches: ['*://*.javdb.com/v/*'],
matches: ['*://*.javdb.com/v/*', '*://*.javlibrary.com/*'],
async main() {
const isEnabled = await storage.getItem(`sync:${STORAGE_KEY}`) ?? true;
@@ -19,7 +19,6 @@ export default defineContentScript({
console.log('🚀 [JavDB Helper] 功能已启用,正在运行脚本...');
const processPage = async () => {
if (window.location.pathname.startsWith('/v/')) {
const videoNumber = getVideoNumber();
if (videoNumber) {
// 只要有番号,就显示导航按钮
@@ -34,11 +33,6 @@ export default defineContentScript({
hidePlayerButtons();
}
}
} else {
// 如果不在视频详情页,隐藏所有按钮
hidePlayerButtons();
hideNavigationButtons();
}
};
// 监听 URL 路径变化
@@ -57,20 +51,31 @@ export default defineContentScript({
});
// 获取目标视频番号
function getVideoNumber(): string {
function getVideoNumber(): string | undefined {
const pathname = window.location.pathname;
// javdb
if (pathname.startsWith('/v/')) {
const targetElement = document.querySelector('a.button.is-white.copy-to-clipboard');
if (!targetElement) {
console.log('未找到目标元素');
return '';
return;
}
const targetNumber = targetElement.getAttribute('data-clipboard-text');
if (!targetNumber) {
console.log('无目标番号');
return '';
return;
}
console.log('目标番号', targetNumber);
return targetNumber;
}
// javlibrary
const search = new URLSearchParams(window.location.search)
const v = search.get('v')
if (v) {
const targetElement = document.querySelector('#video_id > table > tbody > tr > td.text');
return targetElement?.textContent ?? undefined
}
}
// 获取 missav UUID
async function getMissavUUID(videoNumber: string): Promise<string> {

View File

@@ -12,7 +12,8 @@ export default defineConfig({
// Explicitly grant permission for the background script to access this host.
host_permissions: [
'*://*.javdb.com/*',
'*://*.missav.ws/*'
'*://*.missav.ws/*',
'*://*.javlibrary.com/*'
],
},
});