Skip to content

Instantly share code, notes, and snippets.

@tily
Created June 21, 2009 13:56
Show Gist options
  • Save tily/133515 to your computer and use it in GitHub Desktop.
Save tily/133515 to your computer and use it in GitHub Desktop.
output minibuffer pin list as html file
// ==UserScript==
// @name OutputPinListCommand
// @namespace http://d.hatena.ne.jp/tily/
// @include *
// ==/UserScript==
// TODO: handle relative links
(function(){
if(!window.Minibuffer) return
function output_as_html(title, urls) {
var html = <html>
<head><title /></head>
<body><h1 /><ol /></body>
</html>
html.head.title += title
html.body.h1 += title
urls.forEach(function(url) {
html.body.ol += <li><a href={url}>{url}</a></li>
})
GM_openInTab('data:text/html;charset=utf-8,' + html.toXMLString())
}
window.Minibuffer.addCommand({
name: 'output-pin-list',
command: function() {
title = this.args[0] || 'untitled: ' + (new Date()).toLocaleString()
pins = window.Minibuffer.execute('pinned-or-current-link')
urls = pins.map(function(node){return node.href})
output_as_html(title, urls)
}
})
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment