@@ -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,19 +51,30 @@ 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
|
||||
|
||||
@@ -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/*'
|
||||
],
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user