09-18-2015, 11:37 PM | #1 |
Grand Sorcerer
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
GreaseMonkey script to check Kobo prices in this forum
Firstly, this is shamelessy stolen from GreaseMonkey script to check Kindle prices in this forum.
Below is a Greasemonkey script for checking prices of books in the Kobo store. This looks at the link posted and adds the price after the link. If you are logged into you Kobo account, it will also show whether you already own the book. I have been using this for a while and it works well. But, I mainly use the Australian shop. As far as I can tell, they are all the same, but there might be some differences. If you have any problems, please report them here and I will have a look at it. To install:
Code:
// ==UserScript== // @name MobileRead Kobo Price Check // @namespace http://dunck.us/code/greasemonkey // @description Checks price of Kindle ebook links in MobileRead forum posts. // @include https://www.mobileread.com/forums/show*.php* // @version 1 // @grant GM_xmlhttpRequest // @grant GM_log // ==/UserScript== // https://store.kobobooks.com/en-GB/ebook/summoner-book-0-origins-the-prequel var site_regex = /^(http|https):\/\/store.kobobooks.com\/.*\/*ebook\/.*/; 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 price = ''; var color = 'blue'; var data = response.responseText; var pos0 = data.indexOf('class="right inline-price"'); if (pos0 > 1) { var pos1 = data.indexOf('>', pos0); var pos2 = data.indexOf('<', pos1); price = data.substring(pos1 + 1, pos2).trim(); } else if (data.indexOf('>Free eBook<') > 0) { price = 'Free'; color = 'red' } else if (data.indexOf('view-in-library') > 0) { price = 'already own'; color = 'red' } if (price == '') { price = 'N/A'; } if (color == '') { var color = 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) { check_price(a[i], url); } } |
09-19-2015, 10:23 AM | #2 |
Grand Sorcerer
Posts: 44,736
Karma: 55645321
Join Date: Jan 2007
Location: Peru
Device: Kindle: Oasis 3, Voyage WiFi; Kobo: Libra 2, Aura One
|
Moved OUT of the Deals and Freebies forum, and INTO the Kobo Forum.
Don (Moderator) |
Advert | |
|
09-20-2015, 03:29 PM | #3 |
Bibliophagist
Posts: 35,299
Karma: 145435140
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Seems to work here so when a link such as the ones below appear, the price is autofetched (assuming GreaseMonkey and the scripts are installed and enabled )
https://store.kobobooks.com/en-ca/eb...mmers-volume-1 http://www.amazon.ca/Complete-Hammer...r%27s+slammers Last edited by DNSB; 09-20-2015 at 03:45 PM. |
09-20-2015, 11:37 PM | #4 |
Grand Sorcerer
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
|
09-21-2015, 01:37 PM | #5 |
Wizard
Posts: 1,196
Karma: 3765734
Join Date: Feb 2012
Location: Ottawa, Ontario, Canada
Device: Kobo Libra 2, Lenovo Tab M10 FHD Plus, Lenovo Tab M8 HD
|
The Kobo one works for me. The Kindle one does not. Strange.
|
Advert | |
|
09-21-2015, 01:55 PM | #6 |
Grand Sorcerer
Posts: 12,155
Karma: 73448616
Join Date: Nov 2007
Location: Toronto
Device: Nexus 7, Clara, Touch, Tolino EPOS
|
The Kindle one seems to have gone through multiple revisions. I ended up using one of the ones found at http://userscripts-mirror.org/users/476972/scripts
|
09-21-2015, 02:03 PM | #7 |
Wizard
Posts: 2,082
Karma: 8796704
Join Date: Jun 2010
Device: Kobo Clara HD,Hisence Sero 7 Pro RIP, Nook STR, jetbook lite
|
This one will work for you in Canada.
Code:
// ==UserScript== // @name MobileRead Kindle Price Check (amazon.ca) // @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\.(ca)(\/.*)/; var migrate_regex = false; var migrate_replacement = ''; var currency_prefix = 'CDN$ '; 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="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 == 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); } |
09-23-2015, 12:32 AM | #8 |
Bibliophagist
Posts: 35,299
Karma: 145435140
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
I'd suggest this one instead. The one you posted will show prices on Amazon.ca if the link is to amazon.ca. The version I prefer converts .com to .ca which gives me results from the vast majority of Amazon links.
This is the one from the link posted by PeterT. Code:
// ==UserScript== // @name MobileRead Kindle Price Check (amazon.ca) // @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|ca)(\/.*)/; var migrate_regex = /amazon\.com/; var migrate_replacement = 'amazon.ca'; var currency_prefix = 'CDN$ '; 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="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 == 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); } |
09-23-2015, 08:36 AM | #9 |
Wizard
Posts: 1,196
Karma: 3765734
Join Date: Feb 2012
Location: Ottawa, Ontario, Canada
Device: Kobo Libra 2, Lenovo Tab M10 FHD Plus, Lenovo Tab M8 HD
|
Thanks DNSB & PeterT, that script works. Fun funtionality... sometimes GreaseMonkey is worth it. :-D
|
08-12-2017, 02:09 PM | #10 | |
Wizard
Posts: 2,082
Karma: 8796704
Join Date: Jun 2010
Device: Kobo Clara HD,Hisence Sero 7 Pro RIP, Nook STR, jetbook lite
|
Quote:
I have not checked if it works with you library YMMV Code:
// ==UserScript== // @name MobileRead Kobo Price Check // @namespace http://dunck.us/code/greasemonkey // @description Checks price of Kobo US ebook links in MobileRead forum posts. // @include (http|https)://www.mobileread.com/forums/show*.php* // @version 1 // @grant GM_xmlhttpRequest // @grant GM_log // ==/UserScript== // https://www.kobo.com/us/en/ebook/summoner-book-0-origins-the-prequel var site_regex = /^(http|https):\/\/www.kobo.com\/.*\/*ebook\/.*/; 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 price = ''; var color = 'blue'; var data = response.responseText; var pos0 = data.indexOf('span class="price" translate=no'); if (pos0 > 1) { var pos1 = data.indexOf('>', pos0); var pos2 = data.indexOf('<', pos1); price = data.substring(pos1 + 1, pos2).trim(); } else if (data.indexOf('>Free eBook<') > 0) { price = 'Free'; color = 'red' } else if (data.indexOf('view-in-library') > 0) { price = 'already own'; color = 'red' } if (price == '') { price = 'N/A'; } if (color == '') { var color = 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) { check_price(a[i], url); } } |
|
08-13-2017, 05:39 AM | #11 |
Resident Curmudgeon
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
|
Test link...
https://www.kobo.com/us/en/ebook/the...mmers-volume-1 It works here but not for post #3. I tested it in the free/bargain SF thread and it works there. Thanks for the Kobo price checker script. Last edited by JSWolf; 08-13-2017 at 05:41 AM. |
08-13-2017, 02:17 PM | #12 | |
Bibliophagist
Posts: 35,299
Karma: 145435140
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
Code:
https://store.kobobooks.com/en-ca/ebook/ Code:
https://www.kobo.com/us/en/ebook/ |
|
08-13-2017, 02:55 PM | #13 | |
Wizard
Posts: 2,082
Karma: 8796704
Join Date: Jun 2010
Device: Kobo Clara HD,Hisence Sero 7 Pro RIP, Nook STR, jetbook lite
|
Quote:
bernie |
|
08-13-2017, 04:39 PM | #14 |
Bibliophagist
Posts: 35,299
Karma: 145435140
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
If I go to the English Canadian store, the only visible change is /us/ becomes /ca/ in the URL. The kobobooks URL in post #3 is an old one which is what I was attempting to point out. It would take bit more work to convert the old URL to work with the new store.
Last edited by DNSB; 08-13-2017 at 04:48 PM. |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
GreaseMonkey script to check Kindle prices in this forum | kakapo | Deals and Resources (No Self-Promotion or Affiliate Links) | 33 | 02-09-2016 11:42 PM |
Kobo bookstore on Kobo Touch not showing prices (Canada) | RobertJSawyer | Kobo Reader | 13 | 09-23-2012 08:30 PM |
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 |