From ef35c69c3817db9d9062603f1e7945dacb375f29 Mon Sep 17 00:00:00 2001 From: PHO Date: Thu, 29 Oct 2015 16:53:58 +0900 Subject: [PATCH] Auto commit by The Sugar System. --- IGNORE | 1 + .../_vimperator/plugin/amazon_simple_uri_js | 95 +++++++++++++++++++ .../_vimperator/plugin/minecraft-wiki_js | 43 +++++++++ dot-files/_vimperatorrc | 3 + 4 files changed, 142 insertions(+) create mode 100644 dot-files/_vimperator/plugin/amazon_simple_uri_js create mode 100644 dot-files/_vimperator/plugin/minecraft-wiki_js diff --git a/IGNORE b/IGNORE index f9d0b88..3a2167e 100644 --- a/IGNORE +++ b/IGNORE @@ -95,6 +95,7 @@ .lesshst .local .localized +.lsof_* .macports .macromedia .metacity/sessions diff --git a/dot-files/_vimperator/plugin/amazon_simple_uri_js b/dot-files/_vimperator/plugin/amazon_simple_uri_js new file mode 100644 index 0000000..e21c79a --- /dev/null +++ b/dot-files/_vimperator/plugin/amazon_simple_uri_js @@ -0,0 +1,95 @@ +// PLUGIN_INFO//{{{ +var PLUGIN_INFO = xml` + + amazon_simple_uri + Copy Amazon Simple URI. + シンプルなAmazon URIをクリップボードにコピーします。 + from_kyushu + 0.1 + GPL + 1.2 + 2.1 + https://github.com/vimpr/vimperator-plugins/raw/master/amazon_simple_uri.js + || + let g:amazon_asamashi = "hogehoge-22" +||< +と設定することにより、Amazon アソシエイトID(上の例ではhogehoge-22)をURLに追加します。 + + ]]> +`; +//}}} +// +(function() +{ + // URLを正規表現でチェックしてISBNっぽい10桁,13桁の数字と取り出す + function getIsbn(uri) + { + var regex = new RegExp("([0-9]{9,13}[0-9Xx])"); + var match = uri.match(regex); + var isbn = match[0]; + if (isbn.length == 13) + { + isbn = getIsbn10(isbn); + } + return isbn; + } + + // SSBのAPIを使ってISBNから書籍情報を取得 + function getBookInfo(isbn) + { + var uri = "http://stack.nayutaya.jp/api/book/"; + if (isbn.length == 10) + { + uri += "isbn10/" + isbn + ".json"; + } + else if (isbn.length == 13) + { + uri += "isbn13/" + isbn + ".json"; + } + var xhr = new XMLHttpRequest(); + xhr.open('GET', uri, false); + xhr.send(null); + if (xhr.status != 200) { + liberator.echoerr('false'); + return; + } + return window.eval('(' + xhr.responseText + ')'); + } + + //SSBのAPIから書籍情報を取り、そこからISBN10を取得 + function getIsbn10(isbn13) + { + var info = getBookInfo(isbn13); + return info.response.book.isbn10; + } + + commands.addUserCommand( + ['amazoncopy','asc'], + 'Copy Amazon Short URI', + function(args) + { + var asin = window.content.document.getElementById('ASIN'); + // ASINが取得できなかった場合 / Amazon以外の書籍情報ページから取得する場合 + if (asin == null) + { + asin = getIsbn(buffer.URL); + } + else + { + asin = asin.value + } + + var uri = "http://www.amazon.co.jp/dp/" + asin + "/"; + var asamashi = typeof liberator.globalVariables.amazon_asamashi == "undefined" ? '' : liberator.globalVariables.amazon_asamashi; + if (args == "+a") + { + uri += asamashi; + } + util.copyToClipboard(uri); + liberator.echo("[ASC] Copy to clipboard."); + } + ); +})(); diff --git a/dot-files/_vimperator/plugin/minecraft-wiki_js b/dot-files/_vimperator/plugin/minecraft-wiki_js new file mode 100644 index 0000000..83516c9 --- /dev/null +++ b/dot-files/_vimperator/plugin/minecraft-wiki_js @@ -0,0 +1,43 @@ +var INFO = xml` + + PHO + CC0 1.0 Universal + + +`; + +(function () { + +var base_URI = 'http://minecraft.gamepedia.com/'; + +function mcwiki(opts) { + if (opts.query) { + var URI = base_URI + '/index.php?search=' + encodeURIComponent(opts.query); + liberator.open(URI, opts.tab); + } + else { + liberator.open(base_URI, opts.tab); + } +} + +liberator.modules.commands.addUserCommand( + ['mcwiki'], + 'Search the Official Minecraft Wiki', + function (args) { + mcwiki({ + query: args.string.length > 0 ? args.string : null, + tab: args.bang ? liberator.NEW_TAB : liberator.CURRENT_TAB + }); + }, + { + bang: true, + argCount: '*' + }, + true +); + +})(); diff --git a/dot-files/_vimperatorrc b/dot-files/_vimperatorrc index f44a880..1fc1efb 100644 --- a/dot-files/_vimperatorrc +++ b/dot-files/_vimperatorrc @@ -36,6 +36,9 @@ command! -description="Way back the current page" wayback open javascript:(locat map ma :mr alc map mg :mr goo +" plugin/minecraft-wiki.js +map :mcwiki! + " Smokeping qmark p http://aria.cielonegro.org/cgi-bin/smokeping.cgi -- 2.40.0