Monday, April 27, 2009

Ubiquity - Bugmenot command

I like to use BugMeNot when trying to access some websites which require registration, most frequently the New York Times.

Bugmenot has a bookmarklet, but it opens a new window, and is therefore slow, and you have to copy and paste login information yourself.

Ubiquity is a command line interface to various things for Firefox.

I've created a Bugmenot command for Ubiquity.

Simply execute bugmenot while viewing the desired login page, and the top-ranked Bugmenot entry will be populated and submitted.

If that login has expired, you can specify an entry number as a parameter, from the list of entries in the Ubiquity preview pane.

Get it at http://gist.github.com/102363.



Some code was borrowed from Onur Yalazı and Brandon Goldsworthy.

7/9/09 update: Updated to support Ubiquity's Parser 2. The old code is still available here.

Friday, January 2, 2009

Fix for Firefox’s Password Exporter Add-on

7/23/09 Update: Updated to be compatible up to Firefox 3.5.1.

1/8/09 Update: If you tried installing the .xpi and got “Firefox could not install the file at [...] because: Not a valid install package -207,” please see the revised download instructions below.


I like Firefox’s Password Exporter Add-on, but recently I noticed a bug with version 1.1 (released January 5, 2008) when importing into Firefox 3. Several entries return the following error:

'Can't add a login with both a httpRealm and formSubmitURL.' when calling method: [nsILoginManager::addLogin]


I’ve posted the .xpi at http://www.vicshih.com/files/password_exporter-1.1-fx_tb-formSubmitURL-fix.xpi (90.1KB).

Right-click and Left-click this link, which should prompt Firefox to download to your machine. My web page does a redirect, so right-clicking directly actually saves an intermediate web page, which is not what you want. If in doubt, make sure file size is correct. Drag to a browser window to install.

Here’s the diff, in case you are queasy about installing my unsigned version.

Within the file chrome/content/passwordexporter.jar, in the file content/pwdex-loginmanager.js,


540,541c540,549
<
< var bogusLoginInfo = new nsLoginInfo(entries[i].hostname, 'http://passwordexporter',
---
> var doModify = false;
>
> var formSubmitURL = entries[i].formSubmitURL;
>
> if (formSubmitURL) {
> formSubmitURL = '';
> doModify = true;
> }
>
> var bogusLoginInfo = new nsLoginInfo(entries[i].hostname, formSubmitURL,
548c556
< loginManager.modifyLogin(bogusLoginInfo, entries[i]);
---
> if (doModify) loginManager.modifyLogin(bogusLoginInfo, entries[i]);

Tuesday, November 4, 2008

Shortcut to Toggle Firefox Bookmarks Toolbar (like Chrome)

One of the things I've really liked about Google Chrome is the ability to toggle the bookmarks toolbar with a quick Ctrl+B. I hunted around for this ability in Firefox but it took a little finagling -- here's the how-to:

  • Install Keyconfig.

  • Open Keyconfig's configuration dialog via "Tools | Keyconfig..." or Ctrl+Shift+F12.

  • If you want to use Ctrl+B to toggle the Bookmarks Toolbar, first disable the default association to "Bookmarks" by selecting it and clicking the "Disable" button.

  • Click the "Add a new key" button and fill out the form using the following:

    • Name:   Toggle Bookmarks Toolbar

    • Code:
      var b = document.getElementById('PersonalToolbar');
      b.collapsed = !b.collapsed;


  • Click "OK."

  • Select your new key, select the text field, type your desired shortcut (Ctrl+B, for example), and click "Apply."

Your shortcut will be active in the next window opened. Yay nerdiness!

Another key I've added is a shortcut to toggle the status bar. Here's the code:
var s = document.getElementById('status-bar');
s.hidden = !s.hidden;
Enjoy!

Saturday, April 12, 2008

Todoist Sidebar - Firefox Add-On

Note: please see the latest update.

I recently switched from Google Notebook to Todoist for my to-do lists. I'd searched a while for a list manager that could do hierarchical tasks, and Todoist looks like the only one that does, at least for free. It does hierarchical projects too, in fact.

One hack I saw on their site described a way to load Todoist into Firefox's sidebar, basically by bookmarking a simplified view of the site and checking "Load this bookmark in the sidebar." Nice!

My joy soon soured though, when I noticed that adding a task has the side-effect of loading the Todoist website into the main browser window, browsing over whatever site you already have in the current tab. Not so nice.

Plus, I don't like the fact the button to open the sidebar (really just a bookmark) doesn't toggle -- to close the sidebar, you have to mouse all the way over to the sidebar's close button! Ridiculous! And though you can define a keyword for the bookmark which allows easy access through the address bar, there's no way to define a keyboard shortcut to hide the sidebar.

So, I put together a Firefox add-on which solves these problems, which I have creatively christened Todoist Sidebar.

Some perhaps non-obvious things to note:

  • Left-click the toolbar button to toggle the Todoist sidebar.
  • Middle-click the toolbar button to open Todoist in a new tab.
  • The default keyboard shortcut is Alt+Shift+2 on Windows and Linux, and Cmd+Shift+2 on the Mac.
  • The keyboard shortcut can be customized by modifying the string values
    todoist-sidebar.key and todoist-sidebar.modifiers in about:config, according to Mozilla's XUL:key specification. A Firefox restart is required for the changes to take effect. Setting either of these values to blank disables the keyboard shortcut.

All of this will probably be moot once Google continues their world conquest by rolling out their Calendar tasks implementation. But hey, it will be fun while it lasts...

Right now the add-on is hosted in the Firefox add-on sandbox.


10/15/08 update: Okay, Amir, the creator of Todoist, contacted me a bit ago all the way from Denmark to collaborate on the Todoist Sidebar, and he has updated it and now maintains it on the Todoist website! He blogged about it at http://amix.dk/blog/viewEntry/19333. Please go there to install. Woohoo!

5/15/08 update: Hm, it seems to still exhibit the naughty toggle behavior described in the comments on initial install. Restarting Firefox makes the problem go away. I'll look into this at some point. Lame!

4/28/08 update: Version 1.0.2 fixes the previously mentioned bug where any key press triggers the sidebar. Also the default key accelerator is now Alt+Shift+2 for Windows and Linux, and Cmd+Shift+2 for the Mac.

4/26/08 update: Please note that currently there is a bug with the default installation where every key press toggles the sidebar (see comments). This is due to my incorrectly implementing the default shortcut key. Also, the intended default is a bit problematic because it tends to interfere with the Tools menu accelerator.

I plan to change the default to Alt+Shift+2 (Cmd+Shift+2 on the Mac) when I get the chance. In the meantime, you can do this yourself by setting todoist-sidebar.key to "2" and todoist-sidebar.modifiers to "alt shift" for Windows/Linux or "accel shift" for the Mac in about:config.

4/24/08 update: Please note that some users are experiencing behavior where every key they type (or some subset) toggles the sidebar (see comments). This may possibly be remedied by fiddling with the todoist-sidebar.modifiers setting in about:config. Please be patient and I'll look into this shortly.

Tuesday, April 8, 2008

Move to Trash from the Mac Command Line

I was about to make a lengthy comment to a post on Life Hacker and decided to put most of it here instead. That site is seriously starting to take over my life.

A while back I wrote this shell function to be able to move files to the trash from the command line on my Mac, rather than condemning them to oblivion with no chance of return. This is in my .profile.

It's a little hairy looking but it does the job. Note that it attempts to append names with a date stamp if a file/directory with that name already exists in the trash, just as the Finder does.
function del() {
while [ -n "$1" ]; do
if [ ! -e "$1" ]; then
echo "'$1' not found; exiting"
return
fi

local file=`basename -- "$1"`

# Chop trailing '/' if there
file=${file%/}

local destination=''

if [ -e "$HOME/.Trash/$file" ]; then
# Extract file and extension
local ext=`expr "$file" : ".*\(\.[^\.]*\)$"`
local base=${file%$ext}

# Add a space between base and timestamp
test -n "$base" && base="$base "

destination="/$base`date +%H-%M-%S`_$RANDOM$ext"
fi

echo "Moving '$1' to '$HOME/.Trash$destination'"
\mv -i -- "$1" "$HOME/.Trash$destination" || return
shift
done
}

alias rm='del'
An interesting side-effect is that
rm <directory>
works as well, which is a little uncanny because ordinarily either rmdir <directory> (for an empty directory) or rm -rf is required.

2/23/10 update: Handle case where rm options are mistakenly specified.

7/4/08 update: Fixed problem when removing file names containing spaces.

Monday, April 7, 2008

Apologies

Sorry, I can't get enough of reading my own type (and corrections). I replied to SonOfPethuel's blog.