Scripting

Clear Injected Scripts

Remove all scripts previously registered with Inject Script.

Remove all scripts previously registered with Inject Script.

Removes every script that was registered via Inject Script (using CDP Page.removeScriptToEvaluateOnNewDocument), so they no longer run on subsequent document loads. Scripts injected internally by GPAL (e.g. stealth overrides) are not affected.

TIP

Does not affect the currently-loaded page - it only stops the script(s) from running on future navigations/reloads.

Examples

GPAL Fluent: High-level fluent C# API

browser.ClearInjectedScripts();

MagicHelper: MagicHelper utility library

//On the OttoMagic side, ClearInjectedScripts calls BROWSER.userScripts.unregister() with the list of script ids the extension recorded in Globals.injectedScriptIds when InjectScript was called, then clears that list. Subject to the same Chrome/Edge 'Allow User Scripts' manual setup described on Inject Script.

GPAL.MagicHelper.ClearInjectedScripts();

Puppeteer Client: Puppeteer-style C# client

browser.PuppeteerClient.ClearInjectedScripts().Execute();

Puppeteer Communicator: Low-level communicator

//Iterates the script identifiers recorded by InjectScriptTracked and issues Page.removeScriptToEvaluateOnNewDocument for each, then clears the tracked list.

await browser.PuppeteerCommunicator.ClearInjectedScripts(sessionId);

REST Client: Direct REST/HTTP client

GPAL.OttoMagicClient.ClearInjectedScripts().Execute();