Bookmarklet: Click to copy just the main URL

Recently the links on SC started to include information about layout and the display of references. Yay! That way you can send a link to a specific passage and know that the person you send it to will see exactly what you want them to.

But now the links are long and a tad bit ugly.

https://suttacentral.net/mn2/en/sujato?layout=sidebyside&reference=main/csp&notes=asterisk&highlight=true&script=latin

So I created a bookmarklet to allow you to copy just the basic part of the url to your clipboard in case you want to use it somewhere that you donā€™t need all that other info:

javascript: (() => {navigator.clipboard.writeText(window.location.href.replace(/\?.+$/,"")); })();

Itā€™s really nothing fancy, and it wonā€™t hurt anything in your browser.

How do you use it? Manually create a bookmark in your browser (probably just right click on your bookmark toolbar and select something like Add Bookmark. You can give it whatever name you like, or maybe just an emoji. Then in the URL field, paste the code above. Save, and thatā€™s it.

Now when you are on a suttacentral.net link (or any other site for that matter, e.g. amazon.com) just click that bookmark and it will copy the link to your clipboard. Then paste it wherever you like.

5 Likes

Thatā€™s cool. There are always costs and benefits!

Another way to grab the ā€œbareā€ URL is from the suttaplex. If youā€™re on a sutta, click ā€œParallelsā€, then right-click and copy the URL from the relevant text.

If thereā€™s demand, we could make make this available more directly in the UI. But my feeling is, most people donā€™t worry that much.

2 Likes

And just to be clear, I welcome the more info packed urls. But sometimes I just want the simple one. Of course I could also just select it from the url bar. But that can introduce errors.

And yes, this is probably something not many people would need.

Hereā€™s a version that copies a short markdown version of the link to the clipboard:

javascript: (() => {navigator.clipboard.writeText("[" + document.title.replace(/ā€”.+$/, "") + "](" + window.location.href.replace(/\?.+$/, "") + ")");})();

For example:

[MN 152: Indriyabhāvanāsutta](https://suttacentral.net/mn152/en/sujato)

And this one to create a full markdown version:

javascript: (() => {navigator.clipboard.writeText("[" + document.title + "](" + window.location.href + ")");})();

for example:

[MN 152: Indriyabhāvanāsuttaā€”Bhikkhu Sujato](https://suttacentral.net/mn152/en/sujato?layout=sidebyside&reference=main/csp&notes=asterisk&highlight=true&script=latin)
1 Like