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 07-16-2012, 06:09 PM   #1
kakapo
The Night Parrot
kakapo can fool all of the people all of the time.kakapo can fool all of the people all of the time.kakapo can fool all of the people all of the time.kakapo can fool all of the people all of the time.kakapo can fool all of the people all of the time.kakapo can fool all of the people all of the time.kakapo can fool all of the people all of the time.kakapo can fool all of the people all of the time.kakapo can fool all of the people all of the time.kakapo can fool all of the people all of the time.kakapo can fool all of the people all of the time.
 
kakapo's Avatar
 
Posts: 23
Karma: 138516
Join Date: Feb 2011
Location: Codfish Island, NZ
Device: Palm Vx, Kindle Keyboard (wifi)
GreaseMonkey script to check Kindle prices in this forum

I have written a script for GreaseMonkey (a FireFox addon) to check the prices of Kindle ebooks linked in MobileRead forum posts. Once installed, any links to a Kindle ebook will have the price displayed after then. Prices are coloured red for free and blue otherwise.

Currently the script only works in FireFox with GreaseMonkey installed. Even though Google Chrome can use some GreaseMonkey scripts, it can't use this one. I should be able to make it work as a proper Chrome extension, just ask and i will.

The script is set up to check amazon.com links. It can check amazon.co.uk links, just change the appropriate line at the top. Adding of additional Amazon countries should be easy enough. It should even be possible to add other ebook stores, eg Kobo or B&N.

To install the script, go to http://userscripts.org/scripts/show/138544 or copy out the code below.

Code:
// ==UserScript==
// @name        MobileRead Kindle Price Check
// @namespace   kakapo.public
// @description Checks price of Kindle ebook links in MobileRead forum posts
// @include     https://www.mobileread.com/forums/showthread.php*
// @version     1
// ==/UserScript==

// change com in line below to co.uk for Amazon UK
var site_regex = /^(http|https):\/\/(www\.)?amazon\.(com)(\/.*)/;

var ebook_url_regexs = [
  /^\/dp\//,
  /^\/[^\/]+\/dp\//,
  /^\/gp\/product\//
];

var check_price = function(element, url) {
  var xhr = GM_xmlhttpRequest({
    method: 'GET',
    url: url,
    onload: function(response) {
      var data = response.responseText;
      var pos0 = data.indexOf('class="priceLarge"');
      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 == '$0.00' || price == '£0.00' ? 'red' : 'blue';
      element.insertAdjacentHTML('afterend', ' <span style="color:'+color+'">('+price+')</span>');
    }
  });
}

var a = document.getElementsByTagName('a');
for (var i = 0; i < a.length; i++) {
  var url = a[i].href;
  var parts = site_regex.exec(url);
  if (parts) {
    for (var j = 0; j < ebook_url_regexs.length; j++)  {
      if (ebook_url_regexs[j].test(parts[parts.length-1])) {
        check_price(a[i], url);
      }
    }
  }
}
kakapo is offline   Reply With Quote
Old 07-16-2012, 08:55 PM   #2
copyrite
Wizard
copyrite ought to be getting tired of karma fortunes by now.copyrite ought to be getting tired of karma fortunes by now.copyrite ought to be getting tired of karma fortunes by now.copyrite ought to be getting tired of karma fortunes by now.copyrite ought to be getting tired of karma fortunes by now.copyrite ought to be getting tired of karma fortunes by now.copyrite ought to be getting tired of karma fortunes by now.copyrite ought to be getting tired of karma fortunes by now.copyrite ought to be getting tired of karma fortunes by now.copyrite ought to be getting tired of karma fortunes by now.copyrite ought to be getting tired of karma fortunes by now.
 
copyrite's Avatar
 
Posts: 1,814
Karma: 4985051
Join Date: Sep 2010
Location: Maryland
Device: ...lots! ;) mostly reading on a Kindle Voyage
Pretty cool! Thanks!
copyrite is offline   Reply With Quote
Old 07-17-2012, 05:42 AM   #3
sherman
Guru
sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.
 
Posts: 850
Karma: 2641698
Join Date: Aug 2008
Location: Taranaki - NZ
Device: Kobo Aura H2O, Kobo Forma
And still no one knows just WHAT is going on over at Amazon...

This thread on the Amazon discussion boards has quite a number of very confused international Amazon customers.

Us folks from NZ seem to be especially affected. I haven't been able to obtain ANY of the advertised freebies from Amazon for at least a week now
sherman is online now   Reply With Quote
Old 07-17-2012, 10:21 AM   #4
Joseph R
Zealot
Joseph R ought to be getting tired of karma fortunes by now.Joseph R ought to be getting tired of karma fortunes by now.Joseph R ought to be getting tired of karma fortunes by now.Joseph R ought to be getting tired of karma fortunes by now.Joseph R ought to be getting tired of karma fortunes by now.Joseph R ought to be getting tired of karma fortunes by now.Joseph R ought to be getting tired of karma fortunes by now.Joseph R ought to be getting tired of karma fortunes by now.Joseph R ought to be getting tired of karma fortunes by now.Joseph R ought to be getting tired of karma fortunes by now.Joseph R ought to be getting tired of karma fortunes by now.
 
