View Single Post
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: 2,028
Karma: 21036090
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%3Cstrong%3E%2Fg%2C%20'%5BB%5D')%3B%20html%20%3D%20html.replace(%2F%3C%5C%2Fstrong%3E%2Fg%2C%20'%5B%5C%2FB%5D')%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; 07-09-2025 at 05:39 AM.
salty-horse is offline   Reply With Quote