Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book General > Deals and Resources (No Self-Promotion or Affiliate Links)

Notices

Reply
 
Thread Tools Search this Thread
Old 09-19-2015, 01:21 PM   #31
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,189
Karma: 8888888
Join Date: Jun 2010
Device: Kobo Clara HD,Hisence Sero 7 Pro RIP, Nook STR, jetbook lite
Spoiler:
Quote:
Originally Posted by gbm View Post
Try this change to the script.
Edit the following line in the script
Code:
      var pos0 = data.indexOf('class="priceLarge"');
change it to:
Code:
      var pos0 = data.indexOf('class="a-size-small a-color-price"');
This is the compete script with the change.
Code:
// @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-size-small a-color-price"');
      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('class="iou_cust"');
      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);
}


bernie


After further testing and coffee to get this script to work edit the following lines:
Code:
      var pos0 = data.indexOf('class="priceLarge"');
change to:
Code:
      var pos0 = data.indexOf('class="a-color-price a-size-medium a-align-top"');
edit following line
Code:
      pos0 = data.indexOf('class="iou_cust"');
change to:
Code:
 pos0 = data.indexOf('id="ebooksInstantOrderUpdate" class="a-size-medium"');
Here is the entire script with changes:
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-top"');
      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);
}


This will check the kindle price and if already owned.

bernie

Last edited by gbm; 09-19-2015 at 05:01 PM.
gbm is offline   Reply With Quote
Old 09-19-2015, 09:08 PM   #32
saki
Member
saki ought to be getting tired of karma fortunes by now.saki ought to be getting tired of karma fortunes by now.saki ought to be getting tired of karma fortunes by now.saki ought to be getting tired of karma fortunes by now.saki ought to be getting tired of karma fortunes by now.saki ought to be getting tired of karma fortunes by now.saki ought to be getting tired of karma fortunes by now.saki ought to be getting tired of karma fortunes by now.saki ought to be getting tired of karma fortunes by now.saki ought to be getting tired of karma fortunes by now.saki ought to be getting tired of karma fortunes by now.
 
Posts: 10
Karma: 471242
Join Date: Jan 2008
Device: Kindle Voyage, Kindle Paperwhite, Lenovo Tab M8 FHD, Pixel 7a
Thank you. It works great.
saki is offline   Reply With Quote
Advert
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,189
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
Old 02-09-2016, 11:42 PM   #34
sadievan
Wizard
sadievan ought to be getting tired of karma fortunes by now.sadievan ought to be getting tired of karma fortunes by now.sadievan ought to be getting tired of karma fortunes by now.sadievan ought to be getting tired of karma fortunes by now.sadievan ought to be getting tired of karma fortunes by now.sadievan ought to be getting tired of karma fortunes by now.sadievan ought to be getting tired of karma fortunes by now.sadievan ought to be getting tired of karma fortunes by now.sadievan ought to be getting tired of karma fortunes by now.sadievan ought to be getting tired of karma fortunes by now.sadievan ought to be getting tired of karma fortunes by now.
 
sadievan's Avatar
 
Posts: 1,933
Karma: 5477576
Join Date: Nov 2010
Device: Kindle Paperwhite, iPhone, Kobo LC
Quote:
Originally Posted by gbm View Post
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
Can you tell me how to install using my browser.

Edit: I think I've found it.

Thanksw

Last edited by sadievan; 02-09-2016 at 11:49 PM.
sadievan is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
WOW! The Kobo Forum is Almost Getting as Much Action as the Kindle Forum!!! pokee Kobo Reader 16 11-13-2011 09:50 AM
Hate high ebook prices? Check out this experiment iq3 News 75 02-08-2011 06:02 AM
A site to check on prices of ebooks sadievan Deals and Resources (No Self-Promotion or Affiliate Links) 3 12-06-2010 03:55 PM
Serious exploit in Greasemonkey 0.4 Alexander Turcic Lounge 2 07-19-2005 04:59 AM


All times are GMT -4. The time now is 08:31 PM.


MobileRead.com is a privately owned, operated and funded community.