Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Personally, I prefer bookmarklets over extensions and Tampermonkey.

They work the same on Desktop, Android and iOS. So I can write my bookmarklet once and use it everywhere. Without installing anything. I also like that bookmarklets only kick in when you click on them. Although some might find that too much work, it feels natural to me. It is already in my muscle memory, to click an "Increase Fontsize" bookmarklet when I start to read through a thread on Hacker News on a mobile device, for example.



Wait, how do you use a bookmarklet like that on mobile Firefox? I have two that do this:

https://web.archive.org/web/submit?url=%s

javascript:void(location.href='http://web.archive.org/save/'+document.location.href)

But neither of them work on mobile because it opens a new tab first before evaluating the bookmarklet.


For the few I have on FF Android, create the bookmarklet as normal, give it a name, and also give it a "keyword" string.

Then, when you want to execute a bookmarklet on the current page, pull down to get to the URL bar (if it is hidden) and start typing the "keyword" string into the url bar. After a few characters the "suggestions" list should show the bookmarklet entry, when it does, tap on the entry and the bookmarklet will execute on the current page.

I've not been able to find a way to "open" a list of bookmarklets to pick from, other than using keyword search via the URL bar, so this does also require remembering the "keywords" for each to be able to access them.


That doesn't work for me at all. If I type the keyword, it doesn't show up in the URL suggestions. And it doesn't activate when I push go.

But mg also says that it works, so I wonder what's wrong with mine.


Is that void(...code...) syntax a good way to execute bookmarks? Also, your code is not urlencoded?

I use javascript:(function(){...code...})() and urlencode the whole thing.

I maintain this bookmarklet editor to easily convert code to bookmarklets:

https://www.gibney.org/bookmarklet_editor


It's been sitting around a long time and I don't remember where I got it from. Thanks for the link though.


You're welcome.

By the way, in Chrome on Android, you can't execute bookmarklets from the bookmark menu. You need to give the bookmarklet a name. Say "Upsize". Then when you are on the page where you want to increase the font size, type "up" in the url bar and click on "Upsize" in the suggestions. Might be the same in Firefox?


I tried this in firefox for android and it did not work. What gets opened instead is a google search for "javascript:(function()...".

Firefox used so be super useful on Android, but since its redesign almost all its customizability has been gone. So sad.


I just tried it on Firefox on Android, and for me it works.

In fact, it works both ways:

I can click on "bookmarks" and then on the bookmarklet, and it gets executed on the current page.

I can also start typing the bookmarklets name and then click on it in the suggestions. It then also gets executed on the current page.


Thanks! Unfortunately, bookmarklets just doesn't seem to work on iOS... :( I tried using your bookmarklet editor to see if it helped, and the resulting bookmarklets didn't work in iOS Safari nor iOS Firefox.

oh well... Wish I had found your bookmarklet editor when I was trying to use them on Android before!


Wait… it works in iOS Safari by tapping on the bookmarklet icon in the Bookmarks panel or under Favourites. Can’t get it to work in iOS Firefox tho.


Nice! Bookmarked :)


The benefit you say that bookmarklets have is in fact also the biggest drawback of bookmarklets as well - that you have to manually click on them - and you can't press that button in a loop like a script can do :). Personally for me userscripts are great - as instead of using tens of extensions I use one userscript manager and write many of these scripts myself - so the trust factor is always there.


Do bookmarklets still work on iOS? I wanted to try them but I found this post:

> Apple no longer allows running JavaScript in either the Mobile Safari address bar or as a mobile Safari bookmark.

https://discussions.apple.com/thread/253547618


Yes, they work on iOS.

Most browsers don't allow JavaScript in the address bar anymore.

But in bookmarks, all browsers allow it.


Thank you, I will start collecting bookmarks!


Thanks, I had forgotten this even existed. I was looking for something like this to perform unit conversions on a website.

Edit: And without giving excessive permissions to an extension.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: