This Week's Sponsor:

Winterfest 2024

The Festival of Artisanal Software


Posts tagged with "bookmarklet"

Bookmarklet To Open Twitter Profiles In Tweetbot

Dave Bradford had one of the same problems I deal with on a daily basis:

While using mobile Safari on the iPhone I sometimes come across a Twitter account I’d like to follow or check out, to follow them I have to select the users handle from the URL, open Tweetbot, go to search, then copy the username into the search field.

It’s a minor annoyance, but those few seconds you spend copying and pasting add up over time. Dave made a bookmarklet to open Twitter profile pages as usernames in Tweetbot – it works on OS X too if you remove “mobile.” from the bookmarklet to work with desktop Twitter pages.

Get the code here.

Update: Phillip Gruneich also has a few bookmarklets that look cleaner and work with both Twitter and App.net.

Permalink

Command-C Browser Actions

Command-C

Command-C

When I’m writing on my iPad at home, there’s a chance I have my MacBook on my desk with either iTunes open (to check for app updates or playing music from iTunes Match/Radio) or MailMate running (because I’ve been having issues with Mail on the beta of iOS 7.1). It’s not uncommon for me to use a dual-monitor setup when writing, relying on my MacBook for Google searches and other reference material – effectively, I use it as a secondary display to my iPad when I’m working on articles that require a fair amount of research.

Since the release of Command-C, I’ve been using Danilo Torrisi’s utility to quickly beam text and URLs across all my devices, using Launch Center Pro actions to speed up the process. Command-C has excellent support for URL schemes – a boon to iPad users who fiddle with automation tricks to save time when working on iOS. I recently realized, however, that most of the content I share with Command-C is made of URLs from Safari, therefore I asked myself whether I could put together a solution to send URLs with one click from Safari without using an external app or keyboard shortcut. It was pretty clear from the beginning that I would end up with a bookmarklet, but I have to thank Danilo for providing the necessary guidance I needed to achieve the kind of workflow I wanted.

The bookmarklet is part made for myself, part proof of concept (as always) for others to iterate upon. It doesn’t only send URLs from Safari on another device with Command-C – it sends the webpage you’re currently viewing in Safari to another app on another device with Command-C.

Read more


Use WhatsApp’s URL Scheme with Drafts, Launch Center Pro, Or A Bookmarklet

WhatsApp

WhatsApp

I don’t use WhatsApp much[1], but when I saw the app’s documentation last night with a mention of the URL scheme, I thought I could play around with it a little bit.

The WhatsApp URL scheme is extremely basic and there’s one part that I can’t get to work. The scheme itself is, unsurprisingly, whatsapp:// – which you can use from Launch Center Pro if you simply want to launch WhatsApp. There are also parameters to do stuff with the URL scheme: text lets you pass along a (properly encoded) text message that will be automatically inserted in the compose field of the app; abid lets you specificy an “Address Book ID” to send a message to a specific contact.

The WhatsApp team explains:

Address book ID of contact to start a chat with. If contact with this ID has only one whatsapp-able phone number, application will open a conversation with that contact. If contact with this ID has more than one whatsapp-able phone numbers, application will present a menu with all phone numbers available for chat. If contact has no whatsapp-able phone numbers, or contact with this ID does not exist, or this parameter is missing, application will present contact picker listing all contacts available for chat via WhatsApp.

I thought that something like the following URL would have let me send the text message “Test” to my contact “Alex”:

whatsapp://send?abid=Alex&text=Test

But, in practice, I wasn’t able to get the abid parameter to work. I have tried with phone numbers, percent-encoded names and phone numbers, email addresses, but I can’t get WhatsApp to recognize the abid parameter I pass along, as the app continues to present a contact picker. Therefore, for the purpose of this post, I will show you how to send text to WhatsApp, choosing a recipient from the app’s built-in contact picker. If you manage to get abid to work, please let me know. Read more


Getting Safari’s Selection on iPad As HTML With A JavaScript Bookmarklet

I modified this bookmarklet posted by “Tim Down” on StackOverflow to send selected text from Safari to Drafts as HTML. The result is the following code:

javascript:(function(){var%20h="",s,g,c,i;if(window.getSelection){s=window.getSelection();if(s.rangeCount){c=document.createElement("div");for(i=0;i<s.rangeCount;++i){c.appendChild(s.getRangeAt(i).cloneContents());}h=c.innerHTML}}else%20if((s=document.selection)&&s.type=="Text"){h=s.createRange().htmlText;}window.location='drafts://x-callback-url/create?text='+(h);})()

So let’s say you want to grab the first paragraph in this post. Normally, in Safari for iPad you’d end up with the plain text fetched by window.getSelection:

This is a fantastic report with lots of data points for any developer trying to get their apps featured by Apple. Dave Addey’s highly interactive regional graphs and notes are very well done. Be sure to check out Dave Addey’s other works on his main blog.

As you can see, formatting and hyperlinks have been removed. With the bookmarklet above, you’ll receive the HTML version of the selection – which looks like this. But what’s the point?

My idea was that I wanted to be able to automate the process of capturing rich text from iOS’ Safari; I wanted to achieve the same kind of functionality I have on the Mac, where rich text can be dragged from Safari or Chrome and dropped into Evernote, preserving styles, hyperlinks, and images. I thought that combining HTML output with an Evernote Append action (with the “Send as Markdown HTML” option turned on) would let me receive valid HTML content in Evernote starting from an iOS workflow. And, for the most part, I was right, because the workflow does mostly work.

