---
title: Chrome Dev Tools AI Generated Code for Page Querying and Brainstorming
description: Chrome 147 added AI code generation directly in the developer console, and it's more useful than it sounds. This article walks through practical examples of using it for DOM querying, data scraping, and quick rebranding proofs of concept without writing a line of code manually.
image: https://8west.ie/hubfs/8-west-russ-painter-article-chrome-dev-tools-ai-generated-code.png
---

[![Navigate to: 8 West Consulting website Homepage](https://8west.ie/hubfs/SEO_optimized_media/8_west_logo.webp)](https://8west.ie/) [![8 West Consulting: leftward chevron icon](https://8west.ie/hubfs/SEO_optimized_media/8-West-Consulting-leftward-chevron-icon.png) Back to main insights page](https://8west.ie/insights)

## ARTICLE

# Chrome Dev Tools AI Generated Code for Page Querying and Brainstorming

AI & innovation

 Chrome 147 added AI code generation directly in the developer console, and it's more useful than it sounds. This article walks through practical examples of using it for DOM querying, data scraping, and quick rebranding proofs of concept without writing a line of code manually.

![Chrome Dev Tools AI Generated Code for Page Querying and Brainstorming](https://8west.ie/hubfs/8-west-russ-painter-article-chrome-dev-tools-ai-generated-code.png)

![Avatar picture of the author: Russ Painter](https://8west.ie/hubfs/8-West-Consulting-Member-Russ-Painter.png)

### Russ Painter

#### Software Architect, 8 West Consulting

SHARE ON

[![Click to share this article on Linkedin](https://8west.ie/hubfs/SEO_optimized_media/8-west-Consulting-icon-logo-linkedin.png)](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2F8west.ie%2Finsights%2Fchrome-dev-tools-ai-generated-code-for-page-querying-and-brainstorming)

 April 21, 2026

Chrome version 147 [added the ability](https://developer.chrome.com/blog/new-in-devtools-147/?utm_source=devtools&utm_campaign=stable#code-generation&trk=article-ssr-frontend-pulse_little-text-block) to generate code within the console window. This isn't about generating code to be part of your solution, although you could copy and paste parts of this into your solution. But instead, this is mainly about debugging a running website with quick throw-away code snippets.

 

## Turn it on

 

To use this feature, you have to enable it in the Developer Tools Settings. While you're there, you might as well turn on the other AI switches:

 

![](https://8west.ie/hs-fs/hubfs/undefined-Jun-08-2026-10-08-35-2592-AM.png?width=782&height=837&name=undefined-Jun-08-2026-10-08-35-2592-AM.png)

## What's it good for?

 

Rather than slogging through the DOM, we can generate code to do this for us. If you're a JavaScript coder, this is something you always could have done manually, but would be hard to justify the time and effort for something that's just going to be thrown away. And if you're not a JavaScript coder, this sort of thing would be out of reach previously.

 

### Example 1: Finding external images

 

In the console I type this

 

| // List the urls for all 3rd party images on this page |
| --- |

 

I then press CTRL=I to generate the code, then TAB to accept the code, then ENTER to run the code. The code it generated was

 

| (() =\> {   const currentHost = window.location.hostname;   // Use the DevTools $$ utility to select all image elements   const images = $$('img');   const thirdPartyUrls = images     .map(img =\> img.src)     .filter(src =\> {       try {         // img.src returns the absolute URL         const url = new URL(src);                  // Filter for images where the hostname does not match the current page         // Also exclude data URIs and empty sources         return url.hostname &&                 url.hostname !== currentHost &&                 !src.startsWith('data:');       } catch (error) {         // Ignore invalid URLs         return false;       }     });   // Remove duplicates and sort   const uniqueUrls = \[...new Set(thirdPartyUrls)\].sort();   if (uniqueUrls.length \> 0) {     console.log(\`Found ${uniqueUrls.length} third-party image URLs:\`);     console.table(uniqueUrls);   } else {     console.log("No third-party images found on this page.");   } })(); |
| --- |

 

 

And the output:

![](https://8west.ie/hs-fs/hubfs/undefined-Jun-08-2026-10-08-34-9686-AM.png?width=596&height=297&name=undefined-Jun-08-2026-10-08-34-9686-AM.png)

 

Since this is running againts the DOM, I'll see images brought in by 3rd party script or advertisements - things that don't necessarily exist in the source code for the page.

 

 

### Example 2: Scraping FAQ data

 

Prompt:

 

| // Find all of the data-pf-type="Accordion.Header" buttons and the content divs that follow them. Gather these into an array of question and answer values. |
| --- |

 

Auto-Generated Code:

 

| (() =\> {   // Use the Console Utilities API ($$) to select all matching headers   const headers = $$('\[data-pf-type="Accordion.Header"\]');   const accordionData = headers.map(header =\> {     // The content is typically the immediate next sibling element     const contentPanel = header.nextElementSibling;     return {       question: header.innerText?.trim() \|\| 'No text found',       answer: contentPanel ? contentPanel.innerText?.trim() : 'No content panel found'     };   });   // Output the gathered data as a table for easy inspection in the console   console.table(accordionData);   // Return the array for further manipulation if needed   return accordionData; })(); |
| --- |

 

Result:

![](https://8west.ie/hs-fs/hubfs/undefined-Jun-08-2026-10-08-34-7278-AM.png?width=589&height=174&name=undefined-Jun-08-2026-10-08-34-7278-AM.png)

 

For that one I needed a little bit of knowledge about the selector to use to find those elements. When you're generating the code in the console, it doesn't necessarily have an understanding of the page's contents at that point.

 

 

### Example 1: Rebranding Proof of Concept

 

Prompt:

 

| // Find all instances of the text "Raspberry" on this page and replace them with "Blueberry" |
| --- |

 

Generated Code:

 

| (() =\> {   try {     /\*\*      \* Replaces all instances of "Raspberry" with "Blueberry"       \* without disrupting the DOM structure or event listeners.      \*/     const findText = /Raspberry/g;     const replaceText = "Blueberry";     // Use TreeWalker to target only text nodes     const walker = document.createTreeWalker(       document.body,       NodeFilter.SHOW\_TEXT,       null,       false     );     let node;     while (node = walker.nextNode()) {       // Check if the text node contains the target string       if (node.nodeValue.includes("Raspberry")) {         node.nodeValue = node.nodeValue.replace(findText, replaceText);       }     }          console.log('Text replacement complete.');   } catch (error) {     console.error('An error occurred during the text replacement process:', error);   } })(); |
| --- |

 

 

Result:

![](https://8west.ie/hs-fs/hubfs/undefined-Jun-08-2026-10-08-35-6159-AM.png?width=744&height=268&name=undefined-Jun-08-2026-10-08-35-6159-AM.png)

 

This is a great tool to keep in your kit. I'm sure I'll be using it a lot.

 

 

#aibetter

 Enjoyed this article? Follow Russ Painter for more insights and commentary on: 

[![Social Icon: Linkedin](https://8west.ie/hubfs/SEO_optimized_media/8-west-Consulting-icon-logo-linkedin.png) LINKEDIN](https://ie.linkedin.com/in/geekymonkey)

[AI Enablement for Enterprise Development Teams](https://8west.ie/hubfs/SEO_optimized_media/Impact_Engagements_PDFs/8%20West%20Consulting%20-%20AI%20Enablement%20for%20Enterprise%20Development%20Teams.pdf) [BOOK A SCOPING CALL](https://8west.ie/about-us/contact-us)

[![8 West Consulting: chevron icon](https://8west.ie/hubfs/SEO_optimized_media/8-West-Consulting-leftward-chevron-icon.png) ALL POSTS](https://8west.ie/insights) [NEXT ARTICLE ![8 West Consulting: chevron icon](https://8west.ie/hubfs/SEO_optimized_media/8-West-Consulting-leftward-chevron-icon.png)](https://8west.ie/insights/caveman-ai-skill-for-terse-replies)

## RELATED CONTENT

![I have not typed code for months. Here is how it feels.](https://8west.ie/hubfs/8%20West%20Consulting%20-%20Article%20-%20Janos%20Farkas%20-%20I%20have%20not%20typed%20code%20for%20months.%20Here%20is%20how%20it%20feels.png)

#### ARTICLE

[I have not typed code for months. Here is how it feels.](https://8west.ie/insights/i-have-not-typed-code-for-months.-here-is-how-it-feels)

![Why Agentforce Stalls Inside Health & Dental Payers (and the Foundation That Fixes It)](https://8west.ie/hubfs/8%20West%20consulting%20-%20Article%20-%20Why%20Agentforce%20Stalls.png)

#### ARTICLE

[Why Agentforce Stalls Inside Health & Dental Payers (and the Foundation That Fixes It)](https://8west.ie/insights/why-agentforce-stalls-inside-health-dental-payers-and-the-foundation-that-fixes-it)

8 West Consulting © 2026

[Privacy Policy](https://8west.ie/privacy) [Sitemap](https://8west.ie/sitemap)

[![Navigate to: 8 West Consulting Facebook page](https://8west.ie/hubfs/SEO_optimized_media/8-west-Consulting-icon-logo-facebook.png)](https://www.facebook.com/8westconsulting/) [![Navigate to: 8 West Consultng Youtube Channel](https://8west.ie/hubfs/SEO_optimized_media/8-west-Consulting-icon-logo-youtube-white.png)](https://www.youtube.com/@8westconsulting) [![Navigate to: 8 West Consulting Instagram business profile](https://8west.ie/hubfs/SEO_optimized_media/8-west-Consulting-icon-logo-instagram.png)](https://www.instagram.com/8westconsulting/) [![Navigate to: 8 West Consulting LinkedIn business profile](https://8west.ie/hubfs/SEO_optimized_media/8-west-Consulting-icon-logo-linkedin.png)](https://www.linkedin.com/company/8-west-consulting)

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Russ Painter",
    "url" : "https://8west.ie/insights/author/russ-painter"
  },
  "dateModified" : "2026-06-12T13:51:38.111Z",
  "datePublished" : "2026-04-21T11:00:00.000Z",
  "headline" : "Chrome Dev Tools AI Generated Code for Page Querying and Brainstorming",
  "image" : [ "https://8west.ie/hubfs/8-west-russ-painter-article-chrome-dev-tools-ai-generated-code.png" ],
  "mainEntityOfPage" : {
    "@id" : "https://8west.ie/insights/chrome-dev-tools-ai-generated-code-for-page-querying-and-brainstorming",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://8west.ie/hubfs/Imported%20images/logos/8West.png"
    },
    "name" : "8 West Consulting"
  }
}
```

```json
{
  "@context" : "https://schema.org",
  "@id" : "https://8west.ie/#organization",
  "@type" : "Organization",
  "areaServed" : [ "Europe", "United States", "Global" ],
  "contactPoint" : [ {
    "@type" : "ContactPoint",
    "availableLanguage" : [ "English" ],
    "contactType" : "sales",
    "email" : "info@8west.ie"
  }, {
    "@type" : "ContactPoint",
    "areaServed" : "IE",
    "contactType" : "sales",
    "telephone" : "+353 21 4925100"
  }, {
    "@type" : "ContactPoint",
    "areaServed" : "IE",
    "contactType" : "support",
    "telephone" : "+353 21 4925155"
  } ],
  "description" : "8 West Consulting is an ISO 27001-certified software partner delivering enterprise systems for complex, regulated Health InsurTech and ecommerce environments.",
  "knowsAbout" : [ "Software development", "Cloud engineering", "Data engineering", "Artificial intelligence", "Dev Ops", "Cybersecurity", "Ecommerce", "Health insurance technology (Health Insurtech)", "Digital marketing" ],
  "logo" : {
    "@type" : "ImageObject",
    "url" : "https://145696986.fs1.hubspotusercontent-eu1.net/hubfs/145696986/SEO_optimized_media/8-West-Consulting-Logo-250x250.png"
  },
  "name" : "8 West Consulting",
  "sameAs" : [ "https://www.facebook.com/8westconsulting", "https://www.youtube.com/@8westconsulting", "https://ie.linkedin.com/company/8-west-consulting", "https://www.instagram.com/8westconsulting/" ],
  "url" : "https://8west.ie/"
}
```

```json
{
  "@context" : "https://schema.org",
  "@id" : "https://8west.ie/#website",
  "@type" : "WebSite",
  "name" : "8 West Consulting",
  "potentialAction" : {
    "@type" : "SearchAction",
    "query-input" : "required name=search_term_string",
    "target" : "https://8west.ie//search?q={search_term_string}"
  },
  "publisher" : {
    "@id" : "https://8west.ie/#organization"
  },
  "url" : "https://8west.ie/"
}
```

```json
{
  "@context" : "https://schema.org",
  "@id" : "https://8west.ie/insights#1002",
  "@type" : "WebPage",
  "about" : {
    "@id" : "https://8west.ie/#organization"
  },
  "description" : "This page collects the original articles, webinars, and white papers produced and published by the members of 8 West Consulting.",
  "isPartOf" : {
    "@id" : "https://8west.ie/#website"
  },
  "name" : "Insights | 8 West Consulting",
  "url" : "https://8west.ie/insights"
}
```

```json
{
  "@context" : "https://schema.org",
  "@type" : "BreadcrumbList",
  "itemListElement" : [ {
    "@type" : "ListItem",
    "item" : "https://8west.ie/",
    "name" : "Home",
    "position" : 1
  }, {
    "@type" : "ListItem",
    "item" : "https://8west.ie/insights",
    "name" : "Insights",
    "position" : 2
  } ]
}
```