Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript library for a "Universal Wishlist" type bookmark-button?

Amazon has a Universal Wishlist button which can be added to the browser bookmarks bar, then pressed on any website and it sends the details of the page the user is currently looking at to Amazon. Amazon then pull out the product details out of the page and add the product to the user's wish list.

Do any libraries exist to replicate this (or similar) functionality for my own site? I could probably replicate it by copying Amazon's code using javascript, but don't want to waste my time if there already exists a library to do this or something similar that I can adapt. I'm also not really sure what this type of bookmark-button is called so it's difficult to google for.

Thanks.

like image 777
Crashthatch Avatar asked Apr 05 '26 17:04

Crashthatch


1 Answers

It is a bookmarklet.

Usually a link that loads a script in the current page.

<a href="javascript:(function(){var s=window.document.createElement('script');s.src = 'https://yourserver.com/your.js';window.document.body.appendChild(s);}())">
  drag this link to the bookmark bar
</a>

When you click the bookmark, it will execute the simple javascript code in the href.

A script tag is added in the current page. And load the url, here https://yourserver.com/your.js.

At the end of the file your.js you can call a function to execute any action. You have access to all resources of the current page(DOM, JS and cookies).

like image 138
Mic Avatar answered Apr 08 '26 06:04

Mic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!