微信wxid加好友代码
本帖最后由 sun4ay 于 2020-10-26 17:51 编辑package net.wisedream.x.sayhi;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.Toast;
import java.util.HashMap;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import static de.robv.android.xposed.XposedHelpers.callMethod;
import static de.robv.android.xposed.XposedHelpers.callStaticMethod;
import static de.robv.android.xposed.XposedHelpers.findClass;
import static de.robv.android.xposed.XposedHelpers.newInstance;
/**
* Created by <a href="mailto:manwu91@gmail.com">monk</a> on 2019-11-27.
*/
public class XMain implements IXposedHookLoadPackage {
static final String process = "com.tencent.mm";
@Override
public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
if(process.equals(lpparam.processName)){
HideXposed.hideModule(lpparam.classLoader);
XposedHelpers.findAndHookMethod("com.tencent.mm.ui.LauncherUI", lpparam.classLoader,
"onCreateOptionsMenu", Menu.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
final Context context = (Context)param.thisObject;
Menu menu = (Menu)param.args[0];
MenuItem item = menu.add("SayHi");
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
try {
String verName = context.getPackageManager().getPackageInfo("com.tencent.mm", 0).versionName;
if (!isVersionSupported(verName)) {
Toast.makeText(context, "SayHi不支持当前版本: " + verName, Toast.LENGTH_SHORT).show();
return true;
}
}catch (Exception e){
return true;
}
AlertDialog.Builder builder = new AlertDialog.Builder(context).setCancelable(true);
builder.setTitle("对方wxid:");
final EditText etInput = new EditText(context);
builder.setView(etInput);
builder.setPositiveButton("SayHi", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String wxid = etInput.getText().toString().trim();
Log.d("xposed", "say hi to " + wxid);
sayHi(wxid, lpparam.classLoader);
}
});
builder.show();
return true;
}
});
}
});
}
}
private static boolean isVersionSupported(String verName){
return "7.0.6".equals(verName);
}
private static void sayHi(String wxid, ClassLoader cl){
if(wxid==null || wxid.length()<3){
return;
}
Class msgRequestClz = findClass("com.tencent.mm.modelmulti.h", cl);
Object msgRequest = newInstance(msgRequestClz,
wxid, // 接收者wxid
"Hi!", // 消息内容
1, // 消息type, 文本 1
0,
new HashMap()
);
Object requestSenderObj = callStaticMethod(findClass(" ,", cl), "Vs");
callMethod(requestSenderObj, "a", msgRequest, 0);
}
}
我想适配低版本的需要修改那些代码了
我想适配微信6.6.3可登录版https://wwa.lanzouj.com/ivrFThrce5a
sun4ay 发表于 2020-10-26 17:52
大牛怎么修改了我想适配微信6.6.3可登录版https://wwa.lanzouj.com/ivrFThrce5a
不用改啊 我记得有一行代码很少的 发送了点下就可以加了 judgecx 发表于 2020-10-26 17:17
那有这么麻烦,,,有一段很简单的代码搞得这么复杂
大牛怎么修改了我想适配微信6.6.3可登录版https://wwa.lanzouj.com/ivrFThrce5a 那有这么麻烦,,,有一段很简单的代码搞得这么复杂
这是自动加好友?
不需对方同意嘛?
对方需要验证吗? 本帖最后由 xuejiqiao 于 2020-10-26 17:59 编辑
其实两个js也是可以解决的。https://www.lanzoui.com/iJo1ghrd2uj
xuejiqiao 发表于 2020-10-26 17:57
其实两个js也是可以解决的。https://www.lanzoui.com/iJo1ghrd2uj
这个是hook的怎么修改了 其实有一段代码可以直接用 QingYi. 发表于 2020-10-26 18:08
其实有一段代码可以直接用
自动适配低版本微信吗
页:
[1]
2