Dickbookmarklet

So recently I was tasked with building an easter egg for a website called wholesomezine(I still have no clue if it is one word or two). I wanted to have a Konami code that did something amazing yet simple. So I wrote some code that replaces all images with an arbitrary image.

The code for the image replacement is super simple. Now normally I would use a library like jquery for advanced dom manipulation, but this time I opted for pure javascript. Here's the code.

The first thing I do is create a function called changeImage. We can use the method document.querySelectorAll('img'); to select all img tags and store them to an array called image. This means any time you want to manipulate an img node, just refer to it as image[i] where i represents an integer starting at 0.

We can do a lot of things with this piece of code. We could easily make an easter egg that changes all the images to an arbitrary url. All you would have to do is call a konami code library and specify changeImage() as the callback function like so.

Or you could create a bookmarklet. A bookmarklet is a piece of javascript that gets run from a bookmark. To do this in most browsers a bookmark needs to start with javascript:. I like this template for making bookmarklets javascript:{arbitrary script};void(0); Now while you could use some arbitrary url encoding lib to take care of the url encoding, I ended up pasting my script minus the konami code bit and used this simple bookmarklet generator. I've taken the liberty of creating a readily useable bookmarklet for you. Just drag this link to your bookmarks bar to use it anywhere, or click the link and watch the images on the page change. dickbutt!