-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6946d8
commit 3526308
Showing
10 changed files
with
105 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
app/src/main/java/io/github/chipppppppppp/lime/hooks/Console.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.github.chipppppppppp.lime.hooks; | ||
|
||
import de.robv.android.xposed.XposedBridge; | ||
|
||
public class Console { | ||
public void log(Object arg) { | ||
XposedBridge.log(String.valueOf(arg)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
app/src/main/java/io/github/chipppppppppp/lime/hooks/ModifyRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package io.github.chipppppppppp.lime.hooks; | ||
|
||
import android.util.Base64; | ||
|
||
import de.robv.android.xposed.XC_MethodHook; | ||
import de.robv.android.xposed.XposedBridge; | ||
import de.robv.android.xposed.callbacks.XC_LoadPackage; | ||
import io.github.chipppppppppp.lime.LimeOptions; | ||
import io.github.chipppppppppp.lime.Main; | ||
|
||
import org.mozilla.javascript.Context; | ||
import org.mozilla.javascript.Scriptable; | ||
import org.mozilla.javascript.ScriptableObject; | ||
|
||
public class ModifyRequest implements IHook { | ||
@Override | ||
public void hook(LimeOptions limeOptions, XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable { | ||
XposedBridge.hookAllMethods( | ||
loadPackageParam.classLoader.loadClass(Constants.REQUEST_HOOK.className), | ||
Constants.REQUEST_HOOK.methodName, | ||
new XC_MethodHook() { | ||
@Override | ||
protected void beforeHookedMethod(MethodHookParam param) throws Throwable { | ||
final String script = new String(Base64.decode(Main.xPrefs.getString("encoded_custom_js", ""), Base64.NO_WRAP)); | ||
Context ctx = Context.enter(); | ||
ctx.setOptimizationLevel(-1); | ||
try { | ||
Scriptable scope = ctx.initStandardObjects(); | ||
Object jsCommunication = Context.javaToJS(new Communication(Communication.Type.REQUEST, param.args[0].toString(), param.args[1]), scope); | ||
ScriptableObject.putProperty(scope, "communication", jsCommunication); | ||
ScriptableObject.putProperty(scope, "console", Context.javaToJS(new Console(), scope)); | ||
ctx.evaluateString(scope, script, "Script", 1, null); | ||
} catch (Exception e) { | ||
XposedBridge.log(e.toString()); | ||
} finally { | ||
Context.exit(); | ||
} | ||
} | ||
} | ||
); | ||
} | ||
} |
42 changes: 11 additions & 31 deletions
42
...ppppp/lime/hooks/ChangeCommunication.java → ...pppppppppp/lime/hooks/ModifyResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
app/src/main/java/io/github/chipppppppppp/lime/hooks/OutputRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.github.chipppppppppp.lime.hooks; | ||
|
||
import de.robv.android.xposed.XC_MethodHook; | ||
import de.robv.android.xposed.XposedBridge; | ||
import de.robv.android.xposed.callbacks.XC_LoadPackage; | ||
import io.github.chipppppppppp.lime.LimeOptions; | ||
|
||
public class OutputRequest implements IHook { | ||
@Override | ||
public void hook(LimeOptions limeOptions, XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable { | ||
if (!limeOptions.outputCommunication.checked) return; | ||
|
||
XposedBridge.hookAllMethods( | ||
loadPackageParam.classLoader.loadClass(Constants.REQUEST_HOOK.className), | ||
Constants.REQUEST_HOOK.methodName, | ||
new XC_MethodHook() { | ||
@Override | ||
protected void beforeHookedMethod(MethodHookParam param) throws Throwable { | ||
XposedBridge.log(new Communication(Communication.Type.REQUEST, param.args[0].toString(), param.args[1]).toString()); | ||
} | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters