dW

Sep 5th 2008

Amazon’s Universal Wish List & Opera

EDIT: This information could be outdated. Since Opera 11 this would be better suited as an extension, anyway.

A lot of times from relatives and friends I get asked repetively what they could get me, and my response is a link to my wish list on Amazon or simply a coupon or something for Amazon. I’m forever buying books or whatnot from Amazon, so frequently that it’s worth my while to be an Amazon Prime member. Not too long ago Amazon added a new feature they call Universal Wish Lists here people could put items from other websites to their existing wish lists by adding a bookmarklet to your bookmarks bar and pressing it when on a wanted product’s page. While this works in Opera, Opera has much better methods of user interface customizing than using bookmarklets.

In Opera it is possible to create an actual button that can reside anywhere in the interface. The possibilities are almost endless. You can even execute JavaScript (or external programs for that matter). What can be better than that? One-click button installs come to my mind, at least:

Add to Wish List

Clicking that button in Opera will prompt a dialog box asking for permission to install the button. After that Opera will allow you to drag that button anywhere you wish. Personally I don’t add too many custom buttons, especially for something I won’t use on a daily basis. Opera allows for menu customization as well. All of the main menus and each of the right-click toggled drop down menus are customizable. What I thought would be interesting when I first set out to figure out how to get this to work using Opera’s UI customization features was that it’d be nice to be able to right-click on a web page and click on a menu item that’d allow me to add it to my Amazon wish list. The button was a secondary thought, but considering the capabilities to one-click install the button it’s a lot cooler to showcase than code. Editing menus are quite a bit more difficult to do, but menu customization isn’t anything so difficult that it’d be beyond the scope of the average user. It’s just that it’s not entirely obvious as to how to do it which is unfortunate as it is an amazing feature of Opera’s.

Menu customization is stored in an ini file in the Menu folder in your profile folder. The location of the profile folder depends on how it’s installed and what platform you’re on. A quick way to find out is to type opera:config and either search for “Opera Directory” or go to User Prefs then to Opera Directory. It’ll show you the location of your profile. More than likely there won’t be a menu folder there, so the easiest way (without having to explain the differences between platforms) to remedy that is:

  1. In the main menu go to Tools → Preferences (or Opera → Preferences on Mac OS X).
  2. Click on the Advanced tab and in the dialog’s sidebar click on Toolbars.
  3. Under Menu setup click on Opera Standard and then click the duplicate button.

Doing so will create an exact copy of the default toolbar’s setting file in the Menu folder in your profile folder. Go there and open that file in your favorite text editor. Search for “[Document Popup Menu]” and paste the following under that heading somewhere.

Item, Add to Amazon Wishlist="Go to page, "javascript:(function(){var w=window,l=w.location,d=w.document,s=d.createElement('script'),e=encodeURIComponent,x='undefined',u='http://www.amazon.com/gp/wishlist/add';if(typeof s!='object')l.href=u+'?u='+e(l)+'&t='+e(d.title);function g(){if(d.readyState&&d.readyState!='complete'){setTimeout(g,200);}else{if(typeof AUWLBook==x)s.setAttribute('src',u+'.js?loc='+e(l)),d.body.appendChild(s);function f(){(typeof AUWLBook==x)?setTimeout(f,200):AUWLBook.showPopover();}f();}}g();}())""

Figuring out where the new item would reside when the toolbar is loaded should be obvious, so place this snippet of code where you’d personally like the menu item to be. Save it as a different file than the one you’re editing in that folder and restart Opera. Repeat the directions above to get to the Menu setup preferences and select the new menu setup file you just edited. Now when you right-click on a web page you should see a menu item allowing you to add that page to your wish list.