├── .gitignore ├── LICENSE ├── README.md ├── components ├── NavigationButtons.css ├── NavigationButtons.ts ├── PlayerButtons.css └── PlayerButtons.ts ├── cover.png ├── entrypoints ├── background.ts ├── content │ └── index.ts └── popup │ ├── index.html │ ├── main.ts │ └── style.css ├── package-lock.json ├── package.json ├── public ├── JavPlayer.png └── icon │ ├── 16.png │ ├── 32.png │ ├── 48.png │ ├── 64.png │ └── 96.png ├── structure.md ├── tsconfig.json └── wxt.config.ts /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | .output 12 | stats.html 13 | stats-*.json 14 | .wxt 15 | web-ext.config.ts 16 | 17 | # Editor directories and files 18 | .vscode/* 19 | !.vscode/extensions.json 20 | .idea 21 | .DS_Store 22 | *.suo 23 | *.ntvs* 24 | *.njsproj 25 | *.sln 26 | *.sw? 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Jav Play 2 | 1. Call the local player to play the video in javdb.com/javlibrary.com directly. 3 | 2. Jump from the javdb.com/javlibrary.com page to the corresponding playback page of missav/jable 4 | 5 | ![JavDB Cover](/cover.png) 6 | 7 | ## Usage 8 | 1. Download extension zip file from github release page. 9 | 2. Open Chrome, navigate to chrome://extensions, then drag and drop the file onto the extensions page 10 | 3. Enable or Disable feature in popup setting. (Enable by default) 11 | 4. Choose video source from popup setting. (missav.ws by default) 12 | 13 | ## Supported Players 14 | 1. [IINA](https://iina.io/) Recommend in MacOS 15 | 2. [PotPlayer](https://potplayer.daum.net/) Recommend in Windows 16 | 17 | ## Players to be supported 18 | 1. ~~[mpv](https://mpv.io/)~~ Because the mpv player is not automatically registered as a protocol handler in the operating system, it is quite troublesome to handle, and support is not currently being considered. If someone is willing to add pmv support, please submit a request. 19 | 2. ~~[mpc-be](https://github.com/Aleksoid1978/MPC-BE)~~ Same reason as mpv player. 20 | -------------------------------------------------------------------------------- /components/NavigationButtons.css: -------------------------------------------------------------------------------- 1 | .wxt-nav-button { 2 | position: fixed; 3 | right: 0px; 4 | z-index: 9999; 5 | display: flex; 6 | align-items: center; 7 | gap: 5px; 8 | background-color: #28a745; /* 导航按钮使用绿色以作区分 */ 9 | color: white; 10 | padding: 5px 10px; 11 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; 12 | font-size: 14px; 13 | font-weight: 500; 14 | text-decoration: none; 15 | box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15); 16 | cursor: pointer; 17 | transition: transform 0.2s ease-in-out, background-color 0.2s ease; 18 | } 19 | 20 | .wxt-nav-button:hover { 21 | transform: scale(1.05); 22 | } -------------------------------------------------------------------------------- /components/NavigationButtons.ts: -------------------------------------------------------------------------------- 1 | import './NavigationButtons.css'; 2 | 3 | /** 4 | * 创建或更新一个浮动导航按钮。 5 | * 此按钮在新标签页中打开链接。 6 | */ 7 | function createOrUpdateNavButton(id: string, name: string, iconClass: string, url: string, topPosition: string, isDisabled: boolean = false) { 8 | let button = document.getElementById(id) as HTMLAnchorElement | null; 9 | 10 | if (!button) { 11 | button = document.createElement('a'); 12 | button.id = id; 13 | button.className = 'wxt-nav-button'; 14 | 15 | // 关键:设置在新标签页打开 16 | button.target = '_blank'; 17 | // 安全性最佳实践 18 | button.rel = 'noopener noreferrer'; 19 | 20 | document.body.appendChild(button); 21 | } 22 | 23 | // 无论是新创建还是更新,都要设置innerHTML 24 | button.innerHTML = ` 25 | 32 | 38 | 39 | 40 | ${name} 41 | `; 42 | 43 | button.href = url; 44 | button.style.top = topPosition; 45 | button.style.display = 'flex'; 46 | 47 | // 根据是否禁用来设置样式和行为 48 | if (isDisabled) { 49 | button.style.backgroundColor = '#6c757d'; // 灰色 50 | button.style.cursor = 'not-allowed'; 51 | button.style.opacity = '0.6'; 52 | 53 | // 阻止点击事件 54 | button.onclick = (e) => { 55 | e.preventDefault(); 56 | return false; 57 | }; 58 | } else { 59 | button.style.backgroundColor = '#28a745'; // 原来的绿色 60 | button.style.cursor = 'pointer'; 61 | button.style.opacity = '1'; 62 | button.onclick = null; // 移除点击阻止 63 | } 64 | } 65 | 66 | function hideButton(id: string) { 67 | const button = document.getElementById(id); 68 | if (button) { 69 | button.style.display = 'none'; 70 | } 71 | } 72 | 73 | const NAV_BUTTON_ID = 'wxt-nav-button'; 74 | 75 | /** 76 | * 显示检查状态的导航按钮 77 | * @param videoSource - 视频源 ('missav' 或 'jable') 78 | */ 79 | export function showNavigationButtonChecking(videoSource: string = 'missav') { 80 | const name = videoSource === 'jable' ? 'Jable' : 'MissAV'; 81 | createOrUpdateNavButton(NAV_BUTTON_ID, `${name} Checking...`, 'icon-play', '#', '100px', true); 82 | } 83 | 84 | /** 85 | * 显示404状态的导航按钮 86 | * @param videoSource - 视频源 ('missav' 或 'jable') 87 | */ 88 | export function showNavigationButton404(videoSource: string = 'missav') { 89 | const name = videoSource === 'jable' ? 'Jable' : 'MissAV'; 90 | createOrUpdateNavButton(NAV_BUTTON_ID, `${name} 404`, 'icon-play', '#', '100px', true); 91 | } 92 | 93 | /** 94 | * 添加或更新导航按钮。 95 | * @param videoNumber - 视频番号 (例如, 'IPX-811')。 96 | * @param videoSource - 视频源 ('missav' 或 'jable')。 97 | */ 98 | export function addOrUpdateNavigationButtons(videoNumber: string, videoSource: string = 'missav') { 99 | let url: string; 100 | let name: string; 101 | 102 | if (videoSource === 'jable') { 103 | url = `https://jable.tv/videos/${videoNumber.toLowerCase()}/`; 104 | name = 'Jable'; 105 | } else { 106 | // default to missav 107 | url = `https://missav.ws/${videoNumber.toLowerCase()}`; 108 | name = 'MissAV'; 109 | } 110 | 111 | createOrUpdateNavButton(NAV_BUTTON_ID, name, 'icon-play', url, '100px', false); 112 | } 113 | 114 | /** 115 | * 隐藏所有的导航按钮。 116 | */ 117 | export function hideNavigationButtons() { 118 | hideButton(NAV_BUTTON_ID); 119 | } -------------------------------------------------------------------------------- /components/PlayerButtons.css: -------------------------------------------------------------------------------- 1 | .wxt-player-button { 2 | /* 定位和层级 */ 3 | position: fixed; 4 | right: 0px; 5 | z-index: 9999; 6 | 7 | /* 外观和布局 */ 8 | display: flex; 9 | align-items: center; 10 | gap: 5px; 11 | background-color: #3173dc; /* 播放器按钮使用蓝色 */ 12 | color: white; 13 | padding: 5px 10px; 14 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; 15 | font-size: 14px; 16 | font-weight: 500; 17 | text-decoration: none; 18 | box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15); 19 | 20 | /* 交互效果 */ 21 | cursor: pointer; 22 | transition: transform 0.2s ease-in-out, background-color 0.2s ease; 23 | } 24 | 25 | .wxt-player-button:hover { 26 | transform: scale(1.05); 27 | } -------------------------------------------------------------------------------- /components/PlayerButtons.ts: -------------------------------------------------------------------------------- 1 | import './PlayerButtons.css'; 2 | 3 | /** 4 | * 创建或更新一个浮动播放器按钮。 5 | */ 6 | function createOrUpdateButton(id: string, name: string, iconClass: string, url: string, topPosition: string, isDisabled: boolean = false) { 7 | let button = document.getElementById(id) as HTMLAnchorElement | null; 8 | 9 | if (!button) { 10 | button = document.createElement('a'); 11 | button.id = id; 12 | button.className = 'wxt-player-button'; 13 | document.body.appendChild(button); 14 | 15 | // 只在按钮未禁用时添加点击事件 16 | if (!isDisabled) { 17 | button.addEventListener('click', (e) => { 18 | e.preventDefault(); 19 | window.location.href = button!.href; 20 | }); 21 | } 22 | } 23 | 24 | // 无论是新创建还是更新,都要设置innerHTML 25 | button.innerHTML = ` 26 | 33 | 39 | 40 | 41 | ${name} 42 | `; 43 | 44 | button.href = url; 45 | button.style.top = topPosition; 46 | button.style.display = 'flex'; 47 | 48 | // 根据是否禁用来设置样式和行为 49 | if (isDisabled) { 50 | button.style.backgroundColor = '#6c757d'; // 灰色 51 | button.style.cursor = 'not-allowed'; 52 | button.style.opacity = '0.6'; 53 | 54 | // 阻止点击事件 55 | button.onclick = (e) => { 56 | e.preventDefault(); 57 | return false; 58 | }; 59 | } else { 60 | button.style.backgroundColor = '#3173dc'; // 原来的蓝色 61 | button.style.cursor = 'pointer'; 62 | button.style.opacity = '1'; 63 | 64 | // 恢复正常点击行为 65 | button.onclick = (e) => { 66 | e.preventDefault(); 67 | window.location.href = button.href; 68 | }; 69 | } 70 | } 71 | 72 | /** 73 | * 隐藏指定的播放器按钮。 74 | */ 75 | function hideButton(id: string) { 76 | const button = document.getElementById(id); 77 | if (button) { 78 | button.style.display = 'none'; 79 | } 80 | } 81 | 82 | // 定义按钮的常量 ID 83 | const IINA_BUTTON_ID = 'wxt-iina-floating-button'; 84 | const POTPLAYER_BUTTON_ID = 'wxt-potplayer-floating-button'; 85 | 86 | /** 87 | * 显示检查状态的播放器按钮 88 | */ 89 | export function showPlayerButtonsChecking() { 90 | createOrUpdateButton(IINA_BUTTON_ID, 'IINA', 'icon-play', '#', '140px', true); 91 | createOrUpdateButton(POTPLAYER_BUTTON_ID, 'PotPlayer', 'icon-play', '#', '180px', true); 92 | } 93 | 94 | /** 95 | * 显示404状态的播放器按钮 96 | */ 97 | export function showPlayerButtons404() { 98 | createOrUpdateButton(IINA_BUTTON_ID, 'IINA', 'icon-play', '#', '140px', true); 99 | createOrUpdateButton(POTPLAYER_BUTTON_ID, 'PotPlayer', 'icon-play', '#', '180px', true); 100 | } 101 | 102 | /** 103 | * 添加或更新播放器按钮。 104 | * @param playlistUrl - 直接的播放链接。 105 | */ 106 | export function addOrUpdatePlayerButtons(playlistUrl: string) { 107 | // IINA 按钮 108 | const iinaUrl = `iina://weblink?url=${playlistUrl}`; 109 | createOrUpdateButton(IINA_BUTTON_ID, 'IINA', 'icon-play', iinaUrl, '140px', false); 110 | 111 | // PotPlayer 按钮 112 | const potplayerUrl = `potplayer://${playlistUrl}`; 113 | createOrUpdateButton(POTPLAYER_BUTTON_ID, 'PotPlayer', 'icon-play', potplayerUrl, '180px', false); 114 | } 115 | 116 | /** 117 | * 隐藏所有的播放器按钮。 118 | */ 119 | export function hidePlayerButtons() { 120 | hideButton(IINA_BUTTON_ID); 121 | hideButton(POTPLAYER_BUTTON_ID); 122 | } -------------------------------------------------------------------------------- /cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aizhimou/jav-play/79aa5514d58426dd3915ba95384f30453caca342/cover.png -------------------------------------------------------------------------------- /entrypoints/background.ts: -------------------------------------------------------------------------------- 1 | interface FetchVideoRequest { 2 | type: 'fetchVideo' 3 | url: string 4 | } 5 | 6 | interface CheckUrlRequest { 7 | type: 'checkUrl' 8 | url: string 9 | } 10 | 11 | type BackgroundRequest = FetchVideoRequest | CheckUrlRequest; 12 | 13 | export default defineBackground({ 14 | main() { 15 | chrome.runtime.onMessage.addListener(( 16 | request: BackgroundRequest, 17 | sender: chrome.runtime.MessageSender, 18 | sendResponse: (response: any) => void 19 | ) => { 20 | if (request.type === 'fetchVideo') { 21 | console.log('fetchVideo', request.url) 22 | fetch(request.url, { 23 | redirect: 'follow', 24 | // Add headers to mimic a browser request 25 | headers: { 26 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' 27 | } 28 | }) 29 | .then(response => { 30 | if (!response.ok) { 31 | throw new Error(`HTTP error! status: ${response.status}`) 32 | } 33 | return response.text() 34 | }) 35 | .then(html => { 36 | sendResponse({ success: true, html }) 37 | }) 38 | .catch(error => { 39 | sendResponse({ success: false, error: error.message }) 40 | }) 41 | return true // Keep the message channel open for the async response 42 | } 43 | 44 | if (request.type === 'checkUrl') { 45 | console.log('checkUrl', request.url) 46 | fetch(request.url, { 47 | method: 'HEAD', // 只检查头部,不下载完整内容 48 | redirect: 'follow', 49 | headers: { 50 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' 51 | } 52 | }) 53 | .then(response => { 54 | console.log('checkUrl response', response.status) 55 | sendResponse({ 56 | success: true, 57 | exists: response.ok, 58 | status: response.status 59 | }) 60 | }) 61 | .catch(error => { 62 | console.log('checkUrl error', error) 63 | sendResponse({ 64 | success: true, 65 | exists: false, 66 | status: 0, 67 | error: error.message 68 | }) 69 | }) 70 | return true // Keep the message channel open for the async response 71 | } 72 | }) 73 | } 74 | }) -------------------------------------------------------------------------------- /entrypoints/content/index.ts: -------------------------------------------------------------------------------- 1 | // 从两个组件中导入方法 2 | import { 3 | addOrUpdatePlayerButtons, 4 | hidePlayerButtons, 5 | showPlayerButtonsChecking, 6 | showPlayerButtons404 7 | } from '../../components/PlayerButtons'; 8 | import { 9 | addOrUpdateNavigationButtons, 10 | hideNavigationButtons, 11 | showNavigationButtonChecking, 12 | showNavigationButton404 13 | } from '../../components/NavigationButtons'; 14 | 15 | const STORAGE_KEY = 'feature_enabled'; 16 | const VIDEO_SOURCE_KEY = 'video_source'; 17 | 18 | export default defineContentScript({ 19 | matches: ['*://*.javdb.com/v/*', '*://*.javlibrary.com/*'], 20 | async main() { 21 | const isEnabled = await storage.getItem(`sync:${STORAGE_KEY}`) ?? true; 22 | 23 | if (!isEnabled) { 24 | console.log('❌ [JavDB Helper] 功能已禁用。'); 25 | hidePlayerButtons(); 26 | hideNavigationButtons(); // 同时隐藏导航按钮 27 | return; 28 | } 29 | 30 | console.log('🚀 [JavDB Helper] 功能已启用,正在运行脚本...'); 31 | 32 | const processPage = async () => { 33 | const videoNumber = getVideoNumber(); 34 | if (videoNumber) { 35 | // 获取用户选择的视频源 36 | const videoSource = await storage.getItem(`sync:${VIDEO_SOURCE_KEY}`) ?? 'missav'; 37 | 38 | // 1. 先显示检查状态 39 | showNavigationButtonChecking(videoSource as string); 40 | showPlayerButtonsChecking(); 41 | 42 | // 2. 检查目标页面是否存在 43 | const targetUrl = getTargetUrl(videoNumber, videoSource as string); 44 | const urlExists = await checkUrlExists(targetUrl); 45 | 46 | if (!urlExists) { 47 | // 3.1 目标页面不存在,显示404状态 48 | showNavigationButton404(videoSource as string); 49 | showPlayerButtons404(); 50 | console.log('目标页面不存在:', targetUrl); 51 | return; 52 | } 53 | 54 | // 3.2 目标页面存在,显示正常的导航按钮 55 | addOrUpdateNavigationButtons(videoNumber, videoSource as string); 56 | 57 | // 4. 异步获取播放链接来显示播放器按钮 58 | const playUrl = await getPlayUrl(videoNumber, videoSource as string); 59 | if (playUrl) { 60 | addOrUpdatePlayerButtons(playUrl); 61 | } else { 62 | // 如果没有播放链接,显示404状态 63 | showPlayerButtons404(); 64 | } 65 | } 66 | }; 67 | 68 | // 监听 URL 路径变化 69 | let lastPathname = window.location.pathname; 70 | new MutationObserver(() => { 71 | const currentPathname = window.location.pathname; 72 | if (currentPathname !== lastPathname) { 73 | lastPathname = currentPathname; 74 | processPage(); 75 | } 76 | }).observe(document.body, { childList: true, subtree: true }); 77 | 78 | // 页面加载时执行一次 79 | processPage(); 80 | } 81 | }); 82 | 83 | // 获取目标视频番号 84 | function getVideoNumber(): string | undefined { 85 | const pathname = window.location.pathname; 86 | // javdb 87 | if (pathname.startsWith('/v/')) { 88 | const targetElement = document.querySelector('a.button.is-white.copy-to-clipboard'); 89 | if (!targetElement) { 90 | console.log('未找到目标元素'); 91 | return; 92 | } 93 | const targetNumber = targetElement.getAttribute('data-clipboard-text'); 94 | if (!targetNumber) { 95 | console.log('无目标番号'); 96 | return; 97 | } 98 | console.log('目标番号', targetNumber); 99 | return targetNumber; 100 | } 101 | // javlibrary 102 | const search = new URLSearchParams(window.location.search) 103 | const v = search.get('v') 104 | if (v) { 105 | const targetElement = document.querySelector('#video_id > table > tbody > tr > td.text'); 106 | return targetElement?.textContent ?? undefined 107 | } 108 | } 109 | 110 | // 获取目标URL 111 | function getTargetUrl(videoNumber: string, videoSource: string): string { 112 | if (videoSource === 'jable') { 113 | return `https://jable.tv/videos/${videoNumber.toLowerCase()}/`; 114 | } else { 115 | // default to missav 116 | return `https://missav.ws/${videoNumber.toLowerCase()}`; 117 | } 118 | } 119 | 120 | // 检查URL是否存在 121 | async function checkUrlExists(url: string): Promise { 122 | try { 123 | const response = await chrome.runtime.sendMessage({ 124 | type: 'checkUrl', 125 | url: url 126 | }); 127 | 128 | if (!response.success) { 129 | console.error('检查URL时出错:', response.error); 130 | return false; 131 | } 132 | 133 | return response.exists; 134 | } catch (error) { 135 | console.error('检查URL时出错:', error); 136 | return false; 137 | } 138 | } 139 | 140 | // 获取播放链接 (支持不同视频源) 141 | async function getPlayUrl(videoNumber: string, videoSource: string): Promise { 142 | if (videoSource === 'jable') { 143 | return await getJablePlayUrl(videoNumber); 144 | } else { 145 | // default to missav 146 | return await getMissavPlayUrl(videoNumber); 147 | } 148 | } 149 | 150 | // 获取 MissAV 播放链接 151 | async function getMissavPlayUrl(videoNumber: string): Promise { 152 | const lowerTargetNumber = videoNumber.toLowerCase(); 153 | const targetUrl = `https://missav.ws/dm1/en/${lowerTargetNumber}`; 154 | 155 | try { 156 | const response = await chrome.runtime.sendMessage({ 157 | type: 'fetchVideo', 158 | url: targetUrl 159 | }); 160 | 161 | if (!response.success) { 162 | throw new Error(response.error); 163 | } 164 | 165 | const parser = new DOMParser(); 166 | const doc = parser.parseFromString(response.html, 'text/html'); 167 | 168 | const scripts = doc.getElementsByTagName('script'); 169 | 170 | for (const script of scripts) { 171 | const content = script.textContent || ''; 172 | if (content.includes('thumbnail')) { 173 | const urlsMatch = content.match(/urls:\s*\[(.*?)\]/s); 174 | if (urlsMatch) { 175 | const firstUrl = urlsMatch[1].split(',')[0].trim().replace(/"/g, '').replace(/\\/g, ''); 176 | const uuidMatch = firstUrl.match(/\/([0-9a-f-]+)\/seek\//i); 177 | if (uuidMatch) { 178 | console.log('MissAV uuidMatch', uuidMatch[1]); 179 | return `https://surrit.com/${uuidMatch[1]}/playlist.m3u8`; 180 | } 181 | } 182 | } 183 | } 184 | console.warn('未找到 MissAV uuid'); 185 | return ''; 186 | } catch (error) { 187 | console.error('获取或解析 MissAV 文档时出错:', error); 188 | return ''; 189 | } 190 | } 191 | 192 | // 获取 Jable 播放链接 193 | async function getJablePlayUrl(videoNumber: string): Promise { 194 | const lowerTargetNumber = videoNumber.toLowerCase(); 195 | const targetUrl = `https://jable.tv/videos/${lowerTargetNumber}/`; 196 | 197 | try { 198 | const response = await chrome.runtime.sendMessage({ 199 | type: 'fetchVideo', 200 | url: targetUrl 201 | }); 202 | 203 | if (!response.success) { 204 | throw new Error(response.error); 205 | } 206 | 207 | const parser = new DOMParser(); 208 | const doc = parser.parseFromString(response.html, 'text/html'); 209 | 210 | const scripts = doc.getElementsByTagName('script'); 211 | 212 | for (const script of scripts) { 213 | const content = script.textContent || ''; 214 | // 查找 var hlsUrl 变量 215 | const hlsUrlMatch = content.match(/var\s+hlsUrl\s*=\s*['"](.*?)['"]/); 216 | if (hlsUrlMatch) { 217 | console.log('Jable hlsUrl', hlsUrlMatch[1]); 218 | return hlsUrlMatch[1]; 219 | } 220 | } 221 | console.warn('未找到 Jable hlsUrl'); 222 | return ''; 223 | } catch (error) { 224 | console.error('获取或解析 Jable 文档时出错:', error); 225 | return ''; 226 | } 227 | } -------------------------------------------------------------------------------- /entrypoints/popup/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Jav Play Settings 7 | 8 | 9 |
10 |
11 | 12 |