Joseph R's Avatar
 
Posts: 136
Karma: 2137000
Join Date: Aug 2011
Location: Calgary, Alberta
Device: iPad, Kobo Glo HD
Thank you for the good work, kakapo!

Tampermonkey is Chrome's equivalent to greasemonkey.

All you need to do is go to ''add a new script', and Copy and Paste Kakapo's script and you are good to go!
Joseph R is offline   Reply With Quote
Old 07-17-2012, 07:11 PM   #5
kyteflyer
Wizard
kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.
 
kyteflyer's Avatar
 
Posts: 1,841
Karma: 9547754
Join Date: Jul 2009
Location: Newcastle, Australia
Device: iPhone SE2020
Wonder why its not working here... script installed OK...
kyteflyer is offline   Reply With Quote
Old 07-17-2012, 07:30 PM   #6
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 73,887
Karma: 128597114
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Anyway want to come up with scripts for Sony, B&N, & Kobo please?
JSWolf is offline   Reply With Quote
Old 07-31-2012, 07:02 PM   #7
kyteflyer
Wizard
kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.
 
kyteflyer's Avatar
 
Posts: 1,841
Karma: 9547754
Join Date: Jul 2009
Location: Newcastle, Australia
Device: iPhone SE2020
Script is working on the computer, just love it. Thanks
kyteflyer is offline   Reply With Quote
Old 03-02-2013, 04:36 PM   #8
kyteflyer
Wizard
kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.
 
kyteflyer's Avatar
 
Posts: 1,841
Karma: 9547754
Join Date: Jul 2009
Location: Newcastle, Australia
Device: iPhone SE2020
Thumbs up FYI: Works in other browsers too

I've given up on Firefox because it has turned into a giant slug... So mostly using Chrome, Opera and Safari.

Sadly, Greasekit for Safari does not any longer seem to be maintained, and the old script isn't compatible with newer versions of Safari... perhaps someone will do something about it.

On Chrome, its Tampermonkey, and in Opera, its Violentmonkey. This script works beautifully in both of those.

kyteflyer is offline   Reply With Quote
Old 03-02-2013, 05:28 PM   #9
Shack70
Guru
Shack70 ought to be getting tired of karma fortunes by now.Shack70 ought to be getting tired of karma fortunes by now.Shack70 ought to be getting tired of karma fortunes by now.Shack70 ought to be getting tired of karma fortunes by now.Shack70 ought to be getting tired of karma fortunes by now.Shack70 ought to be getting tired of karma fortunes by now.Shack70 ought to be getting tired of karma fortunes by now.Shack70 ought to be getting tired of karma fortunes by now.Shack70 ought to be getting tired of karma fortunes by now.Shack70 ought to be getting tired of karma fortunes by now.Shack70 ought to be getting tired of karma fortunes by now.
 
Shack70's Avatar
 
Posts: 775
Karma: 1043626
Join Date: Dec 2010
Location: York, Pa
Device: Kindle Fire 10", Honor 8 Android Phone
Working fine here (Firefox + Amazon US Store)! Thanks!
Shack70 is offline   Reply With Quote
Old 03-03-2013, 03:46 PM   #10
kakapo
The Night Parrot
kakapo can fool all of the people all of the time.kakapo can fool all of the people all of the time.kakapo can fool all of the people all of the time.kakapo can fool all of the people all of the time.kakapo can fool all of the people all of the time.kakapo can fool all of the people all of the time.kakapo can fool all of the people all of the time.kakapo can fool all of the people all of the time.kakapo can fool all of the people all of the time.kakapo can fool all of the people all of the time.kakapo can fool all of the people all of the time.
 
kakapo's Avatar
 
