< Day Day Up > |
Amazon lets you see larger product images in a separate window. Display them inline instead. Amazon product pages contain a wealth of information, including a medium-sized image of the product. Clicking on the product image opens a new window to display a larger version. This is fine for most screens, but if you're lucky enough to be using a modern laptop or a high-resolution monitor, you have plenty of real estate on your screen to display the larger product image inline on the product page itself. 3.6.1. The CodeThis user script will run on all Amazon pages. The code itself is divided into three parts:
Save the following user script as amazonlarger.user.js: // ==UserScript== // @name Amazon Larger Images // @namespace http://diveintomark.org/projects/greasemonkey/ // @description display larger product images on Amazon // @include http://amazon.tld/* // @include http://*.amazon.tld/* // ==/UserScript== var elmProductImage = document.evaluate( "//img[contains(@src, 'MZZZZZZZ')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; if (!elmProductImage) return; var elmParent = elmProductImage.parentNode; while (elmParent && (elmParent.nodeName != 'BODY')) { elmParent.style.width = 'auto'; elmParent.style.height = 'auto'; elmParent = elmParent.parentNode; } var elmNewImage = document.createElement('img'); elmNewImage.src = elmProductImage.src.replace(/MZZZZZZZ/, 'LZZZZZZZ'); elmNewImage.style.border = '0'; elmProductImage.parentNode.replaceChild(elmNewImage, elmProductImage); 3.6.2. Running the HackAfter installing the user script (Tools Install This User Script), go to http://www.amazon.com and search for anything for example, Dave Matthews Band Stand Up. When you click through to the product page, you will see the larger version of the album cover, as shown in Figure 3-10. 3.6.3. Hacking the HackIf you don't want to see the product images at all, you can simplify the script immensely: var elmProductImage = document.evaluate( "//img[contains(@src, 'MZZZZZZZ')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; if (!elmProductImage) return; elmProductImage.parentNode.removeChild(elmProductImage); Figure 3-10. Amazon.com page with larger product image |
< Day Day Up > |