You’re browsing Safari and find a Twitter profile that sparks your interest. You visit it and get a prompt to install the Twitter official app. You may have it, however, chances are that if you’re reading this, you use Tweetbot. You memorize the Twitter handle, open Tweetbot, tap search, type the user name and you’re finally there. What if we could build a bookmarklet for this?
Most of that bookmarklet is straightforward, what you may want to know is that, while in a Twitter user page,
location.pathname grabs the handle preceded with a slash. If you're checking my Twitter user, it would send
/Pgruneich to Tweetbot. The slash allows us to skip the one after
user_profile in Tweetbot's url scheme.
But what if you want to go straight to a mention to the user? You can't mention with a slash, so we're going to skip that.
I bet you're already have some url encoded characters on the top of your head, so you can identify the at sign (%40). But what about that
substring(1)? We're telling the parameter to start our pathname from the index 1, remember it starts counting in 0, so our index 0 is the slash, meanwhile our index 1 is the first character from the user handle.
But what about some App.net love? We're just modifying the url scheme. You can't automatize to open a profile in Riposte because it requires the user's numeric ID. You can, however, still jump straight to the mention:
Felix is a little more flexible and supports the user handle with the '@' prefix. You can open a profile in Felix with this bookmarklet:
Or mention the user with:
But you don't want to clutter your bookmarks with all these, you may prefer a Launch Center Pro approach.