Skip to content

Commit

Permalink
1、同步unblockneteasemusic最新脚本
Browse files Browse the repository at this point in the history
2、(替低版本网易云)修复评论区加载失败
  • Loading branch information
nining377 committed Dec 3, 2021
1 parent 961572d commit 9972ef0
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 33 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.raincat.dolby_beta"
minSdkVersion 21
targetSdkVersion 29
versionCode 337
versionName "3.3.7"
versionCode 338
versionName "3.3.8"

externalNativeBuild {
cmake {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
package="com.raincat.dolby_beta">

<application
android:extractNativeLibs="true"
android:multiArch="true"
android:allowBackup="false"
android:extractNativeLibs="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:multiArch="true"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:replace="allowBackup">
Expand Down
Binary file modified app/src/main/assets/UnblockNeteaseMusic.zip
Binary file not shown.
11 changes: 6 additions & 5 deletions app/src/main/java/com/raincat/dolby_beta/helper/ClassHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
* version: 1.0
* </pre>
*/

public class ClassHelper {
//类加载器
private static ClassLoader classLoader = null;
Expand Down Expand Up @@ -231,18 +232,18 @@ public static class MainActivitySuperClass {
private static Method[] methods;
private static Method method;

public static Class<?> getClazz(Context context) {
static void getClazz(Context context) {
if (clazz == null) {
Class<?> mainActivityClass = findClass("com.netease.cloudmusic.activity.MainActivity", context.getClassLoader());
clazz = mainActivityClass.getSuperclass();
}
return clazz;
}

public static Method[] getTabItemStringMethods() {
if (methods == null && clazz != null) {
public static Method[] getTabItemStringMethods(Context context) {
if (clazz == null)
getClazz(context);
if (methods == null && clazz != null)
methods = findMethodsByExactParameters(clazz, void.class, String[].class);
}
return methods;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
import android.graphics.drawable.Icon;
import android.media.RingtoneManager;
import android.os.Build;
import android.service.notification.StatusBarNotification;
import android.text.TextUtils;

import java.util.List;

import androidx.annotation.RequiresApi;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public class SettingHelper {
public static final String black_title = "本地黑胶";
public static final String black_sub = "去广告、鲸云音效、个性换肤等(自定义启动图等需要访问网易服务器的设置不可用)";

public static final String fix_comment_key = "β_fix_comment_key";
public static final String fix_comment_title = "修复评论区加载失败";
public static final String fix_comment_sub = "如平时不看评论区或评论区无问题请勿打钩";

public static final String update_key = "β_update_key";
public static final String update_title = "隐藏升级提示";

Expand Down Expand Up @@ -148,6 +152,7 @@ public void refreshSetting(Context context) {
settingMap.put(dex_key, sharedPreferences.getBoolean(dex_key, true));
settingMap.put(warn_key, sharedPreferences.getBoolean(warn_key, true));
settingMap.put(black_key, sharedPreferences.getBoolean(black_key, true));
settingMap.put(fix_comment_key, sharedPreferences.getBoolean(fix_comment_key, true));
settingMap.put(update_key, sharedPreferences.getBoolean(update_key, true));
settingMap.put(sign_key, sharedPreferences.getBoolean(sign_key, true));
settingMap.put(sign_song_key, sharedPreferences.getBoolean(sign_song_key, false));
Expand Down
31 changes: 27 additions & 4 deletions app/src/main/java/com/raincat/dolby_beta/hook/EAPIHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,30 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
jsonObject.put("/api/v1/content/exposure/comment/banner/get", object);
}
original = jsonObject.toString();
} else if (SettingHelper.getInstance().isEnable(SettingHelper.fix_comment_key) &&
original.contains("\\/api\\/resource\\/comment\\/musiciansaid\\/authors")) {
JSONObject jsonObject = new JSONObject(original);
JSONObject object = jsonObject.getJSONObject("/api/resource/comment/musiciansaid/authors");
JSONObject data = object.getJSONObject("data");
JSONArray team = data.getJSONArray("team");
for (int i = 0; i < team.length(); i++) {
JSONObject o = team.getJSONObject(i);
String s = o.optString("authorTypeText");
if (s != null && s.equals("作者")) {
long uid = o.optLong("uid");
long artistId = o.optLong("artistId");
if (uid > 2147483647) {
JSONObject artistJSONObject = jsonObject.getJSONObject("/api/auth/artist");
JSONObject authJSONObject = artistJSONObject.getJSONObject("auth");
while (uid > 2147483647)
uid = uid / 10;
authJSONObject.put(artistId + "", uid);
artistJSONObject.put("auth", authJSONObject);
jsonObject.put("/api/auth/artist", artistJSONObject);
original = jsonObject.toString();
}
}
}
}
} else if (path.contains("upload/cloud/info/v2")) {
JSONObject jsonObject = new JSONObject(original);
Expand All @@ -89,11 +113,10 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
original = original.replace("\"waitTime\":60,", "\"waitTime\":5,");
CloudDao.getInstance(context).saveSong(Integer.parseInt(jsonObject.getString("id")), original);
} else if (path.contains("cloud/pub/v2")) {
String songid = EAPIHelper.decrypt(ClassHelper.HttpParams.getParams(context, eapi).get("params")).getString("songid");
EAPIHelper.uploadCloud(songid);
original = CloudDao.getInstance(context).getSong(Integer.parseInt(songid));
String songId = EAPIHelper.decrypt(ClassHelper.HttpParams.getParams(context, eapi).get("params")).getString("songid");
EAPIHelper.uploadCloud(songId);
original = CloudDao.getInstance(context).getSong(Integer.parseInt(songId));
}

param.setResult(param.getResult() instanceof JSONObject ? new JSONObject(original) : original);
}
});
Expand Down
15 changes: 7 additions & 8 deletions app/src/main/java/com/raincat/dolby_beta/hook/HideTabHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import java.util.List;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;

import static de.robv.android.xposed.XposedBridge.hookMethod;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;

/**
Expand All @@ -30,18 +30,17 @@ public HideTabHook(Context context, int versionCode) {
if (!SettingHelper.getInstance().isEnable(SettingHelper.beauty_tab_hide_key) || versionCode < 138)
return;

Class<?> superClass = ClassHelper.MainActivitySuperClass.getClazz(context);
Method[] setTabItemMethods = ClassHelper.MainActivitySuperClass.getTabItemStringMethods();
if (superClass != null && setTabItemMethods.length != 0) {
Method[] setTabItemMethods = ClassHelper.MainActivitySuperClass.getTabItemStringMethods(context);
if (setTabItemMethods != null && setTabItemMethods.length != 0) {
for (Method method : setTabItemMethods) {
findAndHookMethod(superClass, method.getName(), String[].class, new XC_MethodHook() {
hookMethod(method, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
protected void beforeHookedMethod(final MethodHookParam param) {
if (param.args[0] == null || ((String[]) param.args[0]).length < 2)
return;
String[] tabNames = (String[]) param.args[0];
String tabName = Arrays.toString(tabNames);
if ((tabName.contains("我的") && tabName.contains("发现")) || (tabName.contains("mine") && tabName.contains("main"))) {
if ((tabName.contains("我的") && tabName.contains("发现")) || (tabName.contains("mine") && tabName.contains("wow"))) {
String[] strings = new String[2];
System.arraycopy(tabNames, 0, strings, 0, 2);
param.args[0] = strings;
Expand All @@ -50,7 +49,7 @@ protected void beforeHookedMethod(final MethodHookParam param) throws Throwable
});
}

XposedBridge.hookMethod(ClassHelper.MainActivitySuperClass.getViewPagerInitMethod(context), new XC_MethodHook() {
hookMethod(ClassHelper.MainActivitySuperClass.getViewPagerInitMethod(context), new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
super.beforeHookedMethod(param);
Expand Down
12 changes: 4 additions & 8 deletions app/src/main/java/com/raincat/dolby_beta/hook/MagiskFixHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ protected void beforeHookedMethod(MethodHookParam param) {
if (state.contains(Environment.MEDIA_MOUNTED))
list.add(sdCard);
}

param.setResult(list);
}
});
Expand All @@ -47,9 +46,8 @@ public String getPrimaryStoragePath(Context context) {
return paths[0];
} catch (Exception e) {
e.printStackTrace();
return null;
}

return null;
}

// 获取次存储卡路径,一般就是外置 TF 卡了. 不过也有可能是 USB OTG (Environment.MEDIA_MOUNTED_READ_ONLY),OTG为只读
Expand All @@ -58,13 +56,11 @@ public String getSecondaryStoragePath(Context context) {
StorageManager sm = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
Method getVolumePathsMethod = StorageManager.class.getMethod("getVolumePaths");
String[] paths = (String[]) getVolumePathsMethod.invoke(sm);
return paths.length <= 1 ? null : paths[1];
return (paths == null || paths.length <= 1) ? null : paths[1];
} catch (Exception e) {
e.printStackTrace();
return null;
}

return null;

}

// 获取存储卡的挂载状态. path 参数传入上两个方法得到的路径
Expand All @@ -75,8 +71,8 @@ public String getStorageState(Context context, String path) {
return (String) getVolumeStateMethod.invoke(sm, path);
} catch (Exception e) {
e.printStackTrace();
return null;
}
return null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import com.raincat.dolby_beta.view.setting.BeautyView;
import com.raincat.dolby_beta.view.setting.BlackView;
import com.raincat.dolby_beta.view.setting.DexView;
import com.raincat.dolby_beta.view.setting.FixCommentView;
import com.raincat.dolby_beta.view.setting.MasterView;
import com.raincat.dolby_beta.view.setting.ProxyView;
import com.raincat.dolby_beta.view.setting.SignSongDailyView;
Expand Down Expand Up @@ -227,6 +228,8 @@ private void showSettingDialog(final Context context) {
warnView.setBaseOnView(masterView);
BlackView blackView = new BlackView(context);
blackView.setBaseOnView(masterView);
FixCommentView fixCommentView = new FixCommentView(context);
fixCommentView.setBaseOnView(masterView);
UpdateView updateView = new UpdateView(context);
updateView.setBaseOnView(masterView);
SignView signView = new SignView(context);
Expand All @@ -245,6 +248,7 @@ private void showSettingDialog(final Context context) {
dialogRoot.addView(dexView);
dialogRoot.addView(warnView);
dialogRoot.addView(blackView);
dialogRoot.addView(fixCommentView);
dialogRoot.addView(updateView);
dialogRoot.addView(signView);
dialogRoot.addView(signSongDailyView);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.raincat.dolby_beta.view.setting;

import android.content.Context;
import android.util.AttributeSet;

import com.raincat.dolby_beta.helper.SettingHelper;
import com.raincat.dolby_beta.view.BaseDialogItem;

/**
* <pre>
* author : RainCat
* e-mail : nining377@gmail.com
* time : 2021/11/30
* desc : 评论区加载失败
* version: 1.0
* </pre>
*/

public class FixCommentView extends BaseDialogItem {
public FixCommentView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}

public FixCommentView(Context context, AttributeSet attrs) {
super(context, attrs);
}

public FixCommentView(Context context) {
super(context);
}

@Override
public void init(Context context, AttributeSet attrs) {
super.init(context, attrs);
title = SettingHelper.fix_comment_title;
sub = SettingHelper.fix_comment_sub;
key = SettingHelper.fix_comment_key;
setData(true, SettingHelper.getInstance().getSetting(key));

setOnClickListener(view -> {
SettingHelper.getInstance().setSetting(key, !checkBox.isChecked());
sendBroadcast(SettingHelper.refresh_setting);
});
}
}

0 comments on commit 9972ef0

Please sign in to comment.