Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows添加webview网页登录窗口&&视频验证码窗口&&自动过视频验证码 #106

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
**/logs
config.json
cookies.json
YmServerConfig.json
execution.json
*.js
.DS_Store
Expand Down
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/fuckZHS.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

114 changes: 114 additions & 0 deletions assets/captcha.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>网易易盾验证码-closeEnable</title>
<script src="https://cstaticdun.126.net/load.min.js"></script>
</head>

<body>
<div id="captcha"></div>
<script>
function clickCaptcha(pos) {
// alert(pos['x']+","+pos['y'])
var targetElement = document.querySelector('.yidun_bgimg');

// 检查元素是否存在
if (targetElement) {

// var x =70; // 元素中间的 x 坐标
// var y = 73; // 元素中间的 y 坐标

var rect = targetElement.getBoundingClientRect();
var x = rect.left + ~~pos['x']; // 元素中间的 x 坐标
var y = rect.top + ~~pos['y']; // 元素中间的 y 坐标

// 创建鼠标点击事件
var event = new MouseEvent('click', {
clientX: x, // 鼠标点击的 x 坐标
clientY: y, // 鼠标点击的 y 坐标
bubbles: true, // 事件冒泡
cancelable: true // 事件可取消
});

// 触发事件
targetElement.dispatchEvent(event);
console.log(`已模拟点击元素: .yidun_bgimg, 坐标: (${x}, ${y})`);
} else {
console.log('未找到元素 .yidun_bgimg');
}
}



function verify_captcha() {
var imgUrl=""
var extra=""

var imgElement = document.querySelector('.yidun_bg-img');
if (imgElement) {
imgUrl = imgElement.src;
console.log('验证码图片的 URL: ', imgUrl);
} else {
console.log('未找到对应的图片元素');
}

var extElement = document.querySelector('.yidun-fallback__tip');
if (extElement) {
extra = extElement.innerHTML;
console.log('验证码描述的 ext: ', extra);
} else {
console.log('未找到对应的描述元素');
}

pywebview.api.verify_captcha(imgUrl,extra).then(clickCaptcha)

}
var captchaIns;
initNECaptcha({
element: '#captcha',
captchaId: '4da3050565514a35a50541b0e1f54538',
mode: 'popup',
width: '320px',
closeEnable: true,
apiVersion: 2,
popupStyles: {
position: 'fixed',
top: '20%',

},
onClose: function () {
// 弹出关闭结束后将会触发该函数
},
onVerify: function (err, data) {
if (!err) {
// 验证成功后,调用 close 方法关闭弹框
captchaIns.close()
// TODO: 验证成功后继续进行业务逻辑
console.log(data)
pywebview.api.post_captcha_validate(data.validate)
}
},
onReady: function (ins) {
verify_captcha()

}
}, function (instance) {
// 初始化成功后得到验证实例 instance,可以调用实例的方法
captchaIns = instance
captchaIns.verify()

}, function (err) {
// 初始化失败后触发该函数,err 对象描述当前错误信息
})




</script>
</body>

</html>
Loading