|
@@ -555,6 +555,44 @@ def change_fms_file(path_dest, fms_enable):
|
|
f.write(line)
|
|
f.write(line)
|
|
|
|
|
|
|
|
|
|
|
|
+def change_adblock_file(path_dest, package, use_adblock):
|
|
|
|
+ if use_adblock == 0:
|
|
|
|
+ build_gradle = os.path.join(path_dest, 'app/build.gradle')
|
|
|
|
+ with open(build_gradle, "r") as f:
|
|
|
|
+ lines = f.readlines()
|
|
|
|
+ with open(build_gradle, "w") as f:
|
|
|
|
+ for line in lines:
|
|
|
|
+ if "removeAdblock" in line:
|
|
|
|
+ continue
|
|
|
|
+ else:
|
|
|
|
+ f.write(line)
|
|
|
|
+
|
|
|
|
+ path_package_id = package.replace(".", "/")
|
|
|
|
+ code_path = "app/src/main/java/"
|
|
|
|
+ code_path = os.path.join(path_dest, code_path, path_package_id)
|
|
|
|
+ javas = [os.path.join(dp, f) for dp, dn, filenames in os.walk(code_path) for f in filenames]
|
|
|
|
+ for j in javas:
|
|
|
|
+ print(j)
|
|
|
|
+ with open(j, "r") as f:
|
|
|
|
+ lines = f.readlines()
|
|
|
|
+ with open(j, "w") as f:
|
|
|
|
+ counter = 0
|
|
|
|
+ for line in lines:
|
|
|
|
+ if counter == 0:
|
|
|
|
+ if "removeAdblock" in line:
|
|
|
|
+ continue
|
|
|
|
+ elif "import org.adblockplus.libadblockplus.android" in line:
|
|
|
|
+ continue
|
|
|
|
+ elif "removeAdbMultiLine" in line:
|
|
|
|
+ counter = 11
|
|
|
|
+ elif "extends AdblockWebView" in line:
|
|
|
|
+ replaced = line.replace("extends AdblockWebView", "extends WebView")
|
|
|
|
+ f.write(replaced)
|
|
|
|
+ else:
|
|
|
|
+ f.write(line)
|
|
|
|
+ else:
|
|
|
|
+ counter = counter - 1
|
|
|
|
+
|
|
|
|
|
|
def run_build(path_dest):
|
|
def run_build(path_dest):
|
|
gradlew = os.path.join(path_dest, "gradlew")
|
|
gradlew = os.path.join(path_dest, "gradlew")
|
|
@@ -624,6 +662,7 @@ def build_apk():
|
|
keystore = None
|
|
keystore = None
|
|
huawei_file = None
|
|
huawei_file = None
|
|
fms_enable = 1
|
|
fms_enable = 1
|
|
|
|
+ use_adblock = 0
|
|
key_exists = False
|
|
key_exists = False
|
|
# tabs = ["1", "2", "3", "4"]
|
|
# tabs = ["1", "2", "3", "4"]
|
|
fb_order = "1,2,3,4,5"
|
|
fb_order = "1,2,3,4,5"
|
|
@@ -698,6 +737,9 @@ def build_apk():
|
|
if 'fms_enable' in request.form:
|
|
if 'fms_enable' in request.form:
|
|
fms_enable = int(request.form['fms_enable'])
|
|
fms_enable = int(request.form['fms_enable'])
|
|
|
|
|
|
|
|
+ if 'use_adblock' in request.form:
|
|
|
|
+ use_adblock = int(request.form['use_adblock'])
|
|
|
|
+
|
|
if 'alias' in request.form:
|
|
if 'alias' in request.form:
|
|
if request.form['alias']:
|
|
if request.form['alias']:
|
|
key["alias"] = request.form['alias']
|
|
key["alias"] = request.form['alias']
|
|
@@ -819,6 +861,7 @@ def build_apk():
|
|
change_tab(path_dest, tabs, tab_icon, package_id, tab3_mode, tab_amount)
|
|
change_tab(path_dest, tabs, tab_icon, package_id, tab3_mode, tab_amount)
|
|
change_huawei_file(path_dest, huawei_file, package_id)
|
|
change_huawei_file(path_dest, huawei_file, package_id)
|
|
change_fms_file(path_dest, fms_enable)
|
|
change_fms_file(path_dest, fms_enable)
|
|
|
|
+ change_adblock_file(path_dest, package_id, use_adblock)
|
|
except BaseException as e:
|
|
except BaseException as e:
|
|
vprint(traceback.format_exc())
|
|
vprint(traceback.format_exc())
|
|
return {"status": "2", "message": "Process failure\n{}\n".format(str(e))}
|
|
return {"status": "2", "message": "Process failure\n{}\n".format(str(e))}
|