diff --git a/Scripts/disney-ui-check.js b/Scripts/disney-ui-check.js index e7a5818..ca7bdd4 100644 --- a/Scripts/disney-ui-check.js +++ b/Scripts/disney-ui-check.js @@ -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 @@ -81,6 +83,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) @@ -102,57 +111,88 @@ async function testDisneyPlus() { } function getLocationInfo() { - return new Promise((resolve, reject) => { - let opts0 = { - url: 'https://disney.api.edge.bamgrid.com/graph/v1/device/graphql', - method: "POST", - opts: opts, - headers: { - 'Accept-Language': 'en', - "Authorization": 'ZGlzbmV5JmJyb3dzZXImMS4wLjA.Cu56AgSfBTDag5NiRA81oLHkDZfu5L3CKadnefEAY84', - 'Content-Type': 'application/json', - 'User-Agent': UA, - }, - body: JSON.stringify({ - query: 'mutation registerDevice($input: RegisterDeviceInput!) { registerDevice(registerDevice: $input) { grant { grantType assertion } } }', - variables: { - input: { - applicationRuntime: 'chrome', - attributes: { - browserName: 'chrome', - browserVersion: '94.0.4606', - manufacturer: 'microsoft', - model: null, - operatingSystem: 'windows', - operatingSystemVersion: '10.0', - osDeviceIds: [], - }, - deviceFamily: 'browser', - deviceLanguage: 'en', - deviceProfile: 'windows', - }, - }, - }), - } - - $task.fetch(opts0).then(response => { - let data = response.body - console.log("locationinfo:"+response.statusCode) - if (response.statusCode !== 200) { - console.log('getLocationInfo: ' + data) - reject('Not Available') - return - } else {let { - inSupportedLocation, - location: { countryCode }, - } = JSON.parse(data)?.extensions?.sdk?.session - resolve({ inSupportedLocation, countryCode }) - } - }, reason => { - reject('Error') - return - }) - }) + return new Promise((resolve, reject) => { + let opts0 = { + url: 'https://disney.api.edge.bamgrid.com/graph/v1/device/graphql', + method: "POST", + opts: opts, + headers: { + 'Accept-Language': 'en', + "Authorization": 'ZGlzbmV5JmJyb3dzZXImMS4wLjA.Cu56AgSfBTDag5NiRA81oLHkDZfu5L3CKadnefEAY84', + 'Content-Type': 'application/json', + 'User-Agent': UA, + }, + body: JSON.stringify({ + query: 'mutation registerDevice($input: RegisterDeviceInput!) { registerDevice(registerDevice: $input) { grant { grantType assertion } } }', + variables: { + input: { + applicationRuntime: 'chrome', + attributes: { + browserName: 'chrome', + browserVersion: '94.0.4606', + manufacturer: 'apple', + model: null, + operatingSystem: 'macintosh', + operatingSystemVersion: '10.15.7', + osDeviceIds: [], + }, + deviceFamily: 'browser', + deviceLanguage: 'en', + deviceProfile: 'macosx', + }, + }, + }), + } + + $task.fetch(opts0).then(response => { + let data = response.body + console.log("locationinfo:"+response.statusCode) + if (response.statusCode !== 200) { + console.log('getLocationInfo: ' + data) + reject('Not Available') + return + } else { + let { + token: { accessToken }, + session: { + inSupportedLocation, + location: { countryCode }, + }, + } = JSON.parse(data)?.extensions?.sdk + resolve({ inSupportedLocation, countryCode, accessToken }) + } + }, reason => { + reject('Error') + return + }) + }) +} + +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() { @@ -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" , "🇿🇦"]]) - - diff --git a/Scripts/switch-check-disneyplus.js b/Scripts/switch-check-disneyplus.js index cfbcac8..aee695e 100644 --- a/Scripts/switch-check-disneyplus.js +++ b/Scripts/switch-check-disneyplus.js @@ -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) @@ -280,17 +290,17 @@ function getLocationInfo(pname) { input: { applicationRuntime: 'chrome', attributes: { - browserName: 'chrome', - browserVersion: '94.0.4606', - manufacturer: 'microsoft', - model: null, - operatingSystem: 'windows', - operatingSystemVersion: '10.0', - osDeviceIds: [], + browserName: 'chrome', + browserVersion: '94.0.4606', + manufacturer: 'apple', + model: null, + 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 { - inSupportedLocation, - location: { countryCode }, - } = JSON.parse(data)?.extensions?.sdk?.session - resolve({ inSupportedLocation, countryCode }) + } else { + let { + token: { accessToken }, + session: { + inSupportedLocation, + location: { 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(() => {