Skip to content

Instantly share code, notes, and snippets.

@dlenski
Last active September 5, 2024 19:12
Show Gist options
  • Save dlenski/e598197774666d440503d5168eefed31 to your computer and use it in GitHub Desktop.
Save dlenski/e598197774666d440503d5168eefed31 to your computer and use it in GitHub Desktop.
Bookmarklet to copy current page title as a rich-text formatted link
@Vaisakhkm2625
Copy link

wow trick is nice, you are making a popup window because doc.execCommand("copy") cannot run from bookmarklet right

@dlenski
Copy link
Author

dlenski commented Sep 21, 2022

@Vaisakhkm2625, no. I am making the popup window so that the URL and title can be customized.

@RyanAtSnapLogic
Copy link

Hi @dlenski - Loving the bookmarklet, but would love to remove the popup window as I have no need to customize the link. I tried editing the code, but can't figure it out. Are you able to help?

https://gist.github.com/RyanAtSnapLogic/969457e51092cc040dfb4f5f79a4aa3a

@dlenski
Copy link
Author

dlenski commented Jan 26, 2024

would love to remove the popup window as I have no need to customize the link. I tried editing the code, but can't figure it out.

@RyanAtSnapLogic, what have you tried so far? What is or isn't working, specifically?

https://gist.github.com/RyanAtSnapLogic/969457e51092cc040dfb4f5f79a4aa3a

There are no differences between the current contents of that Gist and this one. 🤷‍♂️

@skehlet
Copy link

skehlet commented Sep 4, 2024

Thanks for this very useful bookmarklet! However recently Brave has been crashing every time I use it. I found changing those nulls on line 4 to empty strings ("") stop the crashing and make it work for me again. Granted Brave shouldn't crash on something like this, but I got the idea to try empty strings from the MDN docs on window.open.

@dlenski
Copy link
Author

dlenski commented Sep 4, 2024

I found changing those nulls on line 4 to empty strings ("") stop the crashing and make it work for me again.

Interesting, thanks @skehlet. It crashes the tab??

Per those docs, should the second parameter (target) be set to "_blank" rather than ""?

I've updated it accordingly. Does that work for you?

@skehlet
Copy link

skehlet commented Sep 5, 2024

Interesting, thanks @skehlet. It crashes the tab??

It does! The whole application actually. Only in the last version or two however.

Per those docs, should the second parameter (target) be set to "_blank" rather than ""?

I've updated it accordingly. Does that work for you?

Yes, "_blank" is working great! Tested your updated version above exactly and it's working great on Brave
Version 1.69.162 Chromium: 128.0.6613.120 (Official Build) (arm64).

Edit: and verified without this change, it still crashes, even on today's update! ☠️

Thanks again!

@dlenski
Copy link
Author

dlenski commented Sep 5, 2024

Interesting, thanks @skehlet. It crashes the tab??

It does! The whole application actually. Only in the last version or two however.

Welp, good to know that there's an easy remotely-exploitable snippet of JavaScript that will crash https://github.com/brave/brave-browser 😝

(^attn @brave, if it hasn't been reported already)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment