Generate a Microsummaries Generator
microsummarygenerator.user.js - Install Greasemonkey User Script.
Among the many new features of Firefox 2.0, there is one called Microsummaries. Also known as "Live Titles", which I think more accurately describes what it's all about: a bookmark that shows the latest key information from the target website.
The live bookmark feature can be created by the site owner, by adding a specific link to the current web page. Or by anyone else, by defining a simple XML file around an XPath query, to select the relevant headline element. This XML file is called a Microsummaries Generator.
Now figuring out the whole XPath string can be a annoying task, especially counting the number of nested divs, table rows and such. To alleviate this, Greasemonkey comes to the rescue with the microsummarygenerator.user.js user script.
Quick walkthrough
Steps to generate the Generator XML:
- Open the desired page in Firefox (e.g. slashdot.org)
- In Firefox, select menu Tools / User Script Commands / Generate Microsummary Generator
- Page elements will display a green outline when hovering over them with your mouse
- Click the headline (or whatever) you're interested in
- The XPath expression to select the clicked element is shown in a floating panel (see example below)
- Elements with an ID attribute are selected, but can be deselected if a location path would be more appropriate
- Click the OK button, a dialog will show the text content of the selected element, asking for confirmation
- If you're happy, click OK and the generator XML will be opened in a new Firefox Tab.
- Copy all of the Tab's content (or save it directly) to a file named something appropriate, e.g.
slashdot.xml
Example XPath selector panel
Installing the generator XML
This is less simple in Firefox 2.0b1, could not erally find an option for easy installation of the Generator XML. However, the following appears to work:
- Find your Firefox Profile folder for the active profile
- There exists a folder, named
microsummary-generators - Copy the XML file you just created over to this directory
- Restart Firefox (yes, I'm sorry!)
- Re-open the target website
- When you create a bookmark, you should get the option to add a "Live Title", based on the generator you just added.
Example, for slashdot.org (talking about terrible html markup...), after selecting the top headline, the following XML is generated:
<?xml version="1.0" encoding="UTF-8"?>
<generator
xmlns="http://www.mozilla.org/microsummaries/0.1"
name="Microsummary for Slashdot: News for nerds, stuff that matters">
<pages>
<include>^http://slashdot\.org/</include>
</pages>
<template>
<transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
<output method="text"/>
<template match="/">
<value-of select="normalize-space(string(//div[@id='articles']/div/div/div/h3/a))"/>
</template>
</transform>
</template>
</generator>
Greasemonkey 0.6.4 and Firefox 2
You can not install the current version (0.6.4) into Firefox 2.x, however, there's a work around. Head over to Greasemonkey for Firefox 2.0 beta.
Changelog
Version 1.10 - improvement: user interface to choose between using an element's ID as start point, or simple XPath components Version 1.02 - fix: escape chars in title (now for real) - fix: use ID attribute if selected element has one - enhancement: stop events after generating XML TODO: user interface to choose between ID's or absolute XPath Version 1.01 - fix: escape chars in title Version 1.00 - initial release
About Greasemonkey
Greasemonkey is a Firefox extension, which can change web pages by applying cleverly crafted user scripts after they are loaded in the browser.
Tip! Greasemonkey Hacks by Mark Pilgim.
More Greasemonkey User Scripts
For more, and a couple of Greasemonkey resources, see Greasemonkey User Scripts.

