View Single Post
Old 01-19-2016, 11:05 AM   #33
gbm
Wizard
gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.
 
Posts: 2,195
Karma: 8888888
Join Date: Jun 2010
Device: Kobo Clara HD,Hisence Sero 7 Pro RIP, Nook STR, jetbook lite
Amazon has made a one word change in their web site use this new script:

Spoiler:
Code:
// ==UserScript==
// @name        MobileRead Kindle Price Check (amazon.com)
// @namespace   kakapo.public
// @description Checks price of Kindle ebook links in MobileRead forum posts. Translates amazon.com links into your local site, please install the correct version.
// @include     https://www.mobileread.com/forums/showthread.php*
// @version     3
// @grant       GM_xmlhttpRequest
// ==/UserScript==
var site_regex = /^(http|https):\/\/(www\.)?amazon\.(com)(\/.*)/;
var migrate_regex = false;
var migrate_replacement = '';
var currency_prefix = '$';
var ebook_url_regexs = [
  /^\/dp\//,
  /^\/[^\/]+\/dp\//,
  /^\/gp\/product\//,
  /^\/exec\/obidos\/ASIN\//
];
var check_price = function (elements, url) {
  var xhr = GM_xmlhttpRequest({
    method: 'GET',
    url: url,
    onload: function (response) {
      var data = response.responseText;
      var pos0 = data.indexOf('class="a-color-price a-size-medium a-align-bottom"');
      var pos1 = data.indexOf('>', pos0);
      var pos2 = data.indexOf('<', pos1);
      var price = data.substring(pos1 + 1, pos2).trim();
      if (price == '') {
        price = 'N/A';
      }
      var color = price == 'Free' || price == currency_prefix + '0.00' || price == currency_prefix + '0,00' || price == currency_prefix + '0' ? 'red' : 'blue';
      pos0 = data.indexOf('id="ebooksInstantOrderUpdate" class="a-size-medium"');
      if (pos0 >= 0) {
        price += ' already own';
      }
      for (var i = 0; i < elements.length; i++) {
        elements[i].insertAdjacentHTML('afterend', ' <span style="color:' + color + '">(' + price + ')</span>');
      }
    }
  });
}
var a = document.getElementsByTagName('a');
var to_check = {
};
for (var i = 0; i < a.length; i++) {
  var url = a[i].href;
  var parts = site_regex.exec(url);
  if (parts) {
    if (migrate_regex) {
      url = url.replace(migrate_regex, migrate_replacement);
      a[i].href = url;
    }
    for (var j = 0; j < ebook_url_regexs.length; j++) {
      if (ebook_url_regexs[j].test(parts[parts.length - 1])) {
        if (!to_check[url]) {
          to_check[url] = [
          ];
        }
        to_check[url].push(a[i]);
      }
    }
  }
}
for (var k in to_check) {
  check_price(to_check[k], k);
}


Install using your browser.


bernie
gbm is offline   Reply With Quote