-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrevanced.ps1
executable file
·66 lines (53 loc) · 1.97 KB
/
revanced.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Remove aliases
Get-Alias | Remove-Alias -Force
# Silent iwr
$ProgressPreference = 'SilentlyContinue'
# Set script arguments
$operation = $args[0]
$apk = $args[1]
$parameters = $args[2]
# Create functions
function mount {
java -jar revanced-cli-all.jar patch -d "GmsCore support" -i --mount -o out.apk -p revanced-patches.rvp --purge $parameters $apk
}
function unmount {
java -jar revanced-cli-all.jar utility uninstall -u -p $apk
}
function install {
java -jar revanced-cli-all.jar patch -i -o out.apk -p revanced-patches.rvp --purge $parameters $apk
}
function apk {
java -jar revanced-cli-all.jar patch -o out.apk -p revanced-patches.rvp --purge $parameters $apk
}
# Update ReVanced files
if ( -not ( Test-Path -Path .\version.json -PathType Leaf ) ) {
$versionfile = "{`n`t`"cli`": `"`",`n`t`"patches`": `"`"`n}"
$versionfile | Out-File .\version.json
}
$cli = "cli", "revanced-cli-all.jar", "revanced-cli-", "-all.jar"
$patches = "patches", "revanced-patches.rvp", "patches-", ".rvp"
foreach ( $repo in $cli, $patches ) {
$reponame = $repo[0]
$repofile = $repo[1]
$versionfile = Get-Content .\version.json | ConvertFrom-Json
$oldversion = $versionfile.$reponame
$version = Invoke-WebRequest -Uri "https://api.revanced.app/v2/revanced-$reponame/releases/latest?dev=true"
$version = (( $version | ConvertFrom-Json ).tag_name | Select-Object -First 1).Remove(0,1)
if ( $oldversion -ne $version ) {
$repoasset = $repo[2] + $version + $repo[3]
if ( Test-Path -Path $repofile -PathType Leaf ) {
Remove-Item -Path $repofile
}
$versionfile.$reponame = $version
$versionfile | ConvertTo-Json | Out-File .\version.json
Write-Output "---> Downloading $reponame version $version <---"
Invoke-WebRequest "https://github.com/revanced/revanced-$reponame/releases/download/v$version/$repoasset" -OutFile $repofile
}
}
# Patch apk
foreach ( $valid_operation in "mount", "unmount", "install", "apk") {
if ( $operation -eq $valid_operation ) {
Invoke-Expression $operation
break
}
}