Created
June 21, 2009 13:56
-
-
Save tily/133515 to your computer and use it in GitHub Desktop.
output minibuffer pin list as html file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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