From b7714e26267e5932f07c069bba67cea5219efd94 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Tue, 24 Jan 2012 10:55:13 +0900 Subject: [PATCH] add pref about instapaper.ks.js --- _keysnail.js | 57 +++++----------------------------------------------- 1 file changed, 5 insertions(+), 52 deletions(-) diff --git a/_keysnail.js b/_keysnail.js index 8a0941e..b6f06d0 100644 --- a/_keysnail.js +++ b/_keysnail.js @@ -192,6 +192,7 @@ ext.add('auto-install-plugins', function(ev, arg){ 'https://github.com/tkosaka/keysnail-plugin/raw/master/nicontroller.ks.js', 'https://raw.github.com/10sr/keysnail-plugin/master/shiitake.ks.js', 'https://raw.github.com/10sr/keysnail-plugin/master/dig-url.ks.js', + 'https://raw.github.com/10sr/keysnail-plugin/master/instapaper.ks.js', ]; function inst(a){ @@ -421,54 +422,6 @@ ext.add("if-mth-exist", function() { if (MultipleTabService === undefined) display.echoStatusBar("mth not exist."); },'if mth exist'); -//////////////////////// -// instapaper -ext.add("instapaper-add-this-page-and-close",function(){ - var url = window.content.location.href; - var title = window.content.document.title; - var tab = gBrowser.selectedTab; - var username = "8slashes+instapaper@gmail.com"; - var password = ""; - var passwordManager = (Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager)); - var logins = passwordManager.findLogins({}, "http://www.instapaper.com", "", null); - for (var i = 0; i < logins.length; i++) { - if (logins[i].username == username) { - password = logins[i].password; - break; - } - } - var comment = ""; - // prompt.read("Instapaper comment:",function(cm){ - // if(cm){comment = cm;} - // }); - display.echoStatusBar("Instapaper: adding " + url + "..."); - util.httpPost("https://www.instapaper.com/api/add", - {"username" : encodeURIComponent(username), - "password" : password, - "url" : encodeURIComponent(url), - "title" : encodeURIComponent(title),}, - function (xhr) { - display.echoStatusBar(xhr.status); - if (xhr.readyState == 4 && xhr.status == 201) { - // var title = decodeURIComponent(xhr.getResponseHeader("X-Instapaper-Title")); //超文字化けする - try { - Components.classes['@mozilla.org/alerts-service;1']. - getService(Components.interfaces.nsIAlertsService). - showAlertNotification(null, "Instapaper", "Page " + title + " added successfully", false, '', null); - } catch(e) { - // prevents runtime error on platforms that don't implement nsIAlertsService - } - display.echoStatusBar("Instapaper: adding " + url + "...done."); - gBrowser.removeTab(tab); - } else{ - display.echoStatusBar("Instapaper: Something wrong has happended!"); - if (window.loadURI) { - loadURI("javascript:function%20iprl5(){var%20d=document,z=d.createElement('scr'+'ipt'),b=d.body,l=d.location;try{if(!b)throw(0);d.title='(Saving...)%20'+d.title;z.setAttribute('src',l.protocol+'//www.instapaper.com/j/mt8YO6Cuosmf?u='+encodeURIComponent(l.href)+'&t='+(new%20Date().getTime()));b.appendChild(z);}catch(e){alert('Please%20wait%20until%20the%20page%20has%20loaded.');}}iprl5();void(0)"); - } - } - }); -},'instapaper add page and close tab when done without error.'); - //////////////////////// //検索 ext.add("query-then-engine", function () { @@ -725,10 +678,6 @@ key.setViewKey('a', function (ev, arg) { allTabs.open(); }, 'alltabs.open'); -key.setViewKey('I', function (ev, arg) { - ext.exec("instapaper-add-this-page-and-close", arg, ev); -}, 'instapaper add page', true); - key.setViewKey('', function (ev) { goDoCommand("cmd_scrollPageUp"); }, '一画面分スクロールアップ'); @@ -765,3 +714,7 @@ key.setViewKey('C', function (ev, arg) { key.setEditKey('C-', function (ev) { command.walkInputElement(command.elementsRetrieverTextarea, true, true); }, '次のテキストエリアへフォーカス'); + +key.setViewKey('I', function (ev, arg) { + ext.exec('instapaper-post-page-with-comment', arg, ev); +}, 'post page and comment', true);