{
+ const lowerTargetNumber = videoNumber.toLowerCase();
+ const targetUrl = `https://jable.tv/videos/${lowerTargetNumber}/`;
+
+ try {
+ const response = await chrome.runtime.sendMessage({
+ type: 'fetchVideo',
+ url: targetUrl
+ });
+
+ if (!response.success) {
+ throw new Error(response.error);
+ }
+
+ const parser = new DOMParser();
+ const doc = parser.parseFromString(response.html, 'text/html');
+
+ const scripts = doc.getElementsByTagName('script');
+
+ for (const script of scripts) {
+ const content = script.textContent || '';
+ // 查找 var hlsUrl 变量
+ const hlsUrlMatch = content.match(/var\s+hlsUrl\s*=\s*['"](.*?)['"]/);
+ if (hlsUrlMatch) {
+ console.log('Jable hlsUrl', hlsUrlMatch[1]);
+ return hlsUrlMatch[1];
+ }
+ }
+ console.warn('未找到 Jable hlsUrl');
+ return '';
+ } catch (error) {
+ console.error('获取或解析 Jable 文档时出错:', error);
+ return '';
+ }
+}
\ No newline at end of file
diff --git a/entrypoints/popup/index.html b/entrypoints/popup/index.html
index 4faaff0..41aa4a6 100644
--- a/entrypoints/popup/index.html
+++ b/entrypoints/popup/index.html
@@ -23,6 +23,14 @@
+
+
+
+
+
diff --git a/entrypoints/popup/main.ts b/entrypoints/popup/main.ts
index 0561cfd..836d7a8 100644
--- a/entrypoints/popup/main.ts
+++ b/entrypoints/popup/main.ts
@@ -1,11 +1,13 @@
import './style.css';
const featureToggle = document.querySelector('#feature-toggle');
+const videoSourceSelect = document.querySelector('#video-source');
-// storage key, define as constant, for easy use in multiple places
+// storage keys, define as constants, for easy use in multiple places
const STORAGE_KEY = 'feature_enabled';
+const VIDEO_SOURCE_KEY = 'video_source';
-// 1. when popup is opened, load and set the initial state of the switch
+// 1. when popup is opened, load and set the initial state of the switch and select
// WXT provided storage API is a wrapper of chrome.storage, usage is basically the same
storage.getItem(`sync:${STORAGE_KEY}`).then((result) => {
// if there is no value in the storage, we default to true
@@ -16,8 +18,22 @@ storage.getItem(`sync:${STORAGE_KEY}`).then((result) => {
}
});
+storage.getItem(`sync:${VIDEO_SOURCE_KEY}`).then((result) => {
+ // default to missav if no value in storage
+ const videoSource = (result as string | null) ?? 'missav';
+ if (videoSourceSelect) {
+ videoSourceSelect.value = videoSource;
+ }
+});
+
// 2. listen for the change of the switch state, and save the new setting
featureToggle?.addEventListener('change', () => {
const isEnabled = featureToggle.checked;
storage.setItem(`sync:${STORAGE_KEY}`, isEnabled);
+});
+
+// 3. listen for the change of the video source selection, and save the new setting
+videoSourceSelect?.addEventListener('change', () => {
+ const videoSource = videoSourceSelect.value;
+ storage.setItem(`sync:${VIDEO_SOURCE_KEY}`, videoSource);
});
\ No newline at end of file
diff --git a/entrypoints/popup/style.css b/entrypoints/popup/style.css
index f3cfcf8..ecacabe 100644
--- a/entrypoints/popup/style.css
+++ b/entrypoints/popup/style.css
@@ -53,6 +53,11 @@ h1 {
justify-content: space-between;
align-items: center;
font-size: 14px;
+ margin-bottom: 15px;
+}
+
+.setting-row:last-child {
+ margin-bottom: 0;
}
footer {
@@ -75,7 +80,24 @@ footer a:hover {
text-decoration: underline;
}
-/* --- 开关样式 (保持不变) --- */
+/* --- 下拉选择框样式 --- */
+.source-select {
+ padding: 4px 8px;
+ border: 1px solid #ccc;
+ border-radius: 4px;
+ font-size: 14px;
+ background-color: white;
+ cursor: pointer;
+ min-width: 100px;
+}
+
+.source-select:focus {
+ outline: none;
+ border-color: #007bff;
+ box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
+}
+
+/* --- 开关样式 --- */
.switch {
position: relative;
display: inline-block;
diff --git a/package.json b/package.json
index 2e3447d..6e2ca91 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "jav-play",
"description": "manifest.json description",
"private": true,
- "version": "0.4.0",
+ "version": "0.5.0",
"type": "module",
"scripts": {
"dev": "wxt",
diff --git a/wxt.config.ts b/wxt.config.ts
index 635c311..11d552f 100644
--- a/wxt.config.ts
+++ b/wxt.config.ts
@@ -12,8 +12,9 @@ export default defineConfig({
// Explicitly grant permission for the background script to access this host.
host_permissions: [
'*://*.javdb.com/*',
+ '*://*.javlibrary.com/*',
'*://*.missav.ws/*',
- '*://*.javlibrary.com/*'
+ '*://*.jable.tv/*'
],
},
-});
+});
\ No newline at end of file