Jav Play

13 |

Play video directly in javdb and javlibrary.

14 |
15 | 16 |
17 | 18 |
19 |
20 | 21 | 25 |
26 | 27 |
28 | 29 | 33 |
34 |
35 | 36 |
37 | 38 | 47 |
48 | 49 | 50 | -------------------------------------------------------------------------------- /entrypoints/popup/main.ts: -------------------------------------------------------------------------------- 1 | import './style.css'; 2 | 3 | const featureToggle = document.querySelector('#feature-toggle'); 4 | const videoSourceSelect = document.querySelector('#video-source'); 5 | 6 | // storage keys, define as constants, for easy use in multiple places 7 | const STORAGE_KEY = 'feature_enabled'; 8 | const VIDEO_SOURCE_KEY = 'video_source'; 9 | 10 | // 1. when popup is opened, load and set the initial state of the switch and select 11 | // WXT provided storage API is a wrapper of chrome.storage, usage is basically the same 12 | storage.getItem(`sync:${STORAGE_KEY}`).then((result) => { 13 | // if there is no value in the storage, we default to true 14 | // '??' is the nullish coalescing operator 15 | const isEnabled = (result as boolean | null) ?? true; 16 | if (featureToggle) { 17 | featureToggle.checked = isEnabled; 18 | } 19 | }); 20 | 21 | storage.getItem(`sync:${VIDEO_SOURCE_KEY}`).then((result) => { 22 | // default to missav if no value in storage 23 | const videoSource = (result as string | null) ?? 'missav'; 24 | if (videoSourceSelect) { 25 | videoSourceSelect.value = videoSource; 26 | } 27 | }); 28 | 29 | // 2. listen for the change of the switch state, and save the new setting 30 | featureToggle?.addEventListener('change', () => { 31 | const isEnabled = featureToggle.checked; 32 | storage.setItem(`sync:${STORAGE_KEY}`, isEnabled); 33 | }); 34 | 35 | // 3. listen for the change of the video source selection, and save the new setting 36 | videoSourceSelect?.addEventListener('change', () => { 37 | const videoSource = videoSourceSelect.value; 38 | storage.setItem(`sync:${VIDEO_SOURCE_KEY}`, videoSource); 39 | }); -------------------------------------------------------------------------------- /entrypoints/popup/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; 3 | width: 280px; /* 为新布局增加了宽度 */ 4 | padding: 0; 5 | margin: 0; 6 | color: #333; 7 | } 8 | 9 | #app { 10 | display: flex; 11 | flex-direction: column; 12 | align-items: center; 13 | text-align: center; 14 | padding: 20px 15px; 15 | } 16 | 17 | header { 18 | margin-bottom: 15px; 19 | } 20 | 21 | .logo { 22 | width: 64px; 23 | height: 64px; 24 | margin-bottom: 10px; 25 | } 26 | 27 | h1 { 28 | font-size: 22px; 29 | margin: 0 0 8px 0; 30 | } 31 | 32 | .description { 33 | font-size: 14px; 34 | color: #666; 35 | margin: 0; 36 | max-width: 240px; /* 确保描述文本可以优雅地换行 */ 37 | } 38 | 39 | .separator { 40 | width: 100%; 41 | border: none; 42 | border-top: 1px solid #eee; 43 | margin: 0; 44 | } 45 | 46 | .settings-container { 47 | width: 100%; 48 | padding: 15px 0; 49 | } 50 | 51 | .setting-row { 52 | display: flex; 53 | justify-content: space-between; 54 | align-items: center; 55 | font-size: 14px; 56 | margin-bottom: 15px; 57 | } 58 | 59 | .setting-row:last-child { 60 | margin-bottom: 0; 61 | } 62 | 63 | footer { 64 | padding-top: 10px; 65 | margin-top: 5px; 66 | } 67 | 68 | footer span { 69 | font-size: 13px; 70 | } 71 | 72 | footer a { 73 | color: #007bff; 74 | text-decoration: none; 75 | font-size: 13px; 76 | padding: 0 3px; 77 | } 78 | 79 | footer a:hover { 80 | text-decoration: underline; 81 | } 82 | 83 | /* --- 下拉选择框样式 --- */ 84 | .source-select { 85 | padding: 4px 8px; 86 | border: 1px solid #ccc; 87 | border-radius: 4px; 88 | font-size: 14px; 89 | background-color: white; 90 | cursor: pointer; 91 | min-width: 100px; 92 | } 93 | 94 | .source-select:focus { 95 | outline: none; 96 | border-color: #007bff; 97 | box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25); 98 | } 99 | 100 | /* --- 开关样式 --- */ 101 | .switch { 102 | position: relative; 103 | display: inline-block; 104 | width: 44px; 105 | height: 24px; 106 | } 107 | 108 | .switch input { 109 | opacity: 0; 110 | width: 0; 111 | height: 0; 112 | } 113 | 114 | .slider { 115 | position: absolute; 116 | cursor: pointer; 117 | top: 0; 118 | left: 0; 119 | right: 0; 120 | bottom: 0; 121 | background-color: #ccc; 122 | transition: .4s; 123 | } 124 | 125 | .slider:before { 126 | position: absolute; 127 | content: ""; 128 | height: 18px; 129 | width: 18px; 130 | left: 3px; 131 | bottom: 3px; 132 | background-color: white; 133 | transition: .4s; 134 | } 135 | 136 | input:checked + .slider { 137 | background-color: #007bff; 138 | } 139 | 140 | input:checked + .slider:before { 141 | transform: translateX(20px); 142 | } 143 | 144 | .slider.round { 145 | border-radius: 34px; 146 | } 147 | 148 | .slider.round:before { 149 | border-radius: 50%; 150 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jav-play", 3 | "description": "manifest.json description", 4 | "private": true, 5 | "version": "0.5.0", 6 | "type": "module", 7 | "scripts": { 8 | "dev": "wxt", 9 | "dev:firefox": "wxt -b firefox", 10 | "build": "wxt build", 11 | "build:firefox": "wxt build -b firefox", 12 | "zip": "wxt zip", 13 | "zip:firefox": "wxt zip -b firefox", 14 | "compile": "tsc --noEmit", 15 | "postinstall": "wxt prepare" 16 | }, 17 | "devDependencies": { 18 | "@types/chrome": "^0.0.323", 19 | "typescript": "^5.8.3", 20 | "wxt": "^0.20.6" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /public/JavPlayer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aizhimou/jav-play/79aa5514d58426dd3915ba95384f30453caca342/public/JavPlayer.png -------------------------------------------------------------------------------- /public/icon/16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aizhimou/jav-play/79aa5514d58426dd3915ba95384f30453caca342/public/icon/16.png -------------------------------------------------------------------------------- /public/icon/32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aizhimou/jav-play/79aa5514d58426dd3915ba95384f30453caca342/public/icon/32.png -------------------------------------------------------------------------------- /public/icon/48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aizhimou/jav-play/79aa5514d58426dd3915ba95384f30453caca342/public/icon/48.png -------------------------------------------------------------------------------- /public/icon/64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aizhimou/jav-play/79aa5514d58426dd3915ba95384f30453caca342/public/icon/64.png -------------------------------------------------------------------------------- /public/icon/96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aizhimou/jav-play/79aa5514d58426dd3915ba95384f30453caca342/public/icon/96.png -------------------------------------------------------------------------------- /structure.md: -------------------------------------------------------------------------------- 1 | Here's a brief summary of each of these files and directories:
2 |
3 | 📂 {rootDir}/
4 | 📁 .output/
5 | 📁 .wxt/
6 | 📁 assets/
7 | 📁 components/
8 | 📁 composables/
9 | 📁 entrypoints/
10 | 📁 hooks/
11 | 📁 modules/
12 | 📁 public/
13 | 📁 utils/
14 | 📄 .env
15 | 📄 .env.publish
16 | 📄 app.config.ts
17 | 📄 package.json
18 | 📄 tsconfig.json
19 | 📄 web-ext.config.ts
20 | 📄 wxt.config.ts
21 | 22 | .output/: All build artifacts will go here
23 | .wxt/: Generated by WXT, it contains TS config
24 | assets/: Contains all CSS, images, and other assets that should be processed by WXT
25 | components/: Auto-imported by default, contains UI components
26 | composables/: Auto-imported by default, contains source code for your project's composable functions for Vue
27 | entrypoints/: Contains all the entrypoints that get bundled into your extension
28 | hooks/: Auto-imported by default, contains source code for your project's hooks for React and Solid
29 | modules/: Contains local WXT Modules for your project
30 | public/: Contains any files you want to copy into the output folder as-is, without being processed by WXT
31 | utils/: Auto-imported by default, contains generic utilities used throughout your project
32 | .env: Contains Environment Variables
33 | .env.publish: Contains Environment Variables for publishing
34 | app.config.ts: Contains Runtime Config
35 | package.json: The standard file used by your package manager
36 | tsconfig.json: Config telling TypeScript how to behave
37 | web-ext.config.ts: Configure Browser Startup
38 | wxt.config.ts: The main config file for WXT projects
-------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.wxt/tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /wxt.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'wxt'; 2 | 3 | // See https://wxt.dev/api/config.html 4 | export default defineConfig({ 5 | manifest: { 6 | name: 'Jav Play', 7 | description: 'Play video directly in JAVDB', 8 | permissions: [ 9 | 'storage', 10 | 'scripting' 11 | ], 12 | // Explicitly grant permission for the background script to access this host. 13 | host_permissions: [ 14 | '*://*.javdb.com/*', 15 | '*://*.javlibrary.com/*', 16 | '*://*.missav.ws/*', 17 | '*://*.jable.tv/*' 18 | ], 19 | }, 20 | }); --------------------------------------------------------------------------------