Amazon Links

Adds eBay markup price, direct link to Amazon product page, eBay search by title, ThePriceGeek search by first 10 words of title, Amabay search by title. However over price to see minimum eBay price to profit $2 by dropshipping with Prime.

  1. // ==UserScript==
  2. // @name Amazon Links
  3. // @description:en Adds eBay markup price, direct link to Amazon product page, eBay search by title, ThePriceGeek search by first 10 words of title, Amabay search by title. However over price to see minimum eBay price to profit $2 by dropshipping with Prime.
  4. // @include *//*amazon.*/*
  5. // @run-at document-end
  6. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.js
  7. // @version 1.0
  8. // @namespace https://greasyfork.org/users/115271
  9. // @description Adds eBay markup price, direct link to Amazon product page, eBay search by title, ThePriceGeek search by first 10 words of title, Amabay search by title. However over price to see minimum eBay price to profit $2 by dropshipping with Prime.
  10. // ==/UserScript==
  11.  
  12. /**
  13. * This script adds a few links to each Amazon product page:
  14. * 1. A direct (clean) link to the product page which can be used e.g. to share (copy & paste)
  15. * a product page without session information etc.:
  16. * http://amazon.[TLD]/dp/[ASIN]
  17. * 2. A link to the current product on eBay
  18. * http://www.ebay.com/sch/i.html?_sacat=0&_nkw=[title]&LH_BIN=1&LH_FS=1&_sop=15
  19. * 3. A link to the current product on ThePriceGeek
  20. * http://www.thepricegeek.com/results/[first ten words of title]?country=us
  21. * 4. A link to the current product on Amabay
  22. * http://amabay.linked8.com/?p=search&c=ALL&q=[title]&sourceid=srch_rslt_logo&region=us
  23. **/
  24. (function() {
  25. /**
  26. * Decimal adjustment of a number.
  27. *
  28. * @param {String} type The type of adjustment.
  29. * @param {Number} value The number.
  30. * @param {Integer} exp The exponent (the 10 logarithm of the adjustment base).
  31. * @returns {Number} The adjusted value.
  32. */
  33. function decimalAdjust(type, value, exp) {
  34. // If the exp is undefined or zero...
  35. if (typeof exp === 'undefined' || +exp === 0) {
  36. return Math[type](value);
  37. }
  38. value = +value;
  39. exp = +exp;
  40. // If the value is not a number or the exp is not an integer...
  41. if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0)) {
  42. return NaN;
  43. }
  44. // Shift
  45. value = value.toString().split('e');
  46. value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp)));
  47. // Shift back
  48. value = value.toString().split('e');
  49. return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp));
  50. }
  51.  
  52. // Decimal round
  53. if (!Math.round10) {
  54. Math.round10 = function(value, exp) {
  55. return decimalAdjust('round', value, exp);
  56. };
  57. }
  58. // Decimal floor
  59. if (!Math.floor10) {
  60. Math.floor10 = function(value, exp) {
  61. return decimalAdjust('floor', value, exp);
  62. };
  63. }
  64. // Decimal ceil
  65. if (!Math.ceil10) {
  66. Math.ceil10 = function(value, exp) {
  67. return decimalAdjust('ceil', value, exp);
  68. };
  69. }
  70. })();
  71. (function () {
  72. // config
  73. var SHOW_LINK_ICON = 1; // toggle link fav icons
  74. var LINK_STYLE = "font-weight: bold; font-style: italic;";
  75.  
  76. // not all pages have fav icons so the following currently makes no sense
  77. var SHOW_LINK_TEXT = 1; // toggle link text
  78.  
  79. if (! $('input#ASIN:first').length) {
  80. return; // this doesn't seem to be a product page
  81. }
  82.  
  83. // get the ASIN (product id)
  84. var asin = $('input#ASIN:first').val();
  85.  
  86. // get the product title
  87. var title = document.getElementById("productTitle").innerHTML.replace(/"/g, '').trim();
  88. // get the price
  89. try {
  90. var price = document.getElementById("priceblock_ourprice").innerHTML.trim().substr(1)
  91. }
  92. catch(err){
  93. var price = document.getElementById("priceblock_saleprice").innerHTML.trim().substr(1)
  94. }
  95. // define the eBay sale price
  96. var markup = Math.round10(price * 1.09 * 1.0319 + 3.70, -2)
  97. try {
  98. document.getElementById("priceblock_ourprice").innerHTML = "<abbr title=" + markup + ">$" + price + "</abbr>";
  99. }
  100. catch(err) {
  101. document.getElementById("priceblock_saleprice").innerHTML = "<abbr title=" + markup + ">$" + price + "</abbr>";
  102. }
  103. // alert("Must sell above $" + markup);
  104. // get top level domain (the simple way)
  105. var tld = document.domain.split('.').pop();
  106. if ([ 'au', 'br', 'mx' ].indexOf(tld) > -1) { // add .com to some domains
  107. tld = 'com.'+tld;
  108. } else if ([ 'uk', 'jp' ].indexOf(tld) > -1) { // add .co to others
  109. tld = 'co.'+tld;
  110. }
  111.  
  112. // create all new links
  113. // direct link
  114. var link1url = '';
  115. var link1 = '';
  116. if (tld != undefined) { // add only if TLD was identified
  117. var tooltip = (tld == 'de' ? 'Direkter und sauberer Produktlink.' : 'Direct and clean product link.');
  118. link1url = 'http://amazon.' + tld + '/dp/' + asin;
  119. link1 = (SHOW_LINK_ICON ? '<img src="http://www.amazon.'+tld+'/favicon.ico" border="0" align="absmiddle" width="16" height="16" />&nbsp;' : '')
  120. + '<a target="_blank" href="http://amazon.' + tld + '/dp/' + asin + '" style="color: #e47911;' + LINK_STYLE + '" title="' + tooltip + '">'
  121. + (SHOW_LINK_TEXT ? (tld == 'de' ? 'Direkter Link' : 'Direct link') : '')
  122. + '</a> / ';
  123. }
  124. // eBay.com
  125. var link2url = 'http://www.ebay.com/sch/i.html?_sacat=0&_nkw=' + title + '&LH_BIN=1' + '&LH_FS=1' + '&_sop=15' + '&_udlo=' + price;
  126. var link2 = (SHOW_LINK_ICON ? '<img src="http://i.imgur.com/1TYirv3.png" border="0" align="absmiddle" width="16" height="16" />&nbsp;' : '')
  127. + '<a target="_blank" href="' + link2url + '" style="color: #039;' + LINK_STYLE + '">'
  128. + (SHOW_LINK_TEXT ? 'eBay' : '') + '</a> / ';
  129. // ThePriceGeek.com
  130. var link3url = 'http://www.thepricegeek.com/results/' + title.replace(/(([^\s]+\s\s*){10})(.*)/,"$1") + '?country=us';
  131. //var link3 = (SHOW_LINK_ICON ? '<img src="http://www.snip-me.de/favicon.ico" border="0" align="absmiddle" width="16" height="16" />&nbsp;' : '')
  132. var link3 = '<a target="_blank" href="' + link3url + '" style="color: #106bcc;' + LINK_STYLE + '">'
  133. + (SHOW_LINK_TEXT ? 'ThePriceGeek' : '') + '</a> / ';
  134. // Amabay
  135. var link4url = 'http://amabay.linked8.com/?p=search&c=ALL&q=' + title + '&sourceid=srch_rslt_logo&region=us';
  136. var link4 = (SHOW_LINK_ICON ? '<img src="http://theimagehost.net/upload/0b12529fc536c7c8a832957c19becfc5.png" border="0" align="absmiddle" width="16" height="16" />&nbsp;' : '')
  137. + '<a target="_blank" href="' + link4url + '" style="color: #900;' + LINK_STYLE + '">'
  138. + (SHOW_LINK_TEXT ? 'Amabay' : '') + '</a>';
  139. // add the links as new table row below the price information
  140. $('table.product > tbody:last > tr:last, table.a-lineitem > tbody:last > tr:last').after('<tr><td></td><td>'+link1+link2+link3+link4+'</td></tr>');
  141.  
  142. })();