public class WebViewHook implements IXposedHookLoadPackage {
// handleLoadPackage 会在android加载每一个apk后执行
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
// 可以从lpparam中获取当前apk的名字
if (! lpparam.packageName.equals("com.tencent.mobileqq")) {
return;
}
XposedBridge.log("WebViewHook handleLoadPackage: " + lpparam.packageName);
// 勾住 WebView 所有的构造器
XposedBridge.hookAllConstructors(WebView.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
// 打开webContentsDebuggingEnabled
XposedHelpers.callStaticMethod(WebView.class, "setWebContentsDebuggingEnabled", true);
XposedBridge.log("WebViewHook new WebView(): " + packageName);
}
});
}
}