subscribe by email and YouTube to get notification of new posts. & videos.

Human Emulation Scroll

To be a litle more difficult, cause, in emulating cursor (previous article) the target website (so youtube) does not know if any code was injected (as no one code was injected) cause the Bot app emulate the cursor, easy, but, in scrolling, some sources says to use , where N = bla bla

browser.ExecuteScriptAsync("window.scroll(0,N);");

but , say to IA «can js detect browser.ExecuteScriptAsync»

results in

JavaScript cannot directly detect the execution of a browser.ExecuteScriptAsync call because this method is part of the host application’s API (such as WebView2 or CefSharp) and operates outside the standard JavaScript environment. 

However, a script can indirectly detect its own injection or «presence» using the following methods:

1. Self-Identification via State

If the host application uses ExecuteScriptAsync to set a global variable, standard JavaScript can check for that variable’s existence. 

  • Detection logic: if (window.myInjectionFlag) { ... }

2. Monitoring DOM or Event Changes

Since ExecuteScriptAsync is often used to modify the DOM or trigger events, JavaScript can use a MutationObserver to watch for unexpected changes that did not originate from the page’s original scripts. 

3. Stack Trace Analysis

In some environments, if a script is executed via an external command, the Error().stack property might reveal a unique trace (e.g., <anonymous> or specific internal wrappers), though this is highly implementation-specific and unreliable for robust detection. 

4. Communication Back to Host

The most common way for JavaScript to «acknowledge» an external script execution is to use host-provided bridges like:

  • WebView2: window.chrome.webview.postMessage().
  • CefSharp: CefSharp.PostMessage() or bound objects. 

For more details on implementing these interfaces, see the official documentation for WebView2 APIs or the CefSharp WebBrowserExtensions

so, 2 things

May my app can use a non injected script, say to scrollgthe browser instance ? if not, then ooohh need to test

So I ask the following (while listen to Im looking at gthe windows Stieve vai):

can js detect is u use oin winformn a webview2 with Document.Window.ScrollTo(0, 0) ?

which results in:

In 2026, JavaScript running inside a WebView2 control can detect the fact that a scroll occurred, but it cannot inherently distinguish whether that scroll was caused by a WinForms Document.Window.ScrollTo(0, 0) command or a user’s manual action. 

How JS Detects the Scroll

  • The scroll Event: Whenever the scroll position changes—whether programmatically via C# or manually by a user—the JavaScript scroll event fires.
  • The scrollend Event: Modern browsers (including the Edge/Chromium engine used by WebView2) support scrollend, which fires when any scroll animation completes. 

SO, js , so youtube, cannot detect using this last method, if our app is a bot or not, so OK, camon men

So code, to record a human real scrolls, to put on database

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Comentarios

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *