Bookmarklet to Toggle Google Accounts

I use Google Apps at work and also have a personal Google account for many other things. Switching between these accounts can be annoying, as can dealing with clicking on share links that open in the wrong account.

To get around this, I put together this bookmarklet that switches between two accounts automatically. You’ll need to be logged into both accounts at once in order for this to work.

To make it work, drag this bookmark to your address bar.

<a href=”javascript:%28function %28%29 %7B %09var newUser %3D 1%3B %09var newURL%3B %09url %3D window.location.href%3B %09var match1 %3D url.match%28%2F%5C%2Fu%5C%2F%28%5Cd%29%5C%2F%2Fi%29%3B %09var match2 %3D url.match%28%2Fauthuser%3D%28%5Cd%29%2Fi%29%3B %09var match3 %3D url.match%28%2F%5C%2Fb%5C%2F%28%5Cd%29%5C%2F%2Fi%29%3B %09var match4 %3D url.match%28%2F%5Ehttps%3A%5C%2F%5C%2Fdocs%5C.google%5C.com%5C%2F%28%5B%5E%5C%2F%5D%2B%29%5C%2Fd%5C%2F%2Fi%29%3B %09if %28match1%29 %7B %09%09console.log%28%27match1%27%29%3B %09%09if %28match1%5B1%5D %3D%3D 1%29 %7B %09%09%09newUser %3D 0%3B %09%09%7D %09%09newURL %3D window.location.href.replace%28%2F%5C%2Fu%5C%2F%5Cd%5C%2F%2Fi%2C “%2Fu%2F” %2B newUser %2B “%2F”%29%3B %09%7D %09else if %28match2%29 %7B %09%09console.log%28%27match2%27%29%3B %09%09if %28match2%5B1%5D %3D%3D 1%29 %7B %09%09%09newUser %3D 0%3B %09%09%7D %09%09newURL %3D window.location.href.replace%28%2Fauthuser%3D%5Cd%2Fi%2C “authuser%3D” %2B newUser%29%3B %09%7D %09else if %28match3%29 %7B %09%09console.log%28%27match3%27%29%3B %09%09if %28match3%5B1%5D %3D%3D 1%29 %7B %09%09%09newUser %3D 0%3B %09%09%7D %09%09newURL %3D window.location.href.replace%28%2F%5C%2Fb%5C%2F%5Cd%5C%2F%2Fi%2C “%2Fb%2F” %2B newUser %2B “%2F”%29%3B %09%7D %09else %7B %09%09newURL %3D window.location.origin %2B window.location.pathname%3B %09%09if %28window.location.search%29 %7B %09%09%09newURL %2B%3D window.location.search %2B “%26authuser%3D” %2B newUser%3B %09%09%7D %09%09else %7B %09%09%09newURL %2B%3D “%3Fauthuser%3D” %2B newUser%3B %09%09%7D %09%09newURL %3D newURL %2B%3D window.location.hash%3B %09%7D %09window.location.href %3D newURL %7D %29%28%29”>Toggle Google Account</a>

I’ve only tested this in Chrome, but it ought to work in other browsers. Also, if you have three or more accounts, this will just switch between the first two.

Written on July 31, 2019

A Better Keyboard

I’d heard a lot of complaints about how bad the 2015+ MacBook keyboards were. Well, for the first time, I’m using one daily, and I have to agree. I don’t think I’m slower typing on it (if anything, the short travel makes it pretty easy to pound out a sentence), but it’s harder on the fingers and just doesn’t feel “good.” So far no problems with stuck keys, but it’s only been a few weeks.

Of course, when I get home and break out my Chromebook, I’m immediately struck at how nice its keyboard is. Keys have short travel, so it still feels speedy, but are satisfyingly responsive and smooth feeling.

Here’s the thing… my Chromebook cost me about $350. This MacBook pro is, what, a $2,000 computer?

Just too bad. Apple’s put style way too far forward at the sake of a pleasant day-to-day experience. (And don’t even get me started on the touch bar, lack of a touch screen… I could go on.)

Written on April 9, 2019

Having fun with Jekyll

A new CMS is always a present. New toys, new things to learn…

So far, I’ve added full text search via client-side JS (didn’t know how good that could be!), “oranged” up the theme, and the usual array of troubleshooting to get analytics, 404s, and all that jazz working correctly. End result: this blog’s more functional than the Tumblr platform. (Sad.)

As I expected, Jekyll’s lack of a server-side CMS is troublesome, since it’s a multi-step process to post anything. I can’t just “share” from my phone to Tumblr. (Not that I ever did that anyhow!)

Unexpectedly, I’m really liking using git for content management and syncing of posts between devices. It’s fast, I have a huge amount of control… just really cool.

Next up is seeing about whether a node-red server fills in that critical automation gap so I can start wiring in IFTTT webhooks to get everyone playing nicely with one another.

Written on April 8, 2019

Changing CMSes Again!

Hello World!

Working on trying something new… static sites are all the rage, so I’m pimping things out with:

  • Jekyll
  • GitHub
  • Netlify
  • CodeAnywhere

That’s right, a full CI process, multiple virtual servers, and distributed source control for a blog that’s had one post since the end of 2016. (Two, counting this one!)

And you wouldn’t believe how much work it was to get this all working nicely on my Chromebook Plus, which is running on an ARM processor.

Oh, and yes, every download link is broken. That’s actually not entirely my fault - most were hosted on Google Drive and they killed the ability to share web server style links. If there’s an applet or script you want, email me.

Hey, a boy has to have a hobby…

Written on April 1, 2019

Email to app for an app with no web service (2Do)

I personally am a big fan of 2Do as a daily task manager. I’ve tried a lot of alternatives, but that’s always where I end up. But unlike most task managers these days, it’s app-only, there’s no web service. So if I want to use some of the great tools out there (like TaskClone, which is a killer tool for any hardcore Evernote junkie), I’m stuck. Sure, I can AppleScript some stuff on a Mac, but now that I’m moving more and more onto Chromebooks, that’s not such a great option.

Well, I do have one device that runs 2Do and is turned on pretty much all the time: My phone. Since I have an Android phone, 2Do’s iOS email-to-task won’t work for me, but Android’s nothing if not a deep bag of tricks, so by stringing together Tasker, Join, and Zapier, I have a fully functional email-to-2Do utility.


Read more... (2 minutes)
Written on November 28, 2018

My Keyboard Maestro Macros and AppleScripts I use the most

As one of the three readers of my blog, you’ve no doubt realized I’m on a bit of a Keyboard Maestro kick these days. I’ve been a KM user since 2010, a QuicKeys user before that, and a rabid AppleScripter before then. I’ve built up a tremendous library of scripts and macros in that time, many of which I’ve shared on this blog. However, of these macros, there’s a handful that have proven truly “sticky” and that I continue to expand upon and use on a daily or near-daily basis. I though my few readers might get more benefit from learning about these truly indispensable scripts and macros than the more esoteric mini-programs that I’ve posted here.

I haven’t posted all of these scripts and macros because most of them are fairly obvious in how they work, and enough have very specific settings for my networks, or even contain sensitive information (app tokens and such), that I didn’t want to go through the effort and “sanitize” them. But if you want to see any specific ones, sound off in the comments or bug me on the Keyboard Maestro forum and I’ll be glad to help you out.


Read more... (7 minutes)
Written on May 7, 2016

Fancy Keyboard Maestro Custom HTML Prompts

image

A library of Custom HTML Prompt macros with some CSS and JS to make them look pretty and Mac-like as well as have some interface functions that aren’t provided by the standard KM dialogs. 

Specifically:

  • A El-Capitan-style alert box with multiple buttons
  • A multiple checkboxes dialog to select multiple items from a pick-list
  • A type-ahead box to select from a pick-list (like a combo-box)

This requires a little bit of extra installation work. You’ll need to move the html-elements folder to ~/Library/Application Support/Keyboard Maestro. If you want it somewhere else, you can edit the variable in the macros themselves.

Download: Fancy HTML Prompts.zip (zip, 240312 bytes)

Written on April 9, 2016

Giphy Search as a Custom HTML Prompt Tech Demo for Keyboard Maestro

This macro takes a search term and gives a selection of gifs from Giphy to select from. Clicking on a gif will save its URL to the clipboard (suitable for pasting into Slack or your other chat tool of choice), or option-clicking will both save the URL and download the gif directly.

Doing this in Keyboard Maestro necessitated a few goofy (“goophy?”) things to make it work:

  • I had to rely on JavaScript to insert the content from the Giphy search results (stored as a KM variable) into the HTML prompt - Keyboard Maestro only lets you pre-populate form fields with macro values.
  • Again, JS events were required for selecting the gif (no surprise since they aren’t form fields), but I was able to use KM itself to check whether the option key was down to prompt a download.
  • For my scripting, I had to rely on a combination of JXA and plain-old AppleScript. JXA was a good choice for the Giphy querying - JavaScript does very nicely with JSON parsing and iterators compared to AppleScript; but JXA still can’t deal with alias paths and the Finder can’t handle POSIX paths - so just to be able to create a unique file name it required me to use old-school AppleScript.

Ultimately, this is a great example of how Keyboard Maestro can be used to build what is essentially a mini-application. There are certainly things that perform better or give more features, but as a toolkit to string together a lot of pieces and parts, it’s fantastic.

This also makes me want to see KM expand to include web services into its vast arsenal of capabilities. Consuming JSON or even permitting variables to be stored in JSON has some real potetial as well.

Download: Giphy Search.kmmacros.zip (zip, 9220 bytes)

Written on March 26, 2016

Preview Chrome in Marked

Working on editing some Markdown in Chrome for your blog? This Keyboard Maestro macro lets you preview what you’re writing in Chrome with Marked 2.

This only works with sites that use regular text areas or editable web content blocks. Sites and apps that rely on custom JavaScript or iframes will generally fail - this includes Tumblr, Google Docs, and Disqus to name a few.

Download: Preview current Chrome text field in Marked.kmmacros (kmmacros, 6621 bytes)

Written on January 18, 2016