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 03-28-2025, 08:07 AM   #1
salty-horse
Wizard
salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.
 
salty-horse's Avatar
 
Posts: 1,943
Karma: 19318370
Join Date: Sep 2008
Device: Kobo Clara 2E
Bookmarklet to help create Kobo sale posts

I created a bookmarklet to help me make sale posts faster.
When activated on a Kobo page, it pops up a textbox with formatted text that I can paste into these forums.

This is based on my opinion on how to create an informative post. It has the book title in bold, the author name, a rounded price (no ".99" cents), the description, and series information, if available. It detects the US and UK stores. I also kept a placeholder for Amazon links.

Feel free to tweak it as you wish, or I can customize it for you.

To create this bookmarklet, copy this text and paste it as the URL of a new bookmark. Place it in a bookmark toolbar, and click it when you're on a Kobo page for an unpurchased book (otherwise, the price isn't visible.) You can open a private tab if you want to see the price.

PHP Code:
javascript:(function()%7Bfunction%20htmlToText(html)%7B%20html%20%3D%20html.replace(%2F%5Cn%2Fg%2C%20'')%3B%20html%20%3D%20html.replace(%2F%5Ct%2Fg%2C%20'')%3B%20html%20%3D%20html.replace(%2F%3C%5C%2Ftd%3E%2Fg%2C%20'%5Ct')%3B%20html%20%3D%20html.replace(%2F%3C%5C%2Ftable%3E%2Fg%2C%20'%5Cn')%3B%20html%20%3D%20html.replace(%2F%3C%5C%2Ftr%3E%2Fg%2C%20'%5Cn')%3B%20html%20%3D%20html.replace(%2F%3C%5C%2Fp%3E%2Fg%2C%20'%5Cn%5Cn')%3B%20html%20%3D%20html.replace(%2F%3C%5C%2Fdiv%3E%2Fg%2C%20'%5Cn')%3B%20html%20%3D%20html.replace(%2F%3C%5C%2Fh%3E%2Fg%2C%20'%5Cn')%3B%20html%20%3D%20html.replace(%2F%3Cem%3E%2Fg%2C%20'%5BI%5D')%3B%20html%20%3D%20html.replace(%2F%3C%5C%2Fem%3E%2Fg%2C%20'%5B%5C%2FI%5D')%3B%20html%20%3D%20html.replace(%2F%3Cbr%3E%2Fg%2C%20'%5Cn')%3B%20html%20%3D%20html.replace(%2F%3Cbr(%20)*%5C%2F%3E%2Fg%2C%20'%5Cn')%3B%20let%20dom%20%3D%20(new%20DOMParser()).parseFromString('%3C!doctype%20html%3E%3Cbody%3E'%20%2B%20html%2C%20'text%2Fhtml')%3B%20return%20dom.body.textContent.trim()%3B%20%7D%20currencies%20%3D%20%7B'USD'%3A%20%5B'%24'%2C%20'US'%5D%2C%20'GBP'%3A%20%5B'%C2%A3'%2C%20'UK'%5D%7D%3B%20function%20createPostText()%20%7B%20let%20title%20%3D%20document.querySelector('h1.title').innerHTML.trim()%3B%20let%20author%20%3D%20document.querySelector('a.contributor-name').innerHTML.trim()%3B%20let%20description%20%3D%20%20htmlToText(document.querySelector('div%5Bdata-full-synopsis%5D').innerHTML.trim())%3B%20let%20price%20%3D%20Math.round(parseFloat(document.querySelector('meta%5Bproperty%3D%22og%3Aprice%22%5D').content))%3B%20let%20%5Bcurrency%2C%20country%5D%20%3D%20currencies%5Bdocument.querySelector('meta%5Bproperty%3D%22og%3Acurrency_code%22%5D').content%5D%3B%20let%20seriesField%20%3D%20document.querySelector('span.product-sequence-field')%3B%20let%20series%20%3D%20''%3B%20if%20(seriesField)%20%7B%20seriesName%20%3D%20seriesField.innerText%3B%20seriesNumber%20%3D%20document.querySelector('span.sequenced-name-prefix')%3B%20if%20(seriesNumber)%20%7B%20let%20match%20%3D%20seriesNumber.innerText.match(%2F%5Cd%2B%2F)%3B%20if%20(match)%20%7B%20series%20%3D%20%60%20(%5BI%5D%24%7BseriesName%7D%20%23%24%7Bmatch%5B0%5D%7D%5B%2FI%5D)%60%3B%20%7D%20%7D%20if%20(!series)%20%7B%20series%20%3D%20%60%20(%5BI%5D%24%7BseriesName%7D%5B%2FI%5D)%60%3B%20%7D%20%7D%20let%20isbn%20%3D%20JSON.parse(JSON.parse(document.querySelector('%23ratings-widget-details-wrapper').dataset.koboGizmoConfig).googleBook).workExample.isbn%3B%20let%20amazonTLD%20%3D%20country%20%3D%3D%20'US'%20%3F%20'com'%20%3A%20'co.uk'%3B%20let%20amazonURL%20%3D%20%60https%3A%2F%2Fwww.amazon.%24%7BamazonTLD%7D%2Fs%3Fk%3D%24%7Bisbn%7D%26i%3Ddigital-text%60%3B%20let%20pageUrl%20%3D%20window.location.href.split('%3F')%5B0%5D%3B%20let%20text%20%3D%20%60%5BB%5D%5BI%5D%24%7Btitle%7D%5B%2FB%5D%5B%2FI%5D%24%7Bseries%7D%20by%20%24%7Bauthor%7D%20is%20%24%7Bcurrency%7D%24%7Bprice%7D%20in%20the%20%24%7Bcountry%7D%20(%5BURL%3D%24%7BpageUrl%7D%5DKobo%5B%2FURL%5D%2C%20%5BURL%3D%24%7BamazonURL%7D%5DAmazon%5B%2FURL%5D)%5Cn%5BQUOTE%5D%24%7Bdescription%7D%5B%2FQUOTE%5D%60%3B%20let%20div%20%3D%20document.createElement('div')%3B%20div.style%20%3D%20%22position%3A%20fixed%3B%20top%3A%200em%3B%20right%3A%200em%3B%20width%3A%20500px%3B%20height%3A%20500px%3B%20border%3A%201px%20solid%20black%3B%20z-index%3A%2010000%3B%22%3B%20let%20textarea%20%3D%20document.createElement('textarea')%3B%20textarea.style%20%3D%20%22width%3A%20400px%3B%20height%3A%20400px%3B%22%3B%20textarea.value%20%3D%20text%3B%20div.appendChild(textarea)%3B%20document.body.appendChild(div)%3B%20textarea.focus()%3B%20textarea.setSelectionRange(0%2C%20text.length%2C%20'backward')%3B%20window.addEventListener('click'%2Cfunction(event)%20%7B%20if%20(!(div.contains(event.target)))%20%7B%20div.remove()%3B%20%7D%20%7D)%3B%20%7D%20createPostText()%3B%7D)()%3B 

