Illustrate Any Web Site

The yReplacer Yahoo! game replaces words on any web page with an image.

Some books are better with pictures, and some web pages would be better with illustrations. You can’t edit every text-heavy page on the Web yourself, but you can have some fun swapping words with images thanks to a clever script called yReplacer.

With yReplacer, you can highlight any word on a web site and click a bookmarklet to swap that word with a matching image from Yahoo! Image Search. So the word Martians on a page could become a picture of the cartoon character Marvin the Martian, or the word planet could become a picture of Saturn.

A Flash memory game using the query “fire”

Figure 5-20. A Flash memory game using the query “fire”

This hack is composed of two parts: a server-side script that retrieves the search image from Yahoo! and displays it, and a bookmarklet that initiates the swap. You can install the bookmarklet from yReplacer’s permanent home on the Web at http://www.kokogiak.com/yreplacer.html, or you can build this hack yourself with the following code.

The Code

The first part of this hack is server-side retrieval of a random image, written here in VBScript for classic ASP. This script accepts an incoming word with the querystring variable q, sends a request to the Yahoo! Image API, and selects a random result from the response. The script then uses the random image to write some HTML to display the image, which will ...

Get Yahoo! Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.