| 588 | #endif |
| 589 | |
| 590 | QString CFrmWebView::AutoFillForm() |
| 591 | { |
| 592 | return R"( |
| 593 | // 自动填充用户名和密码字段 |
| 594 | function autoFillForm(username, password) { |
| 595 | // 查找用户名输入框 |
| 596 | var usernameFields = [ |
| 597 | 'input[type="text"]', |
| 598 | 'input[type="email"]', |
| 599 | 'input[name="username"]', |
| 600 | 'input[name="user"]', |
| 601 | 'input[name="email"]', |
| 602 | 'input[id="username"]', |
| 603 | 'input[id="user"]', |
| 604 | 'input[id="email"]' |
| 605 | ]; |
| 606 | |
| 607 | // 查找密码输入框 |
| 608 | var passwordFields = [ |
| 609 | 'input[type="password"]', |
| 610 | 'input[name="password"]', |
| 611 | 'input[name="pass"]', |
| 612 | 'input[id="password"]', |
| 613 | 'input[id="pass"]' |
| 614 | ]; |
| 615 | |
| 616 | var arrUser = []; |
| 617 | var arrPassword = []; |
| 618 | |
| 619 | // 尝试填充用户名 |
| 620 | usernameFields.forEach(function(selector) { |
| 621 | var field = document.querySelector(selector); |
| 622 | if (field && !field.value) { |
| 623 | arrUser.push(field); |
| 624 | // 触发 change 事件 |
| 625 | //var event = new Event('input', { bubbles: true }); |
| 626 | //field.dispatchEvent(event); |
| 627 | } |
| 628 | }); |
| 629 | |
| 630 | // 尝试填充密码 |
| 631 | passwordFields.forEach(function(selector) { |
| 632 | var field = document.querySelector(selector); |
| 633 | if (field && !field.value) { |
| 634 | arrPassword.push(field); |
| 635 | // 触发 change 事件 |
| 636 | //var event = new Event('input', { bubbles: true }); |
| 637 | //field.dispatchEvent(event); |
| 638 | } |
| 639 | }); |
| 640 | |
| 641 | arrUser.forEach(function(input) { |
| 642 | if(!input.disabled && !input.readOnly) |
| 643 | input.value = username; |
| 644 | }); |
| 645 | arrPassword.forEach(function(input) { |
| 646 | if(!input.disabled && !input.readOnly) |
| 647 | input.value = password; |
nothing calls this directly
no outgoing calls
no test coverage detected