// Buy.com LinkShare Affiliate // Version 1.0 // 2010-10-15 // Chieh Cheng // // Released under the GPL license // http://www.gnu.org/copyleft/gpl.html // // -------------------------------------------------------------------- // // This is a Greasemonkey user script. // // To install, you need Greasemonkey: http://greasemonkey.mozdev.org/ // Then restart Firefox and revisit this script. // Under Tools, there will be a new menu item to "Install User Script". // Accept the default configuration and install. // // To uninstall, go to Tools/Manage User Scripts, // select the name of this script, and click Uninstall. // // -------------------------------------------------------------------- // // ==UserScript== // @name Buy.com Commission Junction Affiliate // @namespace http://www.CynosureX.com/ // @description Build Buy.com Commission Junction Affiliate product links. // @include http://www.buy.com/retail/product.asp* // @include http://www.buy.com/prod/* // ==/UserScript== // title originator = document.evaluate ('/html/head/title', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); element = originator.snapshotItem (0); title = element.innerHTML; pattern = new RegExp (" - .*$", ""); title = title.replace (pattern, ""); // alert (title); // product ID url = location.href; pattern = new RegExp (".*sku=", ""); id = url.replace (pattern, ""); pattern = new RegExp (".*/", ""); id = id.replace (pattern, ""); pattern = new RegExp ("\.html$", ""); id = id.replace (pattern, ""); // alert (id); // insert HTML originator = document.evaluate ('/html/body', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); element = originator.snapshotItem (0); element.innerHTML = "
<a href=\"http://affiliate.buy.com/fs-bin/click?id=ejJf877gbHE&subid=&offerid=209883.1&type=10&tmpid=6932&RD_PARM1=http%3A%2F%2Fwww.buy.com%2Fretail%2Fproduct.asp%3Fsku%3D" + id + "\" target=\"link\">" + title + "</a>
" + element.innerHTML;