From de1382b57ec38f52f0e13294cbcdd6d7293c281e Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Wed, 11 Mar 2026 13:25:18 +0100 Subject: [PATCH] feat(clickTtHttpPageRoutes): add inline confirm elements summarization and logging - Introduced a new function to summarize inline confirm elements in HTML, capturing relevant attributes for better tracking of user interactions. - Enhanced the proxy navigation script to log details of inline confirm elements, improving traceability during proxy interactions. - Updated the existing functionality to ensure inline confirm elements are logged when present, contributing to better debugging and user experience. --- backend/routes/clickTtHttpPageRoutes.js | 46 +++++++++++++++++++++++++ frontend/src/views/MembersView.vue | 2 +- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/backend/routes/clickTtHttpPageRoutes.js b/backend/routes/clickTtHttpPageRoutes.js index 0da2e308..62dd0b3d 100644 --- a/backend/routes/clickTtHttpPageRoutes.js +++ b/backend/routes/clickTtHttpPageRoutes.js @@ -95,6 +95,29 @@ function summarizeFormBody(body) { } } +function summarizeInlineConfirmElements(html) { + if (!html || typeof html !== 'string') return []; + const matches = []; + const regex = /<(a|button|input|form)\b([^>]*?\bonclick\s*=\s*["'][^"']*confirm\([^"']*["'][^>]*?)>/gi; + let match; + while ((match = regex.exec(html)) !== null && matches.length < 10) { + const tag = match[1]; + const attrs = match[2] || ''; + const onclickMatch = attrs.match(/\bonclick\s*=\s*["']([^"']*confirm\([^"']*)["']/i); + const valueMatch = attrs.match(/\bvalue\s*=\s*["']([^"']*)["']/i); + const hrefMatch = attrs.match(/\bhref\s*=\s*["']([^"']*)["']/i); + const nameMatch = attrs.match(/\bname\s*=\s*["']([^"']*)["']/i); + matches.push({ + tag, + name: nameMatch?.[1] || null, + value: valueMatch?.[1] || null, + href: hrefMatch?.[1] || null, + onclick: onclickMatch?.[1] || null + }); + } + return matches; +} + /** Domains, deren Links durch den Proxy umgeleitet werden (für Folge-Logs) */ const PROXY_DOMAINS = ['click-tt.de', 'httv.de', 'liga.nu']; @@ -325,12 +348,28 @@ function injectProxyNavigationScript(html, proxyBaseUrl, pageBaseUrl, sid) { "try{console.log('[ClickTT Proxy] inline confirm',{message:match[2],confirmed:confirmed});}catch(e){}", 'return confirmed;', '}', + 'function logInlineConfirmElements(){', + 'try{', + "var elements=[].slice.call(document.querySelectorAll('[onclick*=\"confirm(\"]')).slice(0,10).map(function(el){", + 'return {', + 'tag:el.tagName,', + "name:el.getAttribute('name'),", + "value:el.getAttribute('value'),", + "href:el.getAttribute('href'),", + "onclick:el.getAttribute('onclick'),", + "text:(el.textContent||'').trim().slice(0,120)", + '};', + '});', + "console.log('[ClickTT Proxy] inline confirm elements',elements);", + '}catch(e){}', + '}', 'function getSubmitTarget(form, submitter){', "var action=submitter&&submitter.getAttribute?submitter.getAttribute('formaction'):null;", 'if(action)return normalizeUrl(action,PAGE_BASE_URL);', "return normalizeUrl((form&&form.getAttribute?form.getAttribute('action'):null)||PAGE_BASE_URL,PAGE_BASE_URL);", '}', 'var lastSubmitter=null;', + 'if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",logInlineConfirmElements,{once:true});}else{logInlineConfirmElements();}', "document.addEventListener('click',function(event){", "var anchor=event.target&&event.target.closest?event.target.closest('a[href]'):null;", "var submitControl=event.target&&event.target.closest?event.target.closest('button, input[type=\"submit\"], input[type=\"image\"]'):null;", @@ -651,6 +690,13 @@ router.post('/proxy', async (req, res, next) => { responseBody = rewriteFormActionsInHtml(responseBody, proxyBase, effectivePageUrl, sid); responseBody = rewriteMetaRefreshInHtml(responseBody, proxyBase, effectivePageUrl, sid); responseBody = normalizeInlineScriptStrings(responseBody); + const inlineConfirmSummary = summarizeInlineConfirmElements(responseBody); + if (inlineConfirmSummary.length > 0) { + console.log('[ClickTT Proxy HTML inline confirm]', JSON.stringify({ + effectivePageUrl, + inlineConfirmSummary + })); + } responseBody = injectProxyNavigationScript(responseBody, proxyBase, effectivePageUrl, sid); } diff --git a/frontend/src/views/MembersView.vue b/frontend/src/views/MembersView.vue index 0ee88a86..74749779 100644 --- a/frontend/src/views/MembersView.vue +++ b/frontend/src/views/MembersView.vue @@ -256,7 +256,7 @@ ⛔