Skip to content

Commit

Permalink
添加电脑微信自动登录功能
Browse files Browse the repository at this point in the history
  • Loading branch information
firesunCN committed Apr 5, 2018
1 parent 5487169 commit 36ccdbb
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ android {
applicationId "me.firesun.wechat.enhancement"
minSdkVersion 15
targetSdkVersion 23
versionCode 36
versionName "1.2.0"
versionCode 37
versionName "1.3.0"
}

buildTypes {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/me/firesun/wechat/enhancement/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import me.firesun.wechat.enhancement.plugin.ADBlock;
import me.firesun.wechat.enhancement.plugin.AntiRevoke;
import me.firesun.wechat.enhancement.plugin.AntiSnsDelete;
import me.firesun.wechat.enhancement.plugin.AutoLogin;
import me.firesun.wechat.enhancement.plugin.HideModule;
import me.firesun.wechat.enhancement.plugin.LuckMoney;
import me.firesun.wechat.enhancement.util.HookClasses;
Expand Down Expand Up @@ -45,6 +46,7 @@ private void loadPlugins(LoadPackageParam lpparam) {
AntiRevoke.getInstance().hook(lpparam);
AntiSnsDelete.getInstance().hook(lpparam);
LuckMoney.getInstance().hook(lpparam);
AutoLogin.getInstance().hook(lpparam);
HideModule.getInstance().hook(lpparam);
} catch (Error | Exception e) {
log("loadPlugins error" + e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ public static boolean isADBlock() {
return getInstance().getBoolean("is_adblock", false);
}

public static boolean isAutoLogin() {
return getInstance().getBoolean("is_autologin", false);
}


}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package me.firesun.wechat.enhancement.plugin;


import android.app.Activity;
import android.widget.Button;

import java.lang.reflect.Field;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import me.firesun.wechat.enhancement.PreferencesUtils;
import me.firesun.wechat.enhancement.util.HookClasses;
import me.firesun.wechat.enhancement.util.ReflectionUtil;

import static de.robv.android.xposed.XposedBridge.log;


public class AutoLogin {
private static AutoLogin instance = null;

private AutoLogin() {
}

public static AutoLogin getInstance() {
if (instance == null)
instance = new AutoLogin();
return instance;
}

public void hook(XC_LoadPackage.LoadPackageParam lpparam) {
XposedHelpers.findAndHookMethod(android.app.Activity.class, "onStart", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) {
try {
if (!PreferencesUtils.isAutoLogin())
return;
Activity activity = (Activity) param.thisObject;
if (activity.getClass().getName().equals(HookClasses.WebWXLoginUIClassName)) {
Class clazz = activity.getClass();
Field field = XposedHelpers.findFirstFieldByExactType(clazz, Button.class);
Button button = (Button) field.get(activity);
if (button != null) {
button.performClick();
}
}

} catch (Error | Exception e) {
log("error:" + e);
}
}
});

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected void afterHookedMethod(MethodHookParam param) {
handleTransfer(contentValues, lpparam);
}
} catch (Error | Exception e) {
log("error:"+e);
log("error:" + e);
}
}
});
Expand Down Expand Up @@ -98,7 +98,7 @@ protected void beforeHookedMethod(MethodHookParam param) {
luckyMoneyMessages.remove(0);

} catch (Error | Exception e) {
log("error:"+e);
log("error:" + e);
}
}
});
Expand All @@ -114,7 +114,7 @@ protected void afterHookedMethod(MethodHookParam param) {
}
}
} catch (Error | Exception e) {
log("error:"+e);
log("error:" + e);
}
}
});
Expand All @@ -131,7 +131,7 @@ protected void afterHookedMethod(MethodHookParam param) {
Toast.makeText(activity, "微信ID:" + wechatId + "已复制到剪切板", LENGTH_LONG).show();
}
} catch (Error | Exception e) {
log("error:"+e);
log("error:" + e);
}
}
});
Expand All @@ -148,7 +148,7 @@ protected void afterHookedMethod(MethodHookParam param) {
Toast.makeText(activity, "微信ID:" + wechatId + "已复制到剪切板", LENGTH_LONG).show();
}
} catch (Error | Exception e) {
log("error:"+e);
log("error:" + e);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class HookClasses {
public static String SQLiteDatabaseDeleteMethod = "delete";
public static String ContactInfoUIClassName = "com.tencent.mm.plugin.profile.ui.ContactInfoUI";
public static String ChatroomInfoUIClassName = "com.tencent.mm.plugin.chatroom.ui.ChatroomInfoUI";
public static String WebWXLoginUIClassName = "com.tencent.mm.plugin.webwx.ui.ExtDeviceWXLoginUI";
public static Class XMLParserClass;
public static String XMLParserMethod;
public static Class MsgInfoClass;
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
<string name="luckmoney_setting">红包设置</string>
<string name="other_setting">其他设置</string>
<string name="AntiRevoke_setting">防撤回设置</string>
<string name="ADBlock_setting">广告设置</string>
<string name="function_setting">增强功能</string>
<string name="pref_enable_adblock">过滤朋友圈广告</string>
<string name="pref_enable_autologin">电脑微信自动登录</string>
<string name="pref_enable_anti_revoke">消息防撤回</string>
<string name="pref_enable_anti_sns_delete">朋友圈防删除</string>
<string name="pref_show_icon">显示图标</string>
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/res/xml/pref_setting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,15 @@
android:title="@string/pref_enable_anti_sns_delete" />
</PreferenceCategory>

<PreferenceCategory android:title="@string/ADBlock_setting">
<PreferenceCategory android:title="@string/function_setting">
<SwitchPreference
android:defaultValue="false"
android:key="is_adblock"
android:title="@string/pref_enable_adblock" />
<SwitchPreference
android:defaultValue="false"
android:key="is_autologin"
android:title="@string/pref_enable_autologin" />
</PreferenceCategory>


Expand Down

0 comments on commit 36ccdbb

Please sign in to comment.