Some hints (pun not intended).
Adding a new extended hint mode:
- You can define the mode with the
hints.addMode
function.
- You can set the pattern to add hints for with the
eht
option, which takes an XPath selector. (In Pentadactyl you can also use CSS selectors, but I'm not sure about Vimperator - there's no mention of them in the help pages)
Here's an simple example I use on Jisho.org to jump to the information page for a kanji using ;k.
js set eht+=[k]:span[class=text]
hints.addMode('k','open kanji details',function(e) { liberator.open(decodeURIComponent("http://jisho.org/search/" + e.textContent + "%2523kanji")); });
Matching a regex:
I'm not sure if Vimperator uses XPath 1.0 or 2.0, or even if it allows the full power of XPath expressions. I've only tried very simple expressions myself. XPath 1.0 doesn't allow regexes (so you'd have to make do with the functionality it provides). However, XPath 2.0 has regex support. So you might be able to use them. (I want to look into this myself sometime.)
Launching a script:
You can do this with the :!
command. Arbitrary "ex" commands can be launched from JS using liberator.execute()
, so to launch a shell script, you can pass a function like this into hints.addMode
:
function(e) { liberator.execute("!~/bin/script " + e.textContent) }
Note on Pentadactyl.
Everything here applies equally to Pentadactyl, except in the JS API, you have to replace liberator
by dactyl
.
I'll try to look at this some more later.