@@ -121,6 +121,8 @@ async function voteForCompany(webContents, company, sendLog, skipClick = false,
121121 const waitClick = waitForNavigation ( webContents ) ;
122122 const clickResult = await webContents . executeJavaScript ( `
123123 (() => {
124+ window.alert = function() { return true; };
125+ window.confirm = function() { return true; };
124126 const row = document.querySelectorAll('tr')[${ company . rowIndex } ];
125127 if (!row) return false;
126128 const voteLink = Array.from(row.querySelectorAll('a.c-actLink')).find(a => a.innerText.includes('投票'));
@@ -149,6 +151,8 @@ async function voteForCompany(webContents, company, sendLog, skipClick = false,
149151
150152 const pageScript = `
151153 (async () => {
154+ window.alert = function() { return true; };
155+ window.confirm = function() { return true; };
152156 const sleep = (ms) => new Promise(r => setTimeout(r, ms));
153157 const submitBtn = Array.from(document.querySelectorAll('button')).find(el =>
154158 el.getAttribute('onclick')?.includes('voteObj.checkMeetingPartner()')
@@ -158,6 +162,18 @@ async function voteForCompany(webContents, company, sendLog, skipClick = false,
158162
159163 if (submitBtn) {
160164 submitBtn.click();
165+
166+ // Attempt to dismiss any DOM-based confirmation dialogs that appear after submission
167+ setTimeout(() => {
168+ const domConfirm = Array.from(document.querySelectorAll('button, a')).find(el =>
169+ (el.innerText.includes('確定') || el.innerText.includes('確認') || el.innerText.includes('OK')) &&
170+ el.closest(':not([style*="display: none"])')
171+ );
172+ if (domConfirm) {
173+ try { domConfirm.click(); } catch(e) {}
174+ }
175+ }, 500);
176+
161177 return { type: 'submit', success: true };
162178 }
163179
0 commit comments