drummerSupport icon indicating copy to clipboard operation
drummerSupport copied to clipboard

Working example of Radio3 bookmarklet

Open jackbaty opened this issue 4 years ago • 9 comments

I was unable to get the "R3" bookmarklet provided in the Radio3 HowTo to work, so I asked around and John Johnston (@troutcolor) had a working version available, which he shared here

Or TL;DR:

javascript:(function()%7B%20window.open('http://radio3.io/?link='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)+'&description='+encodeURIComponent(document.getSelection()));%20%7D)();

I heard at least one or two others have had trouble with the bookmarklet, so hopefully, this gets you by, as I can't imagine it being a priority for Dave right now.

This may not be the proper Github project for this issue, but I think the Radio3 integration with Drummer is a great feature, so I think it makes some sense here.

jackbaty avatar Oct 14 '21 21:10 jackbaty

Just a quick add-on, in the above code some characters are encoded. In my version of Firefox what works is

javascript:(function(){window.open('http://radio3.io/?link='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)+'&description='+encodeURIComponent(document.getSelection()));})();

Also, it still doesn't work properly when you don't select any text. The title of the page becomes the description. I think there needs to be some check included to only include &description when there is some text selected?

frankmeeuwsen avatar Oct 15 '21 06:10 frankmeeuwsen

Thanks for the tweak, @frankmeeuwsen. I've never gotten my head around what needs to be encoded when editing bookmarklets. The encoding seems to magically change when copying and pasting.

The current behavior when no text is selected is actually how I prefer it, so for my use it's not broken :).

jackbaty avatar Oct 15 '21 10:10 jackbaty

Prior discussion of this issue here: https://github.com/scripting/Scripting-News/issues/180

andysylvester avatar Oct 15 '21 15:10 andysylvester

OK, picking up the thread here.

This is the R3 bookmarklet I have on my desktop computer.

javascript:(function()%7Bfunction encode (s) %7Bs %3D s.toString ()%3Bs %3D s.replace (new RegExp ("%25", "g"), " percent")%3Breturn (encodeURIComponent (s))%3B%7Dvar url %3D "http://radio3.io/%3F"%3Bvar link %3D "link%3D" %2B encode (location.href)%3Bvar title %3D "%26title%3D" %2B encode (document.title)%3Bvar desc %3D "%26description%3D" %2B encode (document.getSelection ())%3B window.open (url %2B link %2B title %2B desc)%3B%7D) ()

That is not what's on the Radio3 site. I basically stopped farting around with the site because as far as I knew no one was using the product, except for myself -- so I left everything alone, because I didn't want to break anything. Little did I know that over time it did break, anyway. That's the web for you. ;-)

Anyway I want to get your opinion on this code. Does it work for you?

scripting avatar Oct 19 '21 12:10 scripting

BTW, I found the source for the bookmarklet. Here's a screen shot.

image

scripting avatar Oct 19 '21 13:10 scripting

Yours seems to work for me, Dave.

jackbaty avatar Oct 19 '21 14:10 jackbaty

@jackbaty -- thanks.

there's a mistake there -- with the dev2.html -- that's old.

it should just be radio3.io.

another question -- are the docs you guys reading the this.how page?

if i update that page is that all i need to do?

scripting avatar Oct 19 '21 14:10 scripting

Yes, I was copying the bookmarklet from http://this.how/radio3/, so if that version was correct I would've been all set. Thanks!

jackbaty avatar Oct 19 '21 17:10 jackbaty

Here's the change note.

http://scripting.com/drummer/blog/2021/10/19/193400.html?title=radio3Bookmarklet

scripting avatar Oct 19 '21 19:10 scripting