Skip to content

Instantly share code, notes, and snippets.

@satyr
Created August 24, 2009 08:06
Show Gist options
  • Save satyr/173735 to your computer and use it in GitHub Desktop.
Save satyr/173735 to your computer and use it in GitHub Desktop.
Opens Midori-san in a new tab.
0,function(){{}
const URL = 'http://www.smbc.co.jp/midorisan/';
CmdUtils.CreateCommand({
name: 'midorisan',
description: 'Opens '+ 'Midori-san'.link(URL) +' in a new tab.',
author: 'satyr', license: 'MIT',
icon: 'http://www.smbc.co.jp/favicon.ico',
arguments: {object: noun_type_number, goal: /^\d+/},
execute: function({object: {data: from}, goal: {text: to}}){
var me = this;
if (to) me._open(from, +to);
else $.get(URL, function(h){
me._open(from, +/<div id="top">(\d+)/(h)[1]);
});
},
_open: function(f, t){
var page = ('data:text/html,<!--midorisan-->'+
'<base href="'+ URL +'images/"/><center>');
for(let i = f; i <= t; ++i)
page += '<img src="'+ i +'_t.jpg"/><br/><img src="'+ i +'.jpg"/><hr/>';
Application.activeWindow.open(Utils.uri(page));
},
});
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment