A page I'm browsing has a bunch of images like this: <a…
- User
A page I'm browsing has a bunch of images like this:
<a href="loading06.jpg">loading06.jpg</a>Please write me a Bookmarklet script that replaces all of those in the page with an image tag that displays them. Assistant
Here's a bookmarklet that will replace all the links to images (like the one in your example) with actual
<img>tags:javascript:(function(){ var links = document.getElementsByTagName('a'); for (var i = 0; i < links.length; i++) { var link = links[i]; var href = link.getAttribute('href'); if (href && (href.match(/\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i))) { var img = document.createElement('img'); img.src = href; img.alt = link.textContent || href; link.parentNode.replaceChild(img, link); } } })();How to use this bookmarklet:
- Create a new bookmark in your browser
- Edit the bookmark and paste the entire code above as the URL (make sure to include the
javascript:prefix) - When you're on a page with image links like the one you described, click the bookmarklet
What it does:
- Finds all
<a>tags on the page - Checks if the href attribute ends with common image file extensions
- Replaces the link with an
<img>tag that displays the image - Uses the link text as the alt text (or the filename if there's no link text)
Note:
This will only work for images that are accessible from your current domain (due to same-origin policy). If the images are on a different domain, they might not display unless the server has proper CORS headers.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.