// ==UserScript== // @name Press Enter / Shift+Enter to navigate episodes // @description Press Enter to go to next episode, Shift+Enter to go to previous episode // @match http://ysjdm6.com/* // @match http://agedm6.com/* // @match http://yuejuwu.me/* // @match http*://agedm1.com/* // @match http*://agedm2.com/* // @match http://ysjdm2.com/* // @match http://acgdmw.com/* // @match *://www.yhdm03.com/* // @match *://yhdm007.com/* // @match *://www.bumimi20.com/* // @match https://www.olevod.com/* // @match http://100.65.173.16:5244/* // @match http://192.168.10.102:5244/* // @match http://yhdm.in/* // @match http://www.iyinghua.com/* // @match https://www.mxdm.xyz/* // @match https://yhdm.one/* // @match https://yhdm6.top/* // @version 1.0.2 // @run-at document-start // ==/UserScript== document.addEventListener('keydown', function(event) { // 只在按下 Enter 时触发 if (event.key === 'Enter') { const currentURL = window.location.href; const direction = event.shiftKey ? -1 : 1; // Shift+Enter → 上一集, Enter → 下一集 // Pattern 1: /001.html let match = currentURL.match(/\/(\d+)\.(\w+)$/); if (match) { const pageNumber = match[1]; const extension = match[2]; const nextPageNumber = String(parseInt(pageNumber, 10) + direction).padStart(pageNumber.length, '0'); const nextURL = currentURL.replace(`/${pageNumber}.${extension}`, `/${nextPageNumber}.${extension}`); window.location.href = nextURL; return; } // Pattern 2: /6467-1.html match = currentURL.match(/\/(\d+)-(\d+)\.(\w+)$/); if (match) { const seriesID = match[1]; const currentPage = match[2]; const extension = match[3]; const nextPage = String(parseInt(currentPage, 10) + direction).padStart(currentPage.length, '0'); const nextURL = currentURL.replace(`/${seriesID}-${currentPage}.${extension}`, `/${seriesID}-${nextPage}.${extension}`); window.location.href = nextURL; return; } // Pattern 3: /9314-2-6.html match = currentURL.match(/\/(\d+)-(\d+)-(\d+)\.(\w+)$/); if (match) { const id1 = match[1]; const id2 = match[2]; const page = match[3]; const extension = match[4]; const nextPage = String(parseInt(page, 10) + direction).padStart(page.length, '0'); const currentPart = `/${id1}-${id2}-${page}.${extension}`; const nextPart = `/${id1}-${id2}-${nextPage}.${extension}`; const nextURL = currentURL.replace(currentPart, nextPart); window.location.href = nextURL; return; } // Pattern 4: /nid/X/ match = currentURL.match(/(\/nid\/)(\d+)(\/?$)/); if (match) { const prefix = match[1]; const numStr = match[2]; const suffix = match[3]; const nextNum = String(parseInt(numStr, 10) + direction); const nextURL = currentURL.replace(`${prefix}${numStr}${suffix}`, `${prefix}${nextNum}${suffix}`); window.location.href = nextURL; return; } // 可以继续加更多 pattern } }); /*document.addEventListener('keydown', function(event) { if (event.key === 'Enter') { const currentURL = window.location.href; // General pattern: match any URL ending in .html, find last number before .html const match = currentURL.match(/(.*?)(\d+)(\.html)$/); if (match) { const prefix = match[1]; // Everything before the last number const numberStr = match[2]; // The number to increment const suffix = match[3]; // Usually ".html" const nextNumber = String(parseInt(numberStr, 10) + 1).padStart(numberStr.length, '0'); const nextURL = `${prefix}${nextNumber}${suffix}`; window.location.href = nextURL; } } }); */