Last edited by salty-horse; 05-06-2025 at 03:37 AM.
salty-horse is online now   Reply With Quote
Old 03-28-2025, 09:48 AM   #2
Cactus Chef
Fanatic
Cactus Chef ought to be getting tired of karma fortunes by now.Cactus Chef ought to be getting tired of karma fortunes by now.Cactus Chef ought to be getting tired of karma fortunes by now.Cactus Chef ought to be getting tired of karma fortunes by now.Cactus Chef ought to be getting tired of karma fortunes by now.Cactus Chef ought to be getting tired of karma fortunes by now.Cactus Chef ought to be getting tired of karma fortunes by now.Cactus Chef ought to be getting tired of karma fortunes by now.Cactus Chef ought to be getting tired of karma fortunes by now.Cactus Chef ought to be getting tired of karma fortunes by now.Cactus Chef ought to be getting tired of karma fortunes by now.
 
Cactus Chef's Avatar
 
Posts: 544
Karma: 7000000
Join Date: Apr 2019
Location: East Coast, United States
Device: Kobo Sage, Kobo Clara HD, Galaxy Tab S5e, Kindle 4th Gen
Thumbs up

I put your function into a Javascript Beautifier to try to better understand it, and I still have no idea what it's doing.

Nice idea in theory, though. I've thought about doing something similar so that when I see a publisher sale ebook price on Kobo I could have it automatically retrieve the same book on Amazon, Barnes & Noble, Google Play, and Apple Books, for the purpose of more easily populating the deal post.
Cactus Chef is offline   Reply With Quote
Advert
Old 03-28-2025, 01:18 PM   #3
salty-horse
Wizard
salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.
 
salty-horse's Avatar
 
Posts: 1,943
Karma: 19318370
Join Date: Sep 2008
Device: Kobo Clara 2E
Quote:
Originally Posted by Cactus Chef View Post
I put your function into a Javascript Beautifier to try to better understand it, and I still have no idea what it's doing.
Sorry, it needs to be "unquoted" beforehand.

Here's the original script, which I then pasted into a bookmarklet maker

I didn't try fetching other retailers. I can try adding Amazon by searching for the ISBN on the Kobo page.
salty-horse is online now   Reply With Quote
Old 03-31-2025, 09:41 AM   #4
salty-horse
Wizard
salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.
 
salty-horse's Avatar
 
Posts: 1,943
Karma: 19318370
Join Date: Sep 2008
Device: Kobo Clara 2E
I can't fetch data from Amazon, since the script runs on Kobo's "website", and some browser security features block outgoing requests. But I can include a search page result page instead of a direct link, like:

https://www.amazon.com/s?k=9781668060063&i=digital-text

EDIT: Update bookmarklet code above.

Last edited by salty-horse; 03-31-2025 at 09:52 AM.
salty-horse is online now   Reply With Quote
Old 04-01-2025, 01:51 AM   #5
salty-horse
Wizard
salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.
 
salty-horse's Avatar
 
Posts: 1,943
Karma: 19318370
Join Date: Sep 2008
Device: Kobo Clara 2E
Fixed amazon UK link.
salty-horse is online now   Reply With Quote
Advert
Old 05-06-2025, 03:37 AM   #6
salty-horse
Wizard
salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.salty-horse ought to be getting tired of karma fortunes by now.
 
salty-horse's Avatar
 
Posts: 1,943
Karma: 19318370
Join Date: Sep 2008
Device: Kobo Clara 2E
Fixed trimmed description with "..." at the end (I copied the text from an expandable element instead of its source)
salty-horse is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Wallabag fetch local content through bookmarklet thereisthat KOReader 1 01-11-2024 02:37 PM
Help! Automatically send new blog posts to Kindle/Nook/Kobo? kongjpn Recipes 1 01-28-2022 11:00 AM
Kobo Clara back on sale at Walmart, Amazon and Kobo rcentros Deals and Resources (No Self-Promotion or Affiliate Links) 2 12-11-2019 09:04 PM
New Posts misses a lot of posts Tarana Feedback 2 06-04-2019 01:09 PM
Hacks Bookmarklet to delete archived personal documents quickly thomass Amazon Kindle 38 07-22-2016 07:09 AM


All times are GMT -4. The time now is 04:28 AM.


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