Getting Started

Allowing User Scripts on OttoMagic

When You Need This

Two calls need this, and they are the two that run JavaScript you wrote. InjectScript registers a script that runs on every new document, ahead of anything the page loads. ExecuteJavaScript runs a script once, against the page that is open. On Selenium and Puppeteer both work with no setup at all. On OttoMagic both are carried by the browser extension through the Chrome userScripts API, and Chrome keeps that API switched off until you allow it for the extension by hand. Until you do, the extension has no userScripts object to call and both fail. Nothing else in OttoMagic depends on it, so a workflow that calls neither never needs any of this.

NOTE

Measured on nike.com across four engine and browser pairings, 2026-08-27. An injected script read window.fetch as native and 34 characters long on the blank document, then as 179 characters and not native once the page had loaded. Same browser, same run, seconds apart. The page wrapped fetch, and only a script that ran before the page could see the difference. A script evaluated after load reads 179 and has no way to tell whether the browser or the page put it there.

Allowing User Scripts

Open chrome://extensions, find the OttoMagic extension, open Details, and turn on Allow user scripts. The setting is stored per extension per profile, so it has to be done on the profile the workflow runs on. Then name that profile in the workflow.

IBrowser browser = GPAL.Browser

.WithBrowserType(BrowserType.Chrome)

.WithAutomationEngine(AutomationEngine.OttoMagic)

.WithProfileDataDirectory(@"C:UsersyouAppDataLocalGoogleChromeUser DataSDi")

.ToGPALObject();


// registered ahead of the page, and runs on every document from here on

browser

.InjectScript("window.__weWereHereFirst = true;")

.GoTo("https://example.com");


// runs once, on the page that is open, and hands back what it returned

browser.ExecuteJavaScriptStr("document.title");

string title = browser.JavaScriptResultStr;

NOTE

Allowing user scripts turns on InjectScript and ExecuteJavaScript together. There is no second setting for the second call. Edge carries the same extension and the same restriction, and its toggle is at edge://extensions, on the profile the workflow uses. Turning it on in Chrome does nothing for Edge.

Why a Named Profile

When no profile is named, GPAL builds a throwaway one for the run, and a throwaway profile has never had the toggle set. That makes InjectScript and ExecuteJavaScript named profile features on OttoMagic: point the workflow at a profile you have allowed, using WithProfileDataDirectory, WithProfileUserName or WithProfileName. Selenium and Puppeteer are unaffected and run both on a throwaway profile like any other.

WARNING

The extension also has an Allow in incognito toggle, sitting on the same Details page and set the same way. GPAL has no incognito mode yet, so nothing in a workflow reaches it. It is mentioned here only because the two toggles look alike and are easy to mistake for each other.

💬 Ask GPAL