Skip to content

Instantly share code, notes, and snippets.

@me-suzy
Created July 22, 2026 09:08
Show Gist options
  • Select an option

  • Save me-suzy/1f031727dfcd1118a92cec7babd3e933 to your computer and use it in GitHub Desktop.

Select an option

Save me-suzy/1f031727dfcd1118a92cec7babd3e933 to your computer and use it in GitHub Desktop.
02-codex-browser-cse-check.js
// Run this snippet in the Codex in-app Browser Node REPL after the local server is running.
// It verifies that Google CSE replaces <gcse:searchresults-only> with rendered results.
const { setupBrowserRuntime } = await import(
"C:/Users/necul/.codex/plugins/cache/openai-bundled/browser/26.609.41114/scripts/browser-client.mjs"
);
await setupBrowserRuntime({ globals: globalThis });
globalThis.browser = await agent.browsers.get("iab");
var tab = await browser.tabs.new();
await tab.goto("http://localhost:8765/search.html?q=2025");
// The page has many external resources, so a short wait plus DOM check is more reliable
// than waiting for the full load event.
await tab.playwright.waitForTimeout(8000);
var state = await tab.playwright.evaluate(() => {
const scripts = Array.from(document.scripts)
.map((script) => script.src)
.filter(Boolean);
const cseText = (
document.querySelector(".gsc-control-cse")?.textContent ||
document.querySelector(".gsc-results")?.textContent ||
""
).trim();
return {
url: location.href,
readyState: document.readyState,
title: document.title,
googleCseScriptPresent: scripts.some((src) =>
src.includes("www.google.com/cse/cse.js") ||
src.includes("cse.google.com/cse.js")
),
googleCseScripts: scripts
.filter((src) => src.includes("google.com/cse"))
.slice(0, 5),
rawGcseTagCount: document.querySelectorAll("gcse\\:searchresults-only")
.length,
cseControlCount: document.querySelectorAll(".gsc-control-cse").length,
resultCount: document.querySelectorAll(".gsc-result, .gsc-webResult")
.length,
textSample: cseText.slice(0, 700),
};
});
nodeRepl.write(JSON.stringify(state, null, 2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment