aboutsummaryrefslogtreecommitdiffstats
path: root/lookupDictionary.js
AgeCommit message (Collapse)Author
2010-04-24correct eijiro's xpathsend
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@37266 d0d07461-0603-4401-acd4-de1884942a52
2009-08-27Follow HEADanekos
for http://vimperator.org/trac/gitweb/?p=liberator.git;a=commit;h=f20c2b315bb05c2e88d0c672f07dc229cc9267d2 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@35099 d0d07461-0603-4401-acd4-de1884942a52
2008-11-17文字コード指定アリでのURLエンコードを正しく行えない ↵fifnel
具合修正 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@24027 d0d07461-0603-4401-acd4-de1884942a52
2008-11-15see http://fifnel.com/2008/11/14/1980/teramako
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@23788 d0d07461-0603-4401-acd4-de1884942a52
2008-10-24 * fixed regexes.drry
* added and fixed dictionaries. * et cetera. git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@22081 d0d07461-0603-4401-acd4-de1884942a52
2008-10-24* HTMLパースに失敗していたのを修正teramako
* goo辞書のXPath修正 * goo辞書のHTMLがUTF-8になったのに対応...できてないかも git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@22080 d0d07461-0603-4401-acd4-de1884942a52
2008-10-21liberator -> liberator.modulesjanus_wel
- buffer - commandline - commands - hints - ..etc コマンド追加時に使う addUserCommand の第 3 引数に指定する関数の第 1 引数が String から Object に変更したのに対応 - ldrize_cooperation_fetch_flv.js - lookupDictionary.js - matanico.js - nicontroller.js - nnp_cooperation.js - reading.js - youtubeamp.js migemo_hint.js で一時的にグローバルオブジェクト plugins を定義 応急処置なのであとで削る必要あり git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@21797 d0d07461-0603-4401-acd4-de1884942a52
2008-10-15namespaceの省略(vimperator CVS headと旧版との互換性維持のため)teramako
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@21395 d0d07461-0603-4401-acd4-de1884942a52
2008-10-06vimp CVS Headに追従(bang[!])の仕様変更に対して)teramako
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@20856 d0d07461-0603-4401-acd4-de1884942a52
2008-09-27liberator.globalVariables.lookupDictionary_site_definition ↵anekos
で、スクリプトを書き換えずに辞書を追加できるようにした。 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@20048 d0d07461-0603-4401-acd4-de1884942a52
2008-09-27add dictionary property to SITE_DEFINITION.janus_wel
remove the variable "g:lookupDictionary_dictionary". switch over dictionary by site definition. git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@20024 d0d07461-0603-4401-acd4-de1884942a52
2008-09-26add word suggestion feature by dictionary for Firefox spell checkjanus_wel
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@19995 d0d07461-0603-4401-acd4-de1884942a52
2008-09-21Fix:teramako
* indent * command arguments handling git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@19677 d0d07461-0603-4401-acd4-de1884942a52
2008-09-07- ↵teramako
文字化け対策にXMLHttpRequestのoverrideMimeTypeを用いてcharset付加 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@18935 d0d07461-0603-4401-acd4-de1884942a52
2008-04-07lang/javascript/vimperator-plugins/trunk/lookupDictionary.jsdrry
lang/javascript/vimperator-plugins/trunk/gmperator.js: * 空白を修整しました。 * ほか。 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@9102 d0d07461-0603-4401-acd4-de1884942a52
2008-04-07lang/javascript/vimperator-plugins/trunk/lookupDictionary.js:drry
* fixed a regexp. git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@9067 d0d07461-0603-4401-acd4-de1884942a52
2008-04-07lang/javascript/vimperator-plugins/trunk/lookupDictionary.js:drry
* typo を修正しました。 * インデントを修整しました。 * ほか。 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@9066 d0d07461-0603-4401-acd4-de1884942a52
2008-03-21lang/javascript/vimperator-plugins/trunk/xpathBlink.jsdrry
lang/javascript/vimperator-plugins/trunk/autoIgnoreKey.js lang/javascript/vimperator-plugins/trunk/copy.js lang/javascript/vimperator-plugins/trunk/lookupDictionary.js lang/javascript/vimperator-plugins/trunk/splitBrowser.js lang/javascript/vimperator-plugins/trunk/gmperator.js: * 消えたファイルを trunk にコピーしました。 * ほか。 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@8235 d0d07461-0603-4401-acd4-de1884942a52
2008-03-21lang/javascript/vimperator-plugins/lookupDictionary.js: 0.6pre対応版trapezoid
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@8233 d0d07461-0603-4401-acd4-de1884942a52
version: function() { return this.constants.VERSION; }, getURL: function() { return liberator.modules.buffer.URL; }, getTitle: function() { var title = $f('//title'); return title ? title.text.replace(/^\s+|\s+$/g, '') .replace(/\r\n|[\r\n\t]/g, ' ') : null; }, getSelected: function() { var selected = window.content.getSelection().toString(); return selected ? selected : ''; } }; liberator.modules.commands.addUserCommand(['reading'], "update Twitter's status to current page title, URL and comment", function(args) { try { let arg = args.string; // build post string ----- let post_string; // get value from global variable or set default let format = liberator.globalVariables.reading_format || '$SERVICENAME : $COMMENT "$TITLE" $URL $SELECTED'; let serviceName = liberator.globalVariables.reading_servicename || 'I\'m reading now'; let title_default = liberator.globalVariables.reading_title_default || 'no title'; let scraper = new Scraper; let title = scraper.getTitle() || title_default; let canonicalizedURL = canonicalizeURL(scraper.getURL()); // expand variable ( evaluate variable ? ) post_string = format.replace(/\$SERVICENAME/g, serviceName) .replace(/\$TITLE/g, title) .replace(/\$URL/g, canonicalizedURL) .replace(/\$SELECTED/g, scraper.getSelected()) .replace(/\$COMMENT/g, arg); // ':matanico!' display the evaluated format. if(args.bang) { liberator.modules.util.copyToClipboard(post_string, true); return; } // ready posting ----- // URI encode let parameter = 'status=' + encodeURIComponent(post_string); // get user account for Twitter let [user, pass] = getUserAccount(DOMAIN, POST_URL, null); // send status let req = new XMLHttpRequest(); if(req) { req.open('POST', POST_URL, true, user, pass); req.onreadystatechange = function() { if(req.readyState == 4) { if(req.status == 200) liberator.echo('Posted ' + post_string); else throw new Error('failure in posting status to Twitter. HTTP status code : ' + req.status); } }; req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); req.send(parameter); } } catch(e) { liberator.echoerr(e.message); liberator.log(e.message); } }, // complete logic is none. { bang: true, }, true ); // stuff functions function $f(query, node) { node = node || window.content.document; var result = (node.ownerDocument || node).evaluate( query, node, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ); return result.singleNodeValue ? result.singleNodeValue : null; } function $s(query, node) { node = node || window.content.document; var result = (node.ownerDocument || node).evaluate( query, node, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null ); var nodes = []; for(let i=0 ; i<result.snapshotLength ; ++i) nodes.push(result.snapshotItem(i)); return nodes; } function canonicalizeURL(url) { const PATHTRAQ_CANONICALIZE_URL_API = 'http://api.pathtraq.com/normalize_url2?api=json&url='; var req = new XMLHttpRequest(); req.open('GET', PATHTRAQ_CANONICALIZE_URL_API + encodeURI(url), false); req.send(null); if(req.status === 200) { let canonicalized = req.responseText.replace(/^"|"$/g, ''); return (canonicalized && canonicalized != 'undefined') ? canonicalized : url; } else { throw new Error(req.status + ' ' + req.statusText + "\n" + req.responseHeaders); } } // user account manager // from direct_bookmark.js // thanks to Trapezoid function getUserAccount(form, post, arg) { var user, password; try { let passwordManager = Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager); let logins = passwordManager.findLogins({}, form, post, arg); if(logins.length > 0) { [user, password] = [logins[0].username, logins[0].password]; } else { let promptUser = { value : '' }, promptPass = { value : '' }; let promptSvc = Cc["@mozilla.org/embedcomp/prompt-service;1"] .getService(Ci.nsIPromptService); let nsLoginInfo = new Components.Constructor("@mozilla.org/login-manager/loginInfo;1", Ci.nsILoginInfo, "init"); let ret = promptSvc.promptUsernameAndPassword( window, form, 'Enter e-mail address and password.', promptUser, promptPass, null, {} ); if(ret) { [user, password] = [promptUser.value, promptPass.value]; let formLoginInfo = new nsLoginInfo(form, post, null, user, password, '', ''); passwordManager.addLogin(formLoginInfo); } else { liberator.echoerr("account not found - " + form); } } } catch(ex) { liberator.echoerr("handled exception during getting username and password"); liberator.log(ex); } return [user, password]; } })(); // vim:sw=4 ts=4 et: