-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support baidu pan auto submit password
- Loading branch information
1 parent
ae97428
commit 5732b67
Showing
5 changed files
with
118 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'xxxxx520': patch | ||
--- | ||
|
||
feat: support baidu pan auto submit password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
// @match https://download.gamer520.com/* | ||
// @match https://*.espartasr.com/* | ||
// @match https://*.fourpetal.com/* | ||
// @match https://pan.baidu.com/* | ||
// @icon https://www.google.com/s2/favicons?sz=64&domain=gamer520.com | ||
// @require https://unpkg.com/[email protected]/dist/jquery.min.js | ||
// @grant none | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { waitDOM } from 'shared' | ||
|
||
export default async function main() { | ||
const url = new URL(window.location.href) | ||
const pwd = url.searchParams.get('pwd') | ||
if (!pwd) return | ||
|
||
const btn = await waitDOM<HTMLDialogElement>('#submitBtn') | ||
btn.click() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,22 @@ | ||
import { session } from 'shared' | ||
|
||
autoCompletePassowrd() | ||
moveDownloadToTop() | ||
baiduCloudLinkAutoComplete() | ||
modifyAnchorTarget() | ||
enhanceDownloadLink() | ||
|
||
function autoCompletePassowrd() { | ||
const $pwd = $('[name="post_password"]') | ||
if (!$pwd.length || session.getItem('is-auto-complete')) return | ||
const $submit = $('input[name=Submit]') | ||
|
||
const pwdSource = [$('.entry-title').text(), $('form>p').text()] | ||
const re = /密码保护(?::|:)(\w+)/ | ||
const pwd = pwdSource.map((s) => s.match(re)?.[1]).find((s) => s) | ||
if (!pwd) return | ||
|
||
session.setItem('is-auto-complete', true) | ||
$pwd.val(pwd) | ||
$submit[0].click() | ||
} | ||
|
||
function moveDownloadToTop() { | ||
const $area = $('.sidebar-right .sidebar-column .widget-area') | ||
const $down = $('#cao_widget_pay-4') | ||
|
||
$area.prepend($down) | ||
} | ||
|
||
function baiduCloudLinkAutoComplete() { | ||
function complete() { | ||
const $root = $('article .entry-content') | ||
|
||
let panEl: HTMLParagraphElement | null = null | ||
$root.find('p').each((i, el) => { | ||
if (el.innerText.match(/pan\.baidu\.com/)) { | ||
panEl = el | ||
} | ||
if (el.innerText.match('提取码') && panEl) { | ||
const match = panEl.innerText.match(/https:\/\/pan.baidu.com\/s\/\S+/) | ||
if (!match) return | ||
|
||
const link = match[0] | ||
const url = new URL(link) | ||
if (url.searchParams.has('pwd')) return | ||
const pwd = el.innerText.match(/提取码[::]\s?(\w{4})/)?.[1] | ||
if (!pwd) return | ||
|
||
url.searchParams.set('pwd', pwd) | ||
panEl.innerHTML = panEl.innerHTML.replaceAll(link, url.toString()) | ||
panEl = null | ||
} | ||
}) | ||
} | ||
|
||
complete() | ||
new MutationObserver(complete).observe(document.body, { | ||
subtree: true, | ||
childList: true, | ||
}) | ||
} | ||
|
||
function modifyAnchorTarget() { | ||
$<HTMLAnchorElement>('article .entry-content a').each((i, el) => { | ||
el.target = '_blank' | ||
}) | ||
} | ||
|
||
function enhanceDownloadLink() { | ||
const $dom = $('.go-down') | ||
const id = $dom.attr('data-id') | ||
|
||
$dom.attr('href', `/go/?post_id=${id}`) | ||
$dom[0].addEventListener('click', (e) => e.stopPropagation(), { | ||
capture: true, | ||
}) | ||
} | ||
import { router } from 'shared' | ||
import xxxxx520 from './xxxxx520' | ||
import baidu from './baidu' | ||
|
||
router({ | ||
domain: ['pan.baidu.com'], | ||
routes: [{ path: '/share/init', run: baidu }], | ||
}) | ||
|
||
router({ | ||
domain: [ | ||
/xxxxx520/, | ||
/xxxxx525/, | ||
/xxxxx528/, | ||
/xxxxx520/, | ||
/gamer520/, | ||
/efemovies/, | ||
/espartasr/, | ||
/fourpetal/, | ||
], | ||
routes: [{ run: xxxxx520 }], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { session } from 'shared' | ||
|
||
export default function main() { | ||
autoCompletePassowrd() | ||
moveDownloadToTop() | ||
baiduCloudLinkAutoComplete() | ||
modifyAnchorTarget() | ||
enhanceDownloadLink() | ||
} | ||
|
||
function autoCompletePassowrd() { | ||
const $pwd = $('[name="post_password"]') | ||
if (!$pwd.length || session.getItem('is-auto-complete')) return | ||
const $submit = $('input[name=Submit]') | ||
|
||
const pwdSource = [$('.entry-title').text(), $('form>p').text()] | ||
const re = /密码保护(?::|:)(\w+)/ | ||
const pwd = pwdSource.map((s) => s.match(re)?.[1]).find((s) => s) | ||
if (!pwd) return | ||
|
||
session.setItem('is-auto-complete', true) | ||
$pwd.val(pwd) | ||
$submit[0].click() | ||
} | ||
|
||
function moveDownloadToTop() { | ||
const $area = $('.sidebar-right .sidebar-column .widget-area') | ||
const $down = $('#cao_widget_pay-4') | ||
|
||
$area.prepend($down) | ||
} | ||
|
||
function baiduCloudLinkAutoComplete() { | ||
function complete() { | ||
const $root = $('article .entry-content') | ||
|
||
let panEl: HTMLParagraphElement | null = null | ||
$root.find('p').each((i, el) => { | ||
if (el.innerText.match(/pan\.baidu\.com/)) { | ||
panEl = el | ||
} | ||
if (el.innerText.match('提取码') && panEl) { | ||
const match = panEl.innerText.match(/https:\/\/pan.baidu.com\/s\/\S+/) | ||
if (!match) return | ||
|
||
const link = match[0] | ||
const url = new URL(link) | ||
if (url.searchParams.has('pwd')) return | ||
const pwd = el.innerText.match(/提取码[::]\s?(\w{4})/)?.[1] | ||
if (!pwd) return | ||
|
||
url.searchParams.set('pwd', pwd) | ||
panEl.innerHTML = panEl.innerHTML.replaceAll(link, url.toString()) | ||
panEl = null | ||
} | ||
}) | ||
} | ||
|
||
complete() | ||
new MutationObserver(complete).observe(document.body, { | ||
subtree: true, | ||
childList: true, | ||
}) | ||
} | ||
|
||
function modifyAnchorTarget() { | ||
$<HTMLAnchorElement>('article .entry-content a').each((i, el) => { | ||
el.target = '_blank' | ||
}) | ||
} | ||
|
||
function enhanceDownloadLink() { | ||
const $dom = $('.go-down') | ||
const id = $dom.attr('data-id') | ||
|
||
$dom.attr('href', `/go/?post_id=${id}`) | ||
$dom[0].addEventListener('click', (e) => e.stopPropagation(), { | ||
capture: true, | ||
}) | ||
} |