Posts: 23
Karma: 138516
Join Date: Feb 2011
Location: Codfish Island, NZ
Device: Palm Vx, Kindle Keyboard (wifi)
Quote:
Originally Posted by kyteflyer View Post
Sadly, Greasekit for Safari does not any longer seem to be maintained, and the old script isn't compatible with newer versions of Safari... perhaps someone will do something about it.
Try NinjaKit as a replacement for Greasekit. It works for me on Safari 5.1.7 (still on 10.6 here, so can't get Safari 6).

While i'm here, any suggestions for new features for the Kindle Price Check script? Proper UK/DE/etc versions? Automatic .com to .co.uk link conversion? BN/Kobo/Sony support?
kakapo is offline   Reply With Quote
Old 03-03-2013, 04:02 PM   #11
carld
Wizard
carld ought to be getting tired of karma fortunes by now.carld ought to be getting tired of karma fortunes by now.carld ought to be getting tired of karma fortunes by now.carld ought to be getting tired of karma fortunes by now.carld ought to be getting tired of karma fortunes by now.carld ought to be getting tired of karma fortunes by now.carld ought to be getting tired of karma fortunes by now.carld ought to be getting tired of karma fortunes by now.carld ought to be getting tired of karma fortunes by now.carld ought to be getting tired of karma fortunes by now.carld ought to be getting tired of karma fortunes by now.
 
Posts: 2,698
Karma: 4748723
Join Date: Dec 2007
Device: Kindle Paperwhite
This is terrific. Thank you. And yes, Tapermonkey + Script works just fine with Chrome.

Edit: I was surprised, but it also shows prices for linked Android Apps as well.

Last edited by carld; 03-03-2013 at 04:15 PM.
carld is offline   Reply With Quote
Old 03-04-2013, 04:42 PM   #12
kyteflyer
Wizard
kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.kyteflyer ought to be getting tired of karma fortunes by now.
 
kyteflyer's Avatar
 
Posts: 1,841
Karma: 9547754
Join Date: Jul 2009
Location: Newcastle, Australia
Device: iPhone SE2020
Quote:
Originally Posted by kakapo View Post
Try NinjaKit as a replacement for Greasekit. It works for me on Safari 5.1.7 (still on 10.6 here, so can't get Safari 6).
Thanks for that.. I'll give it a try (on 10.8.3 beta and latest safari so should be interesting... will report back)

[edit] WORKING!! Yay! Hope it works for my other scripts for other sites too

Last edited by kyteflyer; 03-04-2013 at 04:49 PM.
kyteflyer is offline   Reply With Quote
Old 03-06-2013, 06:56 PM   #13
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,931
Karma: 5456284
Join Date: Nov 2010
Device: Kindle Paperwhite 2, iPhone, Kindle Fire HD 6
Thanks Kakapo. Karma going to you.
sadievan is offline   Reply With Quote
Old 03-06-2013, 07:27 PM   #14
DustyDisks
Old Fart In Training
DustyDisks ought to be getting tired of karma fortunes by now.DustyDisks ought to be getting tired of karma fortunes by now.DustyDisks ought to be getting tired of karma fortunes by now.DustyDisks ought to be getting tired of karma fortunes by now.DustyDisks ought to be getting tired of karma fortunes by now.DustyDisks ought to be getting tired of karma fortunes by now.DustyDisks ought to be getting tired of karma fortunes by now.DustyDisks ought to be getting tired of karma fortunes by now.DustyDisks ought to be getting tired of karma fortunes by now.DustyDisks ought to be getting tired of karma fortunes by now.DustyDisks ought to be getting tired of karma fortunes by now.
 
DustyDisks's Avatar
 
Posts: 534
Karma: 2742476
Join Date: Jan 2011
Location: Gladewater, Texas
Device: K3+3g/KFHD 7"/Nexus 7/Nexus 7.2
Thanks Kakapo,

This is almost as good as "crispy" bacon!
DustyDisks is offline   Reply With Quote
Old 03-16-2013, 12:13 PM   #15
darthyoda6
Connoisseur
darthyoda6 can talk all four legs off a donkey... then persuade it to go for a walk.darthyoda6 can talk all four legs off a donkey... then persuade it to go for a walk.darthyoda6 can talk all four legs off a donkey... then persuade it to go for a walk.darthyoda6 can talk all four legs off a donkey... then persuade it to go for a walk.darthyoda6 can talk all four legs off a donkey... then persuade it to go for a walk.darthyoda6 can talk all four legs off a donkey... then persuade it to go for a walk.darthyoda6 can talk all four legs off a donkey... then persuade it to go for a walk.darthyoda6 can talk all four legs off a donkey... then persuade it to go for a walk.darthyoda6 can talk all four legs off a donkey... then persuade it to go for a walk.darthyoda6 can talk all four legs off a donkey... then persuade it to go for a walk.darthyoda6 can talk all four legs off a donkey... then persuade it to go for a walk.
 
Posts: 93
Karma: 124056
Join Date: Nov 2010
Location: Canada
Device: Kobo Clara HD, Kindle Paperwhite 10th Gen, Kindle 7th Gen
Thanks, it's working great with Greasemonkey, although I had to add
Code:
// @grant       GM_xmlhttpRequest
at the top to get rid of the message that kept poping up about the script needing to grant permission. Is there a way to get the script to use the amazon.com links but check the price against amazon.ca? Or do I just need to change the (com) to (ca).

Thanks
darthyoda6 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 02:21 AM.


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