Skip to content

Commit aada165

Browse files
committed
Add feature to disable ads
1 parent ccdc701 commit aada165

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed

app/src/main/java/com/wmods/wppenhacer/xposed/core/devkit/Unobfuscator.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,7 +2032,7 @@ public static Class<?> loadMeManagerClass(ClassLoader classLoader) throws Except
20322032
});
20332033
}
20342034

2035-
public static Class<?> loadVerifyKeyClass(ClassLoader classLoader) throws Exception {
2035+
public synchronized static Class<?> loadVerifyKeyClass(ClassLoader classLoader) throws Exception {
20362036
return UnobfuscatorCache.getInstance().getClass(classLoader, () -> {
20372037
var classList = dexkit.findClass(FindClass.create().matcher(ClassMatcher.create().addMethod(
20382038
MethodMatcher.create().addUsingNumber(2966).paramCount(1).addParamType(int.class)
@@ -2045,11 +2045,22 @@ public static Class<?> loadVerifyKeyClass(ClassLoader classLoader) throws Except
20452045
}
20462046

20472047

2048-
public static Method loadMySearchBarMethod(ClassLoader classLoader) throws Exception {
2048+
public synchronized static Method loadMySearchBarMethod(ClassLoader classLoader) throws Exception {
20492049
return UnobfuscatorCache.getInstance().getMethod(classLoader, () -> {
20502050
Method method = findFirstMethodUsingStrings(classLoader, StringMatchType.EndsWith, "search_bar_render_start");
20512051
if (method == null) throw new NoSuchMethodException("MySearchBar method not found");
20522052
return method;
20532053
});
20542054
}
2055+
2056+
public synchronized static Method loadAdVerifyMethod(ClassLoader classLoader) throws Exception {
2057+
return UnobfuscatorCache.getInstance().getMethod(classLoader, () -> {
2058+
var clazz = findFirstClassUsingStrings(classLoader, StringMatchType.Contains, "WamoAccountSettingManager");
2059+
if (clazz == null)
2060+
throw new ClassNotFoundException("WamoAccountSettingManager Not Found");
2061+
var method = ReflectionUtils.findMethodUsingFilter(clazz, method1 -> method1.getParameterCount() == 0 && method1.getReturnType() == boolean.class);
2062+
if (method == null) throw new NoSuchMethodException("loadAdVerify Not Found");
2063+
return method;
2064+
});
2065+
}
20552066
}

app/src/main/java/com/wmods/wppenhacer/xposed/features/general/Others.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public void doHook() throws Exception {
8282
var animationEmojis = prefs.getBoolean("animation_emojis", false);
8383
var disableProfileStatus = prefs.getBoolean("disable_profile_status", false);
8484
var disableExpiration = prefs.getBoolean("disable_expiration", false);
85+
var disableAd = prefs.getBoolean("disable_ads", false);
8586

8687
propsInteger.put(3877, oldStatus ? igstatus ? 2 : 0 : 2);
8788
propsBoolean.put(5171, filterSeen);
@@ -241,6 +242,16 @@ public void doHook() throws Exception {
241242
disableExpirationVersion(classLoader);
242243
}
243244

245+
if (disableAd) {
246+
disableAds();
247+
}
248+
249+
}
250+
251+
private void disableAds() throws Exception {
252+
propsBoolean.put(22904, true);
253+
var loadAd = Unobfuscator.loadAdVerifyMethod(classLoader);
254+
XposedBridge.hookMethod(loadAd, XC_MethodReplacement.returnConstant(false));
244255
}
245256

246257
private void disablePhotoProfileStatus() throws Exception {

app/src/main/res/values/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,4 +426,8 @@
426426
<string name="show_contact_blocked">Show Contact Blocked in Conversation</string>
427427
<string name="show_contact_blocked_sum">This option verifies whether the contact may have blocked you (note: false positives may occur).</string>
428428
<string name="block_unverified">Block Unverified</string>
429+
<string name="disable_whatsapp_expiration">Disable WhatsApp Expiration</string>
430+
<string name="disable_whatsapp_expiration_sum">Deactivates the expired version of WhatsApp, (Note: Manual Disable to update WhatsApp on the Play Store or mark the Play Store on LSposed)</string>
431+
<string name="disable_ads">Disable Ads</string>
432+
<string name="disable_ads_sum">Blocks ads from appearing in WhatsApp</string>
429433
</resources>

app/src/main/res/xml/preference_general_home.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@
2121
<rikka.material.preference.MaterialSwitchPreference
2222
app:defaultValue="false"
2323
app:key="disable_expiration"
24-
app:summary="Deactivates the expired version of WhatsApp, (Note: Manual Disable to update WhatsApp on the Play Store or mark the Play Store on LSposed)"
25-
app:title="Disable WhatsApp Expiration" />
24+
app:summary="@string/disable_whatsapp_expiration_sum"
25+
app:title="@string/disable_whatsapp_expiration" />
26+
27+
<rikka.material.preference.MaterialSwitchPreference
28+
app:defaultValue="false"
29+
app:key="disable_ads"
30+
app:summary="@string/disable_ads_sum"
31+
app:title="@string/disable_ads" />
2632

2733
<rikka.material.preference.MaterialSwitchPreference
2834
app:key="lite_mode"

0 commit comments

Comments
 (0)