View Single Post
Old 07-11-2012, 03:49 AM   #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)
Bookmarklet to check if Kindle "free" books are really free

One of my favourite foraging grounds for free books for my Kindle was Amazon's Best Sellers in Kindle eBooks. That shows the top paid and free in the US books. Many books have stopped being free in the Asia-Pacific region so i wrote a bookmarklet to which ones were actually free to me. It will show the ones that are free to you by loading the pages with your login and region.

(If you've not heard of bookmarklets before, they're a bookmark that is some JavaScript code. So instead of going to a new location, they perform an action on the current page.)

I can't make a javascript: url in this forum, so it's a two step process to add it. Drag this link to your browser's bookmarks toolbar:
Kindle Best Seller price correction

Then change the url to:
Code:
javascript:amznJQ.jQuery('.zg_availability').each(function(){if(amznJQ.jQuery(this).html().trim()=='Currently%20unavailable'){amznJQ.jQuery(this).parent().parent().css('opacity',0.2);}});amznJQ.jQuery('.price').each(function(){var%20url=amznJQ.jQuery(this).parent().parent().find('a').attr('href').trim();var%20price=amznJQ.jQuery(this).html().trim();if(price=='Free'||price=='$0.00'){(function(price_node,old_price,url){amznJQ.jQuery.get(url,{},function(data,textStatus){var%20pos0=data.indexOf('class="priceLarge"');var%20pos1=data.indexOf('>',pos0);var%20pos2=data.indexOf('<',pos1);var%20new_price=data.substring(pos1+1,pos2).trim();amznJQ.jQuery(price_node).after('%20actual:'+new_price);if(new_price!='$0.00'){amznJQ.jQuery(price_node).parent().parent().parent().css('opacity',0.2);}},'text');})(this,price,url);}else{amznJQ.jQuery(this).parent().parent().parent().css('opacity',0.2);}});void(0);
Once you've done that, visit the Best Sellers in Kindle eBooks, wait for the page to finish loading and click on the new bookmark. It will check the actual price of "free" books and all the books that are not free for you will turn white.

Hopefully this is useful to someone.

If you'd like to modify the bookmarket (eg turn it into a GreaseMonkey script or Chrome extension) or just to see how it works, here is the code before i removed all the whitespace:

Code:
javascript:
amznJQ.jQuery('.zg_availability').each(function() {
  if (amznJQ.jQuery(this).html().trim() == 'Currently unavailable') {
    amznJQ.jQuery(this).parent().parent().css('opacity', 0.2);
  }
});
amznJQ.jQuery('.price').each(function() {
  var url = amznJQ.jQuery(this).parent().parent().find('a').attr('href').trim();
  var price = amznJQ.jQuery(this).html().trim();
  if (price == 'Free' || price == '$0.00') { 
    (function(price_node, old_price, url) {
      amznJQ.jQuery.get(url, {}, function (data, textStatus) {
        var pos0 = data.indexOf('class="priceLarge"');
        var pos1 = data.indexOf('>', pos0);
        var pos2 = data.indexOf('<', pos1);
        var new_price = data.substring(pos1 + 1, pos2).trim();
        amznJQ.jQuery(price_node).after(' actual:' + new_price);
        if (new_price != '$0.00') {
          amznJQ.jQuery(price_node).parent().parent().parent().css('opacity', 0.2);
        }
      }, 'text');
    })(this, price, url);
  } else {
    amznJQ.jQuery(this).parent().parent().parent().css('opacity', 0.2);
  }
});
void(0);
kakapo is offline   Reply With Quote