feat(clickTtHttpPageRoutes): add inline confirm handling to proxy navigation script
- Introduced a new function to manage inline confirm dialogs, allowing user confirmation before proceeding with actions triggered by inline event handlers. - Enhanced the proxy navigation script to prevent default actions if the inline confirm is not accepted, improving control over user interactions. - Updated logging to capture confirmation dialog details for better traceability during proxy interactions.
This commit is contained in:
@@ -316,6 +316,15 @@ function injectProxyNavigationScript(html, proxyBaseUrl, pageBaseUrl, sid) {
|
||||
'window.location.assign(buildProxyUrl(targetUrl));',
|
||||
'return true;',
|
||||
'}',
|
||||
'function shouldAllowInlineConfirm(element){',
|
||||
"var onclickValue=element&&element.getAttribute?element.getAttribute('onclick'):null;",
|
||||
'if(!onclickValue)return true;',
|
||||
"var match=onclickValue.match(/return\\s+confirm\\((['\"])([\\s\\S]*?)\\1\\)/i);",
|
||||
'if(!match)return true;',
|
||||
'var confirmed=window.confirm(match[2]);',
|
||||
"try{console.log('[ClickTT Proxy] inline confirm',{message:match[2],confirmed:confirmed});}catch(e){}",
|
||||
'return confirmed;',
|
||||
'}',
|
||||
'function getSubmitTarget(form, submitter){',
|
||||
"var action=submitter&&submitter.getAttribute?submitter.getAttribute('formaction'):null;",
|
||||
'if(action)return normalizeUrl(action,PAGE_BASE_URL);',
|
||||
@@ -330,6 +339,10 @@ function injectProxyNavigationScript(html, proxyBaseUrl, pageBaseUrl, sid) {
|
||||
"try{console.log('[ClickTT Proxy] submit control click',{name:submitControl.name||null,value:submitControl.value||null,type:submitControl.type||submitControl.tagName,formAction:submitControl.getAttribute?submitControl.getAttribute('formaction'):null,text:(submitControl.textContent||'').trim().slice(0,120)});}catch(e){}",
|
||||
'}',
|
||||
'if(!anchor||event.defaultPrevented)return;',
|
||||
'if(!shouldAllowInlineConfirm(anchor)){',
|
||||
'event.preventDefault();',
|
||||
'return;',
|
||||
'}',
|
||||
"var targetUrl=normalizeUrl(anchor.getAttribute('href'),PAGE_BASE_URL);",
|
||||
'if(!targetUrl||!shouldProxyUrl(targetUrl))return;',
|
||||
"try{console.log('[ClickTT Proxy] anchor click',{href:anchor.getAttribute('href'),targetUrl:targetUrl,text:(anchor.textContent||'').trim().slice(0,120)});}catch(e){}",
|
||||
|
||||
Reference in New Issue
Block a user