My first vimperator script

I wrote my first vimperator plugin script last night. While browsing any of my blog posts I can now type :manage and Firefox opens the "edit" URI found in the page's head (a concept ripped off from AtomPub).

/*
 * Opens the URI of the first link in the document with rel="edit" in the same
 * tab.
 *
 * Usage:
 *   :manage
 *
 * @author Sean Gillies (sean.gillies@gmail.com)
 * @version 0.1
 */

commands.add(["manage"],
  "Open document's edit URI",
  function(args) {
    var documentNode = window.content.document;
    var editNode = documentNode.evaluate(
                    '//link[@rel="edit"]',
                    documentNode,
                    null,
                    XPathResult.FIRST_ORDERED_NODE_TYPE,
                    null
                    ).singleNodeValue;
    var editURI = editNode.getAttribute("href");
    liberator.open(editURI, null, true);
  }
);

Comments

Re: My first vimperator script

Author: jachym

Yeah, vimerator rulez! Imho it is much better, than this strange ubiquity thing...