-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update TestFlight scripts and modules
- Loading branch information
Showing
4 changed files
with
132 additions
and
0 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,10 @@ | ||
#!name=Automatically Join TestFlight | ||
#!desc=Automatically Join TestFlight. | ||
#!system=ios | ||
#!category=🎒 TestFlight | ||
|
||
[Script] | ||
TestFlight=type=cron, cronexp=0 */30 * * * *,script-path=https://ruleset.tiiwoo.moe/Script/testflight.js,wake-system=0,timeout=180 | ||
|
||
[MITM] | ||
hostname = %APPEND% testflight.apple.com |
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 @@ | ||
#!name=TestFlight Get Key | ||
#!desc=Get TestFlight Keys. | ||
#!system=ios | ||
#!category=🎒 TestFlight | ||
|
||
[Script] | ||
TestFlight_Get_Key=type=http-request,pattern=^https:\/\/testflight\.apple\.com\/v3\/accounts/.*\/apps$,requires-body=0,script-path=https://ruleset.tiiwoo.moe/Script/testflight_get_key.js | ||
|
||
[MITM] | ||
hostname = %APPEND% testflight.apple.com |
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,88 @@ | ||
!(async () => { | ||
ids = $persistentStore.read('APP_ID'); | ||
if (ids == '') { | ||
$notification.post( | ||
'All TestFlights have been joined', | ||
'Module has been automatically disabled', | ||
'' | ||
); | ||
$done($httpAPI('POST', '/v1/modules', { TestFlight: 'false' })); | ||
} else { | ||
ids = ids.split(','); | ||
for await (const ID of ids) { | ||
await autoPost(ID); | ||
} | ||
} | ||
$done(); | ||
})(); | ||
|
||
function autoPost(ID) { | ||
let Key = $persistentStore.read('key'); | ||
let testurl = 'https://testflight.apple.com/v3/accounts/' + Key + '/ru/'; | ||
let header = { | ||
'X-Session-Id': `${$persistentStore.read('session_id')}`, | ||
'X-Session-Digest': `${$persistentStore.read('session_digest')}`, | ||
'X-Request-Id': `${$persistentStore.read('request_id')}`, | ||
}; | ||
return new Promise(function (resolve) { | ||
$httpClient.get( | ||
{ url: testurl + ID, headers: header }, | ||
function (error, resp, data) { | ||
if (error === null) { | ||
if (resp.status == 404) { | ||
ids = $persistentStore.read('APP_ID').split(','); | ||
ids = ids.filter((ids) => ids !== ID); | ||
$persistentStore.write(ids.toString(), 'APP_ID'); | ||
console.log( | ||
ID + | ||
' ' + | ||
'This TestFlight does not exist, APP_ID has been automatically removed' | ||
); | ||
$notification.post( | ||
ID, | ||
'This TestFlight does not exist', | ||
'APP_ID has been automatically removed' | ||
); | ||
resolve(); | ||
} else { | ||
let jsonData = JSON.parse(data); | ||
if (jsonData.data == null) { | ||
console.log(ID + ' ' + jsonData.messages[0].message); | ||
resolve(); | ||
} else if (jsonData.data.status == 'FULL') { | ||
console.log(ID + ' ' + jsonData.data.message); | ||
resolve(); | ||
} else { | ||
$httpClient.post( | ||
{ url: testurl + ID + '/accept', headers: header }, | ||
function (error, resp, body) { | ||
let jsonBody = JSON.parse(body); | ||
$notification.post( | ||
jsonBody.data.name, | ||
'TestFlight joined successfully', | ||
'' | ||
); | ||
console.log( | ||
jsonBody.data.name + ' TestFlight joined successfully' | ||
); | ||
ids = $persistentStore.read('APP_ID').split(','); | ||
ids = ids.filter((ids) => ids !== ID); | ||
$persistentStore.write(ids.toString(), 'APP_ID'); | ||
resolve(); | ||
} | ||
); | ||
} | ||
} | ||
} else { | ||
if (error == 'The request timed out.') { | ||
resolve(); | ||
} else { | ||
$notification.post('Automatically join TestFlight', error, ''); | ||
console.log(ID + ' ' + error); | ||
resolve(); | ||
} | ||
} | ||
} | ||
); | ||
}); | ||
} |
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,24 @@ | ||
$persistentStore.write(null, 'request_id'); | ||
let url = $request.url; | ||
let key = url.replace(/(.*accounts\/)(.*)(\/apps)/, '$2'); | ||
let session_id = $request.headers['x-session-id']; | ||
let session_digest = $request.headers['x-session-digest']; | ||
let request_id = $request.headers['x-request-id']; | ||
$persistentStore.write(key, 'key'); | ||
$persistentStore.write(session_id, 'session_id'); | ||
$persistentStore.write(session_digest, 'session_digest'); | ||
$persistentStore.write(request_id, 'request_id'); | ||
if ($persistentStore.read('request_id') !== null) { | ||
$notification.post( | ||
'[SUCCESS] Please stop the script', | ||
'Information retrieved successfully', | ||
'' | ||
); | ||
} else { | ||
$notification.post( | ||
'[FAIL] Information retrieval failed', | ||
'Please enable the MITM H2 switch and add testflight.apple.com', | ||
'' | ||
); | ||
} | ||
$done({}); |