Рефакторинг патчей, реализация Список патчей:
settings_urls: ✔ enabled disable_ad: ✔ enabled disable_beta_banner: ✔ enabled insert_new: ✔ enabled color_theme: ✔ enabled change_server: ✘ disabled package_name: ✔ enabled replace_navbar: ✔ enabled compress: ✔ enabled, обновление описаний
This commit is contained in:
@@ -1,26 +1,33 @@
|
||||
"""
|
||||
Заменяет сервер api
|
||||
Заменяет сервер api
|
||||
|
||||
"change_server": {
|
||||
"enabled": true,
|
||||
"server": "https://anixarty.wowlikon.tech/modding"
|
||||
}
|
||||
"""
|
||||
|
||||
priority = 0
|
||||
|
||||
# imports
|
||||
import json
|
||||
import requests
|
||||
from tqdm import tqdm
|
||||
|
||||
|
||||
# Patch
|
||||
def apply(config: dict) -> bool:
|
||||
response = requests.get(config['server'])
|
||||
assert response.status_code == 200, f"Failed to fetch data {response.status_code} {response.text}"
|
||||
|
||||
new_api = json.loads(response.text)
|
||||
for item in new_api['modifications']:
|
||||
tqdm.write(f"Изменение {item['file']}")
|
||||
filepath = './decompiled/smali_classes2/com/swiftsoft/anixartd/network/api/'+item['file']
|
||||
|
||||
with open(filepath, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
with open(filepath, 'w') as f:
|
||||
if content.count(item['src']) == 0:
|
||||
tqdm.write(f"⚠ Не найдено {item['src']}")
|
||||
@@ -28,18 +35,22 @@ def apply(config: dict) -> bool:
|
||||
|
||||
tqdm.write(f"Изменение Github ссылки")
|
||||
filepath = './decompiled/smali_classes2/com/swiftsoft/anixartd/utils/anixnet/GithubPagesNetFetcher.smali'
|
||||
|
||||
with open(filepath, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
with open(filepath, 'w') as f:
|
||||
f.write(content.replace('const-string v1, "https://anixhelper.github.io/pages/urls.json"', f'const-string v1, "{new_api["gh"]}"'))
|
||||
|
||||
content = ""
|
||||
tqdm.write("Удаление динамического выбора сервера")
|
||||
filepath = './decompiled/smali_classes2/com/swiftsoft/anixartd/DaggerApp_HiltComponents_SingletonC$SingletonCImpl$SwitchingProvider.smali'
|
||||
|
||||
with open(filepath, 'r') as f:
|
||||
for line in f.readlines():
|
||||
if "addInterceptor" in line: continue
|
||||
content += line
|
||||
|
||||
with open(filepath, 'w') as f:
|
||||
f.write(content)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user