mirror of
https://github.com/KOP-XIAO/QuantumultX.git
synced 2026-01-25 21:25:09 +00:00
disneyplus check
This commit is contained in:
@@ -8,6 +8,8 @@ Thanks to & modified from
|
||||
|
||||
For Quantumult-X 598+ ONLY!!
|
||||
|
||||
2022-07-23
|
||||
|
||||
[task_local]
|
||||
|
||||
event-interaction https://raw.githubusercontent.com/KOP-XIAO/QuantumultX/master/Scripts/disney-ui-check.js, tag=Disney⁺ 查询, img-url=https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Disney.png, enabled=true"
|
||||
@@ -69,7 +71,7 @@ async function testDisneyPlus() {
|
||||
// if (cnbl == 2) {
|
||||
// return { region, status: STATUS_COMING }
|
||||
// }
|
||||
let { countryCode, inSupportedLocation } = await Promise.race([getLocationInfo(), timeout(7000)])
|
||||
let { countryCode, inSupportedLocation, accessToken } = await Promise.race([getLocationInfo(), timeout(7000)])
|
||||
console.log(`getLocationInfo: countryCode=${countryCode}, inSupportedLocation=${inSupportedLocation}`)
|
||||
|
||||
region = countryCode ?? region
|
||||
@@ -82,6 +84,13 @@ async function testDisneyPlus() {
|
||||
return { region, status: STATUS_AVAILABLE }
|
||||
}
|
||||
|
||||
let support = await Promise.race([testPublicGraphqlAPI(accessToken), timeout(7000)])
|
||||
if (!support) {
|
||||
return { status: STATUS_NOT_AVAILABLE }
|
||||
}
|
||||
// 支持解锁
|
||||
return { region, status: STATUS_AVAILABLE }
|
||||
|
||||
} catch (error) {
|
||||
console.log("error:"+error)
|
||||
|
||||
@@ -121,15 +130,15 @@ function getLocationInfo() {
|
||||
attributes: {
|
||||
browserName: 'chrome',
|
||||
browserVersion: '94.0.4606',
|
||||
manufacturer: 'microsoft',
|
||||
manufacturer: 'apple',
|
||||
model: null,
|
||||
operatingSystem: 'windows',
|
||||
operatingSystemVersion: '10.0',
|
||||
operatingSystem: 'macintosh',
|
||||
operatingSystemVersion: '10.15.7',
|
||||
osDeviceIds: [],
|
||||
},
|
||||
deviceFamily: 'browser',
|
||||
deviceLanguage: 'en',
|
||||
deviceProfile: 'windows',
|
||||
deviceProfile: 'macosx',
|
||||
},
|
||||
},
|
||||
}),
|
||||
@@ -142,11 +151,15 @@ function getLocationInfo() {
|
||||
console.log('getLocationInfo: ' + data)
|
||||
reject('Not Available')
|
||||
return
|
||||
} else {let {
|
||||
} else {
|
||||
let {
|
||||
token: { accessToken },
|
||||
session: {
|
||||
inSupportedLocation,
|
||||
location: { countryCode },
|
||||
} = JSON.parse(data)?.extensions?.sdk?.session
|
||||
resolve({ inSupportedLocation, countryCode })
|
||||
},
|
||||
} = JSON.parse(data)?.extensions?.sdk
|
||||
resolve({ inSupportedLocation, countryCode, accessToken })
|
||||
}
|
||||
}, reason => {
|
||||
reject('Error')
|
||||
@@ -155,6 +168,33 @@ function getLocationInfo() {
|
||||
})
|
||||
}
|
||||
|
||||
function testPublicGraphqlAPI(accessToken) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let opts = {
|
||||
url: 'https://disney.api.edge.bamgrid.com/v1/public/graphql',
|
||||
headers: {
|
||||
'Accept-Language': 'en',
|
||||
Authorization: accessToken,
|
||||
'Content-Type': 'application/json',
|
||||
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
query:
|
||||
'query($preferredLanguages: [String!]!, $version: String) {globalization(version: $version) { uiLanguage(preferredLanguages: $preferredLanguages) }}',
|
||||
variables: { version: '1.5.0', preferredLanguages: ['en'] },
|
||||
}),
|
||||
}
|
||||
|
||||
$task.fetch(opts).then( response => {
|
||||
|
||||
resolve(response.status === 200)
|
||||
}, reason => {
|
||||
reject('Error')
|
||||
return
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function testHomePage() {
|
||||
return new Promise((resolve, reject) => {
|
||||
let opts0 = {
|
||||
@@ -168,7 +208,7 @@ function testHomePage() {
|
||||
$task.fetch(opts0).then(response => {
|
||||
let data = response.body
|
||||
//console.log("homepage"+response.statusCode)
|
||||
if (response.statusCode !== 200 || data.indexOf('unavailable') !== -1) {
|
||||
if (response.statusCode !== 200 || data.indexOf('not available in your') !== -1) {
|
||||
reject('Not Available')
|
||||
return
|
||||
} else {
|
||||
@@ -199,5 +239,3 @@ function timeout(delay = 5000) {
|
||||
}
|
||||
|
||||
var flags = new Map([[ "AC" , "🇦🇨" ] ,["AE","🇦🇪"], [ "AF" , "🇦🇫" ] , [ "AI" , "🇦🇮" ] , [ "AL" , "🇦🇱" ] , [ "AM" , "🇦🇲" ] , [ "AQ" , "🇦🇶" ] , [ "AR" , "🇦🇷" ] , [ "AS" , "🇦🇸" ] , [ "AT" , "🇦🇹" ] , [ "AU" , "🇦🇺" ] , [ "AW" , "🇦🇼" ] , [ "AX" , "🇦🇽" ] , [ "AZ" , "🇦🇿" ] , ["BA", "🇧🇦"], [ "BB" , "🇧🇧" ] , [ "BD" , "🇧🇩" ] , [ "BE" , "🇧🇪" ] , [ "BF" , "🇧🇫" ] , [ "BG" , "🇧🇬" ] , [ "BH" , "🇧🇭" ] , [ "BI" , "🇧🇮" ] , [ "BJ" , "🇧🇯" ] , [ "BM" , "🇧🇲" ] , [ "BN" , "🇧🇳" ] , [ "BO" , "🇧🇴" ] , [ "BR" , "🇧🇷" ] , [ "BS" , "🇧🇸" ] , [ "BT" , "🇧🇹" ] , [ "BV" , "🇧🇻" ] , [ "BW" , "🇧🇼" ] , [ "BY" , "🇧🇾" ] , [ "BZ" , "🇧🇿" ] , [ "CA" , "🇨🇦" ] , [ "CF" , "🇨🇫" ] , [ "CH" , "🇨🇭" ] , [ "CK" , "🇨🇰" ] , [ "CL" , "🇨🇱" ] , [ "CM" , "🇨🇲" ] , [ "CN" , "🇨🇳" ] , [ "CO" , "🇨🇴" ] , [ "CP" , "🇨🇵" ] , [ "CR" , "🇨🇷" ] , [ "CU" , "🇨🇺" ] , [ "CV" , "🇨🇻" ] , [ "CW" , "🇨🇼" ] , [ "CX" , "🇨🇽" ] , [ "CY" , "🇨🇾" ] , [ "CZ" , "🇨🇿" ] , [ "DE" , "🇩🇪" ] , [ "DG" , "🇩🇬" ] , [ "DJ" , "🇩🇯" ] , [ "DK" , "🇩🇰" ] , [ "DM" , "🇩🇲" ] , [ "DO" , "🇩🇴" ] , [ "DZ" , "🇩🇿" ] , [ "EA" , "🇪🇦" ] , [ "EC" , "🇪🇨" ] , [ "EE" , "🇪🇪" ] , [ "EG" , "🇪🇬" ] , [ "EH" , "🇪🇭" ] , [ "ER" , "🇪🇷" ] , [ "ES" , "🇪🇸" ] , [ "ET" , "🇪🇹" ] , [ "EU" , "🇪🇺" ] , [ "FI" , "🇫🇮" ] , [ "FJ" , "🇫🇯" ] , [ "FK" , "🇫🇰" ] , [ "FM" , "🇫🇲" ] , [ "FO" , "🇫🇴" ] , [ "FR" , "🇫🇷" ] , [ "GA" , "🇬🇦" ] , [ "GB" , "🇬🇧" ] , [ "HK" , "🇭🇰" ] ,["HU","🇭🇺"], [ "ID" , "🇮🇩" ] , [ "IE" , "🇮🇪" ] , [ "IL" , "🇮🇱" ] , [ "IM" , "🇮🇲" ] , [ "IN" , "🇮🇳" ] , [ "IS" , "🇮🇸" ] , [ "IT" , "🇮🇹" ] , [ "JP" , "🇯🇵" ] , [ "KR" , "🇰🇷" ] , [ "LU" , "🇱🇺" ] , [ "MO" , "🇲🇴" ] , [ "MX" , "🇲🇽" ] , [ "MY" , "🇲🇾" ] , [ "NL" , "🇳🇱" ] , [ "PH" , "🇵🇭" ] , [ "RO" , "🇷🇴" ] , [ "RS" , "🇷🇸" ] , [ "RU" , "🇷🇺" ] , [ "RW" , "🇷🇼" ] , [ "SA" , "🇸🇦" ] , [ "SB" , "🇸🇧" ] , [ "SC" , "🇸🇨" ] , [ "SD" , "🇸🇩" ] , [ "SE" , "🇸🇪" ] , [ "SG" , "🇸🇬" ] , [ "TH" , "🇹🇭" ] , [ "TN" , "🇹🇳" ] , [ "TO" , "🇹🇴" ] , [ "TR" , "🇹🇷" ] , [ "TV" , "🇹🇻" ] , [ "TW" , "🇨🇳" ] , [ "UK" , "🇬🇧" ] , [ "UM" , "🇺🇲" ] , [ "US" , "🇺🇸" ] , [ "UY" , "🇺🇾" ] , [ "UZ" , "🇺🇿" ] , [ "VA" , "🇻🇦" ] , [ "VE" , "🇻🇪" ] , [ "VG" , "🇻🇬" ] , [ "VI" , "🇻🇮" ] , [ "VN" , "🇻🇳" ] , [ "ZA" , "🇿🇦"]])
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ Thanks to & modified from
|
||||
|
||||
For Quantumult-X 598+ ONLY!!
|
||||
|
||||
2022-07-23
|
||||
|
||||
[task_local]
|
||||
|
||||
// UI 查询版本
|
||||
@@ -50,6 +52,7 @@ function GetPolicy(cnt) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const message = {
|
||||
action: "get_customized_policy",
|
||||
content: policy
|
||||
@@ -217,7 +220,7 @@ async function testDisneyPlus(pname) {
|
||||
// console.log(pname+"22: 即将登陆"+region)
|
||||
// return { region, status: STATUS_COMING }
|
||||
// }
|
||||
let { countryCode, inSupportedLocation } = await Promise.race([getLocationInfo(pname), timeout(7000)])
|
||||
let { countryCode, inSupportedLocation, accessToken } = await Promise.race([getLocationInfo(pname), timeout(7000)])
|
||||
//console.log(`getLocationInfo: countryCode=${countryCode}, inSupportedLocation=${inSupportedLocation}`)
|
||||
|
||||
region = countryCode ?? region
|
||||
@@ -234,6 +237,13 @@ async function testDisneyPlus(pname) {
|
||||
console.log(pname+": 支持 「"+region+"」")
|
||||
return { region, status: STATUS_AVAILABLE }
|
||||
}
|
||||
let support = await Promise.race([testPublicGraphqlAPI(accessToken), timeout(7000)])
|
||||
if (!support) {
|
||||
return { status: STATUS_NOT_AVAILABLE }
|
||||
}
|
||||
// 支持解锁
|
||||
return { region, status: STATUS_AVAILABLE }
|
||||
|
||||
} // sign
|
||||
} catch (error) {
|
||||
//console.log(pname+": 检测错误"+error)
|
||||
@@ -282,15 +292,15 @@ function getLocationInfo(pname) {
|
||||
attributes: {
|
||||
browserName: 'chrome',
|
||||
browserVersion: '94.0.4606',
|
||||
manufacturer: 'microsoft',
|
||||
manufacturer: 'apple',
|
||||
model: null,
|
||||
operatingSystem: 'windows',
|
||||
operatingSystemVersion: '10.0',
|
||||
operatingSystem: 'macintosh',
|
||||
operatingSystemVersion: '10.15.7',
|
||||
osDeviceIds: [],
|
||||
},
|
||||
deviceFamily: 'browser',
|
||||
deviceLanguage: 'en',
|
||||
deviceProfile: 'windows',
|
||||
deviceProfile: 'macosx',
|
||||
},
|
||||
},
|
||||
}),
|
||||
@@ -303,11 +313,15 @@ function getLocationInfo(pname) {
|
||||
//console.log('getLocationInfo: ' + data)
|
||||
reject('Not Available')
|
||||
return
|
||||
} else {let {
|
||||
} else {
|
||||
let {
|
||||
token: { accessToken },
|
||||
session: {
|
||||
inSupportedLocation,
|
||||
location: { countryCode },
|
||||
} = JSON.parse(data)?.extensions?.sdk?.session
|
||||
resolve({ inSupportedLocation, countryCode })
|
||||
},
|
||||
} = JSON.parse(data)?.extensions?.sdk
|
||||
resolve({ inSupportedLocation, countryCode, accessToken })
|
||||
}
|
||||
}, reason => {
|
||||
reject('Error')
|
||||
@@ -332,7 +346,7 @@ function testHomePage(pname) {
|
||||
$task.fetch(opts0).then(response => {
|
||||
let data = response.body
|
||||
//console.log("homepage"+response.statusCode)
|
||||
if (response.statusCode !== 200 || data.indexOf('unavailable') !== -1) {
|
||||
if (response.statusCode !== 200 || data.indexOf('not available in your') !== -1) {
|
||||
reject('Not Available')
|
||||
return
|
||||
} else {
|
||||
@@ -354,6 +368,33 @@ function testHomePage(pname) {
|
||||
})
|
||||
}
|
||||
|
||||
function testPublicGraphqlAPI(accessToken) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let opts = {
|
||||
url: 'https://disney.api.edge.bamgrid.com/v1/public/graphql',
|
||||
headers: {
|
||||
'Accept-Language': 'en',
|
||||
Authorization: accessToken,
|
||||
'Content-Type': 'application/json',
|
||||
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
query:
|
||||
'query($preferredLanguages: [String!]!, $version: String) {globalization(version: $version) { uiLanguage(preferredLanguages: $preferredLanguages) }}',
|
||||
variables: { version: '1.5.0', preferredLanguages: ['en'] },
|
||||
}),
|
||||
}
|
||||
|
||||
$task.fetch(opts).then( response => {
|
||||
|
||||
resolve(response.status === 200)
|
||||
}, reason => {
|
||||
reject('Error')
|
||||
return
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function timeout(delay = 5000) {
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
|
||||
Reference in New Issue
Block a user