46 lines
1.7 KiB
Python
46 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""检查登录页当前状态:可见按钮、弹窗、表单、提示文案。"""
|
|
import json
|
|
import sys
|
|
|
|
try:
|
|
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
|
|
except Exception:
|
|
pass
|
|
|
|
from DrissionPage import ChromiumPage
|
|
|
|
DUMP = r"""
|
|
var visBtn = [].slice.call(document.querySelectorAll('button')).filter(function (b) {
|
|
return b.offsetWidth > 0;
|
|
}).map(function (b) { return (b.innerText || '').replace(/\s+/g, ''); });
|
|
var modals = [].slice.call(document.querySelectorAll('.ant-modal'));
|
|
var body = document.body ? document.body.innerText : '';
|
|
return JSON.stringify({
|
|
url: location.href,
|
|
visButtons: visBtn,
|
|
modalCount: modals.length,
|
|
modalVisible: modals.filter(function (m) { return m.offsetWidth > 0; }).length,
|
|
footer: [].slice.call(document.querySelectorAll('.ant-modal-footer button')).map(function (b) {
|
|
return (b.innerText || '').replace(/\s+/g, '') + (b.offsetWidth ? '[vis]' : '[hidden]');
|
|
}),
|
|
hasLoginForm: !!document.querySelector('#loginForm_username'),
|
|
pwdValue: (function () {
|
|
var a = [].slice.call(document.querySelectorAll('input[type=password]'));
|
|
return a.map(function (e) { return e.offsetWidth ? (e.value || '').length : -1; });
|
|
})(),
|
|
tail: body.slice(-260),
|
|
messages: [].slice.call(document.querySelectorAll('.ant-message-notice, .ant-form-explain')).map(function (e) {
|
|
return (e.innerText || '').replace(/\s+/g, '');
|
|
})
|
|
});
|
|
"""
|
|
|
|
page = ChromiumPage('127.0.0.1:9222')
|
|
t = page.latest_tab
|
|
raw = t.run_js(DUMP)
|
|
try:
|
|
print(json.dumps(json.loads(raw), ensure_ascii=False, indent=1)[:2200], flush=True)
|
|
except Exception:
|
|
print(str(raw)[:1500], flush=True)
|