Skip to content

Commit

Permalink
feat: 兼容encode过的BING_HEADER
Browse files Browse the repository at this point in the history
  • Loading branch information
weaigc committed Aug 10, 2023
1 parent 54812c8 commit 5a29a6a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,17 @@ export function Settings() {
variant="secondary"
className="bg-[#c7f3ff] hover:bg-[#fdc7ff]"
onClick={() => {
if (curlValue) {
if (!/^\s*curl ['"]https:\/\/www\.bing\.com\/turing\/captcha\/challenge['"]/.test(curlValue)) {
let headerValue = curlValue
if (headerValue) {
try {
headerValue = atob(headerValue)
} catch (e) {}
if (!/^\s*curl ['"]https:\/\/www\.bing\.com\/turing\/captcha\/challenge['"]/.test(headerValue)) {
toast.error('格式不正确')
return
}
const maxAge = 86400 * 30
encodeHeadersToCookie(curlValue).forEach(cookie => document.cookie = `${cookie}; Max-Age=${maxAge}; Path=/; SameSite=None; Secure`)
encodeHeadersToCookie(headerValue).forEach(cookie => document.cookie = `${cookie}; Max-Age=${maxAge}; Path=/; SameSite=None; Secure`)
} else {
[...ChunkKeys, 'BING_COOKIE', 'BING_UA', 'BING_IP'].forEach(key => document.cookie = `${key}=; Path=/; SameSite=None; Secure`)
}
Expand Down

0 comments on commit 5a29a6a

Please sign in to comment.