importClass(android.os.Build);
window = floaty.rawWindow(
<frame bg="#00000000" id="frame" h="*">
<text id="action1" text="拖动|最小化" gravity="center" textColor="#ffffffff" bg="#66000000" />
<text id="action2" text="关闭" gravity="center" textColor="#ffffffff" bg="#66000000" />
<text id="action4" text="切换" gravity="center" textColor="#ffffffff" bg="#66000000" />
<text id="action5" text="网页路径" gravity="center" textColor="#ffffffff" bg="#66000000" />
<text id="action6" text="嗅探资源" gravity="center" textColor="#ffffffff" bg="#66000000" />
<text id="action7" text="输入网址" gravity="center" textColor="#ffffffff" bg="#66000000" />

    <input id="action3" text="..." gravity="left|top" textColor="#ff000000" bg="#ffeeffff" textSize="10sp"/>
    <webview id="webView" textSize="16sp" />
</frame>);

function rip(str, str) {
ui.run(function() {
window.disableFocus();
});
window.setPosition(2000, 2000);

kjsr = dialogs.rawInput(str, str);

window.setPosition(0, 0);
ui.run(function() {
    window.requestFocus();
});
log(kjsr);
if (kjsr == null) {
    return arr;
} else {
    return kjsr;
}

}
zrjspic = `
 
// 选择所有的<a>标签
var linkspenglishan = document.querySelectorAll('img');

// 遍历链接并打印href属性
linkspenglishan.forEach(function(linkspenglishan) {
console.log(linkspenglishan.src);
});
 
; zrjsvideo =
 
 
// 选择所有的 <video> 元素
var videos = document.querySelectorAll('video');

// 遍历所有视频元素并打印它们的 src 属性
videos.forEach(function(video) {
// 获取视频的 src 属性
var src = video.src;

// 如果 video 元素使用了 source 子元素定义视频源
var sources = video.querySelectorAll('source');
sources.forEach(function(source) {
console.log(source.src); // 打印 source 元素的 src 属性
});

// 如果 video 元素直接定义了 src 属性
if (src) {
console.log(src);
}
});
 
 
; zrjssy =
 
// 使用var代替const
var resources = window.performance.getEntriesByType('resource');

// 遍历资源并打印相关信息
for (var i = 0; i < resources.length; i++) {
var resource = resources[i];
var type = resource.initiatorType; // 获取资源类型
var url = resource.name; // 获取资源URL
console.log('Resource Type: ' + type + ', URL: ' + url);
}
 
`;

window.action7.on("touch_down", function() { 
threads.start(function() {
xwz=rip("输入网址", "http://");
ui.run(function() {
window.webView.loadUrl(xwz);
});
});
});

window.action6.on("touch_down", function() { 
threads.start(function() {
ui.run(function() {
window.action3.text("");
nr = zrjssy;
window.webView.evaluateJavascript("javascript:" + nr, null);
mog("注入javascript:\n<script>\n" + nr + "\n</script>"); 
});

});

});

ui.run(function() {
view = window.webView;
var MyWebChromeClient = JavaAdapter(android.webkit.WebChromeClient, {
onConsoleMessage: function(message) {
tmp = message.message();
if (!tmp.includes("base64")) {
mog("" + tmp);
}
}
});
view.setWebChromeClient(MyWebChromeClient);
webSettings = view.getSettings();
webSettings.setJavaScriptEnabled(true); 
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
webSettings.setMixedContentMode(webSettings.MIXED_CONTENT_ALWAYS_ALLOW);

window.requestFocus();
view.setBackgroundColor(colors.parseColor("#11000000"));
view.loadUrl("https://i.meituan.com/mttouch/page/home");
});

function mog(str) {
builder = new android.text.SpannableStringBuilder();
currentText = window.action3.getText();
builder.append(str + "\n").append(currentText);
ui.run(function() {
window.action3.text(builder);
});

}

function onClick() {
if (zkkz == 0) {
zkkz = 1;
zhankaiaction();
window.setPosition(0, 0);
window.requestFocus();

} else {
    zkkz = 0;
    zhedieaction();
    window.disableFocus();
    window.setPosition(window.getX(), window.getY());
}

}
window.action1.setOnTouchListener(function(view, event) {
switch (event.getAction()) {
case event.ACTION_DOWN:
x = event.getRawX();
y = event.getRawY();
windowX = window.getX();
windowY = window.getY();
return true;
case event.ACTION_MOVE:
//移动手指时调整悬浮窗位置
dx = (event.getRawX() - x);
dy = (event.getRawY() - y);
window.setPosition(windowX + dx, windowY + dy);
return true;
case event.ACTION_UP:
//手指弹起时如果偏移很小则判断为点击
if (Math.abs(event.getRawY() - y) < 5 && Math.abs(event.getRawX() - x) < 5) {
onClick();
}
return true;
}
return true;
});

function dbfo(k, x, y, w, h) {
ui.run(function() {
eval("var layoutParams = window." + k + ".getLayoutParams();");
layoutParams.leftMargin = x;
layoutParams.topMargin = y;
layoutParams.width = w;
layoutParams.height = h;
eval("window." + k + ".setLayoutParams(layoutParams);");
});
}

zkkz = 1;
zhankaiaction();
window.setPosition(0, 0);

window.action2.on("touch_down", function() {
threads.start(function() {
soketkz = 1;

    ui.run(function() {
        webView = window.webView;
        webView.evaluateJavascript("javascript:" + wangye, null);

        // 从布局中移除 WebView
        layout = webView.getParent();
        if (layout != null) {
            layout.removeView(webView);
        }

        // 停止加载
        webView.stopLoading();

        // 清除缓存和历史记录
        webView.clearHistory();
        webView.clearCache(true);

        // 加载空白页
        webView.loadUrl("about:blank");

        // 移除回调
        webView.setWebViewClient(null);
        webView.setWebChromeClient(null);

        // 销毁 WebView
        webView.destroy(); 
    });
});
threads.shutDownAll();
exit();

});
qh = 0;
window.action4.on("touch_down", function() {
if (qh == 0) {
qh = 1;
dbfo("action3", 0 + x, 111 + y, 1080, 1080);
dbfo("webView", 0 + x, 1192 + y, 1080, 1080);
} else {
qh = 0;
dbfo("webView", 0 + x, 111 + y, 1080, 1080);
dbfo("action3", 0 + x, 1192 + y, 1080, 1080);
}
});

function zhankaiaction() {

x = 0;
y = 0;
dbfo("webView", 0 + x, 111 + y, 1080, 1080);
dbfo("action3", 0 + x, 1192 + y, 1080, 1080);
dbfo("action1", 0, 0, 110, 110);
dbfo("action7", 115 + x, 0, 505, 110);
x = 395;
dbfo("action4", 345 + x, 0, 110, 110);
dbfo("action5", 460 + x, 0, 110, 110);
dbfo("action6", 230 + x, 0, 110, 110);
dbfo("action2", 575 + x, 0, 110, 110);
x = 0;

}

function zhedieaction() {
dbfo("webView", 0, 0, 0, 0);
dbfo("action1", 0, 0, 110, 110);
dbfo("action2", 0, 0, 0, 0);
dbfo("action3", 0, 0, 0, 0);
dbfo("action4", 0, 0, 0, 0);
dbfo("action5", 0, 0, 0, 0);
dbfo("action6", 0, 0, 0, 0);
dbfo("action7", 0, 0, 0, 0);
}

while (true) {
sleep(1000);
}