As it turns out, Evernote is extremely cautious with the HTML tags they accept, and the ones that are supported follow the XHTML guidelines as ENML is a superset of XHTML. This means that my bookmarklet will work for something as simple as selecting a single paragraph, but may easily fail with multiple selections, inline images, complex styles, and so forth. When that will happen, Drafts will return an error when trying to append HTML to Evernote; obviously, this will work just fine with Dropbox, which doesn’t care about the kind of text you’re using in your actions. Even better, this should work very well with Textastic’s just-released update that supports x-callback-url.

I guess the solution would be to build a Pythonista-based converter for Evernote-approved XHTML tags and place it between Safari and Drafts, converting HTML tags Evernote won’t like to compatible ones. If you’re interested, my birthday is August 10.

Permalink

Pushpin 2.0: A Powerful Pinboard Client for iPhone

Pushpin 2.0

Pushpin 2.0

On the first episode of The Prompt podcast, I chose Pushpin 2.0 as my weekly pick, and I thought the app deserved a mention here on the site as well.

In January, when I first reviewed Pushpin, I noted how the app didn’t look as good as Pinbook, another Pinboard client that, back then, didn’t support some of the power-user functionalities that were available in Pushpin. Many Pinboard clients have come out in the past few months; as MacStories readers know, my choices have always been Pinbook, Pushpin, and Pinbrowser – while these three apps were all made for Pinboard, each one of them had a peculiar feature that made it stand out. With Pushpin 2.0, I feel like the difference is now marginal, as the app takes important steps towards becoming the only Pinboard client you’d ever need to add, manage, and browse Pinboard bookmarks. Read more


Linked Posts with Drafts and Poster

When we announced a new format for linked posts last week, I hadn’t set up a proper workflow to create linked posts on the iPhone and iPad. Driven by annoyance, I put together a Drafts action and a bookmarklet to help me post links to WordPress with or without additional text and quotes.

Our linked posts use a custom field to link back to the original source and format the clickable titles that you see on the site. Tom Witkin’s Poster is my default app to publish posts on MacStories from iOS, and, fortunately, it has support for calling and assigning values to custom fields from the URL scheme. On the other hand, Agile Tortoise’s Drafts, my favorite app to chain multiple actions together, can launch custom URL actions differentiating between the first line of a note and everything else after it. That seemed like a good opportunity to separate my source URL from any possible text I wanted to add to a linked post. Read more


A Better Chrome To Safari Bookmarklet

pythonista

pythonista

In January, I tried to put together a bookmarklet to send the webpage currently open in Google Chrome for iOS to Apple’s Safari. That turned out to be a surprisingly complex effort as Google didn’t think offering an “Open In Safari” option would be a good idea, and the app’s URL scheme produced some interesting results when opening and closing Chrome.

I was reminded of the bookmarklet this morning by reader @CNWLshadow, and I realized that I never posted the solution I settled with. It consists of a browser bookmarklet and a Pythonista script, and it works with just one tap.

Read more


Chaining Multiple Apps Together with Drafts

A few weeks ago, I took a look at the automation possibilities opened by Drafts, Agile Tortoise’s multi-purpose text app. In the article, I mentioned how a bug prevented Drafts from “linking to itself” more than once:

Therefore, my idea for cross-posting was: I can link to Drafts itself, and if the first action is successful, I can link to Drafts itself again. Essentially, I wanted to leverage the built-in App.net and Twitter actions to avoid the use of any third-party app. Unfortunately, there’s a bug in the current version of Drafts that doesn’t make that kind of action work.

With an update to Drafts released yesterday, Greg Pierce has brought various improvements to the app, including support for more customizable timestamps and dates using strftime, date and time tags for file names and URL actions, and a new way to encode strings with curly brackets.

Seemingly minor, the option to more easily URL encode strings is actually a very welcome addition: like in the latest Mr. Reader, instead of forcing the user to encode a URL into a longer string, you can simply put a URL inside {{ }} and let Drafts take care of encoding it. It means I can now experiment with building more complex workflows that contain actions for more external apps and, more importantly, for “sequential” tasks in Drafts itself. Easier encoding means we construct URLs that will tell Drafts “do this, and then do that” in a single workflow.

Those who follow me on Twitter know that I’ve been trying since yesterday to see how many apps I could chain together in a workflow, mainly out of curiosity and as a “proof” of concept. First, I tweeted about a Mr. Reader -> Drafts -> Poster workflow that would take selected text from an article, convert its Markdown to HTML, and then send it to Poster; the workflow consisted of three apps chained together, but I knew I could try to accomplish something a bit more ambitious. I kept on experimenting with Drafts URLs, and eventually I managed to build a single workflow with 3 apps and 4 different tasks involved. I’m posting it here for two reasons: a) I believe it’s a quite useful workflow; and b) it can serve as an example of what Drafts can do when you understand how to properly link multiple apps together. Read more


Poster Adds Improved URL Scheme and 1Password Integration

Poster is my favorite iOS app to post articles to WordPress. I recently took a look at version 2.0 and the improvements developer Tom Witkin made to further streamline the app’s posting workflow. Today, Tom released another update that adds support for custom fields to the URL scheme and brings 1Password integration.

Like other apps have done in the past weeks, Poster now sports a 1Password button when setting up a new site that requires authentication. The button will take you directly to 1Password, searching for “wordpress” by default. Once you’ve found your login item, you can copy the password and go back to Poster. I believe this sort of non-forced integration is really nice and ultimately beneficial to the end user, as it makes using multiple apps for a single task less cumbersome. Read more