mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-08-26 11:32:02 +00:00
fix(lz): adapt new Lanzou pages and stop duplicate release notes
Complete the fake jQuery/document sandbox for cookie, location, querySelector and chained APIs, extract ajax params by regex first with JS fallback, and generate GitHub release notes in a single job so matrix OS uploads no longer append What's Changed twice. Bump version to 0.4.3. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -50,21 +50,47 @@ public class JsExecUtils {
|
||||
*/
|
||||
public static ScriptObjectMirror executeDynamicJs(String jsText, String funName) throws ScriptException,
|
||||
NoSuchMethodException {
|
||||
ScriptEngine engine = ENGINE_MANAGER.getEngineByName("JavaScript"); // 得到脚本引擎
|
||||
return executeDynamicJs(jsText, funName, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pwd 分享密码,写入伪 DOM(#pwd / getElementById('pwd')),供新版页面取值
|
||||
*/
|
||||
public static ScriptObjectMirror executeDynamicJs(String jsText, String funName, String pwd) throws ScriptException,
|
||||
NoSuchMethodException {
|
||||
ScriptEngine engine = ENGINE_MANAGER.getEngineByName("JavaScript");
|
||||
try {
|
||||
engine.eval(JsContent.lz + "\n" + jsText);
|
||||
engine.eval(JsContent.lz);
|
||||
Invocable inv = (Invocable) engine;
|
||||
//调用js中的函数
|
||||
if (StringUtils.isNotEmpty(funName)) {
|
||||
inv.invokeFunction(funName);
|
||||
if (pwd != null) {
|
||||
inv.invokeFunction("__lzSetPwd", pwd);
|
||||
}
|
||||
return (ScriptObjectMirror) engine.get("signObj");
|
||||
try {
|
||||
engine.eval(jsText);
|
||||
if (StringUtils.isNotEmpty(funName)) {
|
||||
inv.invokeFunction(funName);
|
||||
}
|
||||
} catch (ScriptException | NoSuchMethodException | RuntimeException e) {
|
||||
ScriptObjectMirror captured = asSignObj(engine.get("signObj"));
|
||||
if (captured != null) {
|
||||
return captured;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
return asSignObj(engine.get("signObj"));
|
||||
} finally {
|
||||
// 清理引擎持有的引用,帮助 GC 回收
|
||||
clearEngineBindings(engine);
|
||||
}
|
||||
}
|
||||
|
||||
private static ScriptObjectMirror asSignObj(Object sign) {
|
||||
if (sign instanceof ScriptObjectMirror mirror
|
||||
&& (mirror.get("url") != null || mirror.get("data") != null)) {
|
||||
return mirror;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 调用执行js文件(使用缓存的 ScriptEngineManager 创建新引擎实例)
|
||||
|
||||
Reference in New Issue
Block a user