Skip to content

Commit

Permalink
Adjust JavaScript slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
DelphiWorlds committed Oct 5, 2024
1 parent 6a34440 commit 58569be
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions Features/JavaScript/DW.JavaScript.pas
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,22 @@ interface
cJSEventScheme = 'jsevent';
cJSEventProtocol = cJSEventScheme + ':blank?';

cJavaScriptClickAtXY = '(function() { '#13#10 +
'var windowX = %d, windowY = %d'#13#10 +
'let x = windowX - (window.scrollX || window.pageXOffset)'#13#10 +
'let y = windowY - (window.scrollY || window.pageYOffset);'#13#10 +
cJavaScriptClickAtXY = '(function() {'#13#10 +
'var windowX = %d, windowY = %d;'#13#10 +
'var x = windowX - (window.scrollX || window.pageXOffset)'#13#10 +
'var y = windowY - (window.scrollY || window.pageYOffset);'#13#10 +
'var element = document.elementFromPoint(x, y);'#13#10 +
'if (element) {'#13#10 +
' var clickEvent = document.createEvent("MouseEvents");'#13#10 +
' clickEvent.initMouseEvent("click", true, true, window, 0, 0, 0, x, y, false, false, false, false, 0, null);'#13#10 +
'while (element) {'#13#10 +
' if (element.tagName !== "A" && !element.hasAttribute("onclick"))'#13#10 +
' element = element.parentElement;'#13#10 +
' else'#13#10 +
' break;'#13#10 +
'}'#13#10 +
'if (element) {'#13#10 +
' var clickEvent = new MouseEvent("click", { view: window, bubbles: true, cancelable: true, clientX: x, clientY: y });'#13#10 +
' element.dispatchEvent(clickEvent);'#13#10 +
'} else'#13#10 +
' console.log("No element found at coordinates:", x, y);'#13#10 +
' console.log("No clickable element found at coordinates:", x, y);'#13#10 +
'})()';
cJavaScriptGetInputValueByName = '(function() { return document.getElementsByName("%s")[0].value; })()';
cJavaScriptGetPageContents = '(function() { return document.getElementsByTagName("html")[0].innerHTML; })()';
Expand Down

0 comments on commit 58569be

Please sign in to comment.