Skip to content

Instantly share code, notes, and snippets.

Created September 5, 2012 04:58
What would you like to do?
VoodooPad Random Page Script Plugin
A script plugin to add an essential missing feature to the personal desktop
wiki VoodooPad: opening a random page.
Just hit the button in your Plugins menu to open a page randomly picked from
your current document. Every page has an equal probability of appearing;
independent of how many aliases it has. Also this plugin does not pick the
files you store in your VoodooPad document.
First of all make sure you have the most recent version of VoodooPad. I created
and tested this exclusively using VoodooPad Version 5.0.3. Due to some changes
in the plugin programming interface this plugin may require at least Version 5.
Now just copy the contents of Random Page.jstalk into an empty page of any
VoodooPad document and then hit Plugin -> JSTalk -> Save Page as JSTalk Plugin…
in your menu bar. Give it a descriptive name (like Random Page.jstalk), which
will appear in your Plugin menu from now on. After pressing the Save button,
you may delete the page you just created.
Expert users just copy Random Page.jstalk to ~/Application
Support/VoodooPad/Script Plugins and remember that the filename (without the
extension) will be the name of the new menu item in the Plugins menu.
function main(windowController, document) {
var titles = pageTitles(document);
Math.floor(Math.random() * titles.length)
function pageTitles(document) {
var pageTitles = [];
var page = 0;
for(key = 0; key < document.keys().length(); ++key) {
var item = document.pageForKey(
if(!isAlias(item)) {
pageTitles[page++] = item.displayName();
function isAlias(page) {
var uti = page.uti();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment