aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorteramako2011-03-25 21:58:50 +0900
committerteramako2011-03-25 21:58:50 +0900
commit55c19e9b6af78c522148c43ee658e5189fce6ded (patch)
tree4de81c44226c55d52ca831c71b10c6d307d7474f
parent30c4c6b5598cf75463f2bf60794b4df1db5efbc6 (diff)
downloadvimperator-plugins-55c19e9b6af78c522148c43ee658e5189fce6ded.tar.bz2
もやは使われていないよね
-rw-r--r--feedSomeKeys_2.js379
-rw-r--r--jetpackHack.js177
-rw-r--r--twitter.js323
-rw-r--r--xpathBlink.js104
4 files changed, 0 insertions, 983 deletions
diff --git a/feedSomeKeys_2.js b/feedSomeKeys_2.js
deleted file mode 100644
index b701943..0000000
--- a/feedSomeKeys_2.js
+++ /dev/null
@@ -1,379 +0,0 @@
-let INFO =
-<plugin name="feedSomeKeys" version="2.2.3"
- href="http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/feedSomeKeys_2.js"
- summary="Feed some defined key events into the Web content"
- xmlns="http://vimperator.org/namespaces/liberator">
- <author email="teramako@gmail.com">teramako</author>
- <license href="http://www.mozilla.org/MPL/MPL-1.1.html">MPL 1.1</license>
- <project name="Vimperator" minVersion="2.3"/>
- <p>
- keyイベントをWebコンテンツ側へ送る事を可能にするプラグイン。
- GmailやGreasemonkeyでキーを割り当てている場合に活躍するでしょう。
- </p>
- <item>
- <tags>:fmap :feedmap</tags>
- <spec>:f<oa>eed</oa>map <oa>-depath=<a>frameNumber</a></oa> <oa>-vkey</oa> <oa>-event=<a>eventName</a></oa> <oa>lhs<oa>,<oa>frameNumber</oa>rhs</oa></oa></spec>
- <description>
- <p>
- Feed to the Web contents <oa>lhs</oa>.
- If specified <oa>rhs</oa>, feed <oa>rhs</oa> key events when hit <oa>lhs</oa>.
- </p>
- <p>The following options are interpreted.</p>
- <dl>
- <dt>-v<oa>key</oa></dt>
- <dd>仮想キーコードでイベントを送る</dd>
- <dt>-e<oa>vent</oa></dt>
- <dd>
- 以下の<oa>eventName</oa>が設定可能
- <ul>
- <li>keypress (default)</li>
- <li>keydown</li>
- <li>keyup</li>
- </ul>
- </dd>
- </dl>
- </description>
- </item>
- <item>
- <tags>:fmapc :feedmapclear</tags>
- <spec>:fmapc</spec>
- <spec>:feedmapclear</spec>
- <description>
- <p>clear fmap entries</p>
- </description>
- </item>
- <h3 tag="combine-fmap-with-autocmd">Combine fmap with autocmd</h3>
- <code><ex>
-:autocmd LocationChange .* fmapc
-:autocmd LocationChange 'example\.com' fmap a b c
- </ex></code>
- <h3 tag="fmap-examples">fmap examples</h3>
- <p>
- At first, you need to write following code
- <code>:autocmd LocationChange .* :fmapc</code>
- </p>
- <h4 tag="fmap-example-gmail">Gmail</h4>
- <code>
-:autocmd LocationChange 'mail\.google\.com/mail' :fmap c / j k n p o u e x s r a # [ ] z ? gi gs gt gd ga gc
- </code>
- <h4 tag="fmap-example-ldr">Livedoor Reader</h4>
- <code>
-:autocmd LocationChange 'reader\.livedoor\.com/reader' :fmap j k s a p o v c &lt;Space> &lt;S-Space> z b &lt; >
- </code>
- <h4 tag="fmap-example-googlereader">Google Reader</h4>
- <code>
-:autocmd LocationChange 'www\.google\.co\.jp/reader' :fmap! -vkey j k n p m s t v A r S N P X O gh ga gs gt gu u / ?
- </code>
- <h4 tag="fmap-example-googlecalendar">Google Calendar</h4>
- <code>
-:autocmd LocationChange 'www\.google\.com/calendar/' :fmap! -vkey -event keydown t a d w m x c e &lt;Del> / + q s ?
- </code>
-</plugin>
-var PLUGIN_INFO=
-<VimperatorPlugin>
-<name>{NAME}</name>
-<description>feed some defined key events into the Web content</description>
-<version>2.2.3</version>
-<author mail="teramako@gmail.com" homepage="http://vimperator.g.hatena.ne.jp/teramako/">teramako</author>
-<minVersion>2.3</minVersion>
-<updateURL>https://github.com/vimpr/vimperator-plugins/raw/master/feedSomeKeys_2.js</updateURL>
-</VimperatorPlugin>;
-
-liberator.plugins.feedKey = (function(){
-var origMaps = [];
-var feedMaps = [];
-
-// keyTableの再定義...ひどく不毛...
-const keyTable = [
- [ KeyEvent.DOM_VK_BACK_SPACE, ["BS"] ],
- [ KeyEvent.DOM_VK_TAB, ["Tab"] ],
- [ KeyEvent.DOM_VK_RETURN, ["Return", "CR", "Enter"] ],
- //[ KeyEvent.DOM_VK_ENTER, ["Enter"] ],
- [ KeyEvent.DOM_VK_ESCAPE, ["Esc", "Escape"] ],
- [ KeyEvent.DOM_VK_SPACE, ["Spc", "Space"] ],
- [ KeyEvent.DOM_VK_PAGE_UP, ["PageUp"] ],
- [ KeyEvent.DOM_VK_PAGE_DOWN, ["PageDown"] ],
- [ KeyEvent.DOM_VK_END, ["End"] ],
- [ KeyEvent.DOM_VK_HOME, ["Home"] ],
- [ KeyEvent.DOM_VK_LEFT, ["Left"] ],
- [ KeyEvent.DOM_VK_UP, ["Up"] ],
- [ KeyEvent.DOM_VK_RIGHT, ["Right"] ],
- [ KeyEvent.DOM_VK_DOWN, ["Down"] ],
- [ KeyEvent.DOM_VK_INSERT, ["Ins", "Insert"] ],
- [ KeyEvent.DOM_VK_DELETE, ["Del", "Delete"] ],
- [ KeyEvent.DOM_VK_F1, ["F1"] ],
- [ KeyEvent.DOM_VK_F2, ["F2"] ],
- [ KeyEvent.DOM_VK_F3, ["F3"] ],
- [ KeyEvent.DOM_VK_F4, ["F4"] ],
- [ KeyEvent.DOM_VK_F5, ["F5"] ],
- [ KeyEvent.DOM_VK_F6, ["F6"] ],
- [ KeyEvent.DOM_VK_F7, ["F7"] ],
- [ KeyEvent.DOM_VK_F8, ["F8"] ],
- [ KeyEvent.DOM_VK_F9, ["F9"] ],
- [ KeyEvent.DOM_VK_F10, ["F10"] ],
- [ KeyEvent.DOM_VK_F11, ["F11"] ],
- [ KeyEvent.DOM_VK_F12, ["F12"] ],
- [ KeyEvent.DOM_VK_F13, ["F13"] ],
- [ KeyEvent.DOM_VK_F14, ["F14"] ],
- [ KeyEvent.DOM_VK_F15, ["F15"] ],
- [ KeyEvent.DOM_VK_F16, ["F16"] ],
- [ KeyEvent.DOM_VK_F17, ["F17"] ],
- [ KeyEvent.DOM_VK_F18, ["F18"] ],
- [ KeyEvent.DOM_VK_F19, ["F19"] ],
- [ KeyEvent.DOM_VK_F20, ["F20"] ],
- [ KeyEvent.DOM_VK_F21, ["F21"] ],
- [ KeyEvent.DOM_VK_F22, ["F22"] ],
- [ KeyEvent.DOM_VK_F23, ["F23"] ],
- [ KeyEvent.DOM_VK_F24, ["F24"] ],
-];
-const vkeyTable = [
- [ KeyEvent.DOM_VK_0, ['0'] ],
- [ KeyEvent.DOM_VK_1, ['1'] ],
- [ KeyEvent.DOM_VK_2, ['2'] ],
- [ KeyEvent.DOM_VK_3, ['3'] ],
- [ KeyEvent.DOM_VK_4, ['4'] ],
- [ KeyEvent.DOM_VK_5, ['5'] ],
- [ KeyEvent.DOM_VK_6, ['6'] ],
- [ KeyEvent.DOM_VK_7, ['7'] ],
- [ KeyEvent.DOM_VK_8, ['8'] ],
- [ KeyEvent.DOM_VK_9, ['9'] ],
- [ KeyEvent.DOM_VK_SEMICOLON, [';'] ],
- [ KeyEvent.DOM_VK_EQUALS, ['='] ],
- [ KeyEvent.DOM_VK_A, ['a'] ],
- [ KeyEvent.DOM_VK_B, ['b'] ],
- [ KeyEvent.DOM_VK_C, ['c'] ],
- [ KeyEvent.DOM_VK_D, ['d'] ],
- [ KeyEvent.DOM_VK_E, ['e'] ],
- [ KeyEvent.DOM_VK_F, ['f'] ],
- [ KeyEvent.DOM_VK_G, ['g'] ],
- [ KeyEvent.DOM_VK_H, ['h'] ],
- [ KeyEvent.DOM_VK_I, ['i'] ],
- [ KeyEvent.DOM_VK_J, ['j'] ],
- [ KeyEvent.DOM_VK_K, ['k'] ],
- [ KeyEvent.DOM_VK_L, ['l'] ],
- [ KeyEvent.DOM_VK_M, ['m'] ],
- [ KeyEvent.DOM_VK_N, ['n'] ],
- [ KeyEvent.DOM_VK_O, ['o'] ],
- [ KeyEvent.DOM_VK_P, ['p'] ],
- [ KeyEvent.DOM_VK_Q, ['q'] ],
- [ KeyEvent.DOM_VK_R, ['r'] ],
- [ KeyEvent.DOM_VK_S, ['s'] ],
- [ KeyEvent.DOM_VK_T, ['t'] ],
- [ KeyEvent.DOM_VK_U, ['u'] ],
- [ KeyEvent.DOM_VK_V, ['v'] ],
- [ KeyEvent.DOM_VK_W, ['w'] ],
- [ KeyEvent.DOM_VK_X, ['x'] ],
- [ KeyEvent.DOM_VK_Y, ['y'] ],
- [ KeyEvent.DOM_VK_Z, ['z'] ],
- [ KeyEvent.DOM_VK_MULTIPLY, ['*'] ],
- [ KeyEvent.DOM_VK_ADD, ['+'] ],
- [ KeyEvent.DOM_VK_SUBTRACT, ['-'] ],
- [ KeyEvent.DOM_VK_COMMA, [','] ],
- [ KeyEvent.DOM_VK_PERIOD, ['.'] ],
- [ KeyEvent.DOM_VK_SLASH, ['/', '?'] ],
- [ KeyEvent.DOM_VK_BACK_QUOTE, ['`'] ],
- [ KeyEvent.DOM_VK_OPEN_BRACKET, ['{'] ],
- [ KeyEvent.DOM_VK_BACK_SLASH, ['\\'] ],
- [ KeyEvent.DOM_VK_CLOSE_BRACKET, ['}'] ],
- [ KeyEvent.DOM_VK_QUOTE, ["'"] ],
-];
-
-function getKeyCode(str, vkey) {
- str = str.toLowerCase();
- var ret = 0;
- (vkey ? vkeyTable : keyTable).some(function(i) i[1].some(function(k) k.toLowerCase() == str && (ret = i[0])));
- return ret;
-}
-function init(keys, useVkey){
- destroy();
- keys.forEach(function(key){
- var origKey, feedKey;
- if (key instanceof Array){
- [origKey, feedKey] = key;
- } else if (typeof(key) == 'string'){
- [origKey, feedKey] = [key,key];
- }
- replaceUserMap(origKey, feedKey, useVkey);
- });
-}
-function replaceUserMap(origKey, feedKey, useVkey, eventName){
- if (mappings.hasMap(modes.NORMAL, origKey)){
- var origMap = mappings.get(modes.NORMAL,origKey);
- if (origMap.description.indexOf(origKey+' -> ') != 0) {
- // origMapをそのままpushするとオブジェクト内の参照先を消されてしまう
- // 仕方なく複製を試みる
- var clone = new Map(origMap.modes.map(function(m) m),
- origMap.names.map(function(n) n),
- origMap.description,
- origMap.action,
- {
- flags:origMap.flags,
- rhs:origMap.rhs,
- noremap:origMap.noremap,
- count: origMap.cout,
- arg: origMap.arg,
- motion: origMap.motion
- });
- origMaps.push(clone);
- }
- }
- var map = new Map([modes.NORMAL], [origKey], origKey + ' -> ' + feedKey,
- function(count){
- count = count > 1 ? count : 1;
- for (var i=0; i<count; i++){
- feedKeyIntoContent(feedKey, useVkey, eventName);
- }
- }, { flags:(Mappings.flags ? Mappings.flags.COUNT : null), rhs:feedKey, noremap:true, count:true });
- addUserMap(map);
- if (feedMaps.some(function(fmap){
- if (fmap.names[0] != origKey) return false;
- for (var key in fmap) fmap[key] = map[key];
- return true;
- })) return;
- feedMaps.push(map);
-}
-function destroy(){
- try{
- feedMaps.forEach(function(map){
- mappings.remove(map.modes[0],map.names[0]);
- });
- }catch(e){ liberator.log(map); }
- origMaps.forEach(function(map){
- addUserMap(map);
- });
- origMaps = [];
- feedMaps = [];
-}
-function addUserMap(map){
- mappings.addUserMap(map.modes, map.names, map.description, map.action, {
- flags:map.flags,noremap:map.noremap,rhs:map.rhs,count:map.count,arg:map.arg,motion:map.motion
- });
-}
-function parseKeys(keys){
- var matches = /^\d+(?=\D)/.exec(keys);
- if (matches){
- var num = parseInt(matches[0],10);
- if (!isNaN(num)) return [keys.substr(matches[0].length), num];
- }
- return [keys, 0];
-}
-function getDestinationElement(frameNum){
- var root = document.commandDispatcher.focusedWindow;
- if (frameNum > 0){
- var frames = [];
- (function(frame){// @see liberator.buffer.shiftFrameFocus
- if (frame.document.body.localName.toLowerCase() == 'body') {
- frames.push(frame);
- }
- for (var i=0; i<frame.frames.length; i++){
- arguments.callee(frame.frames[i]);
- }
- })(window.content);
- frames = frames.filter(function(frame){
- frame.focus();
- if (document.commandDispatcher.focusedWindow == frame) return frame;
- });
- if (frames[frameNum]) return frames[frameNum];
- }
- return root;
-}
-function feedKeyIntoContent(keys, useVkey, eventName){
- var frameNum = 0;
- [keys, frameNum] = parseKeys(keys);
- var destElem = getDestinationElement(frameNum);
- destElem.focus();
- modes.passAllKeys = true;
- modes.passNextKey = false;
- for (var i=0; i<keys.length; i++){
- var keyCode;
- var shift = false, ctrl = false, alt = false, meta = false;
- if (useVkey && (keyCode = getKeyCode(keys[i], true))) {
- var charCode = 0;
- } else {
- var charCode = keys.charCodeAt(i);
- keyCode = 0;
- }
- if (keys[i] == '<'){
- var matches = keys.substr(i + 1).match(/^((?:[ACMSacms]-)*)([^>]+)/);
- if (matches) {
- if (matches[1]) {
- ctrl = /[cC]-/.test(matches[1]);
- alt = /[aA]-/.test(matches[1]);
- shift = /[sS]-/.test(matches[1]);
- meta = /[mM]-/.test(matches[1]);
- }
- if (matches[2].length == 1) {
- if (!ctrl && !alt && !shift && !meta) return false;
- if (useVkey && (keyCode = getKeyCode(matches[2], true))) {
- charCode = 0;
- } else {
- charCode = matches[2].charCodeAt(0);
- }
- } else if (matches[2].toLowerCase() == "space") {
- if (useVkey) {
- charCode = 0;
- keyCode = KeyEvent.DOM_VK_SPACE;
- } else {
- charCode = KeyEvent.DOM_VK_SPACE;
- }
- } else if (keyCode = getKeyCode(matches[2])) {
- charCode = 0;
- } else {
- return false;
- }
- i += matches[0].length + 1;
- }
- } else {
- shift = (keys[i] >= "A" && keys[i] <= "Z") || keys[i] == "?";
- }
-
- //liberator.log({ctrl:ctrl, alt:alt, shift:shift, meta:meta, keyCode:keyCode, charCode:charCode, useVkey: useVkey});
- var evt = content.document.createEvent('KeyEvents');
- evt.initKeyEvent(eventName, true, true, content, ctrl, alt, shift, meta, keyCode, charCode);
- if (destElem.document.body)
- destElem.document.body.dispatchEvent(evt);
- else
- destElem.document.dispatchEvent(evt);
- }
- modes.passAllKeys = false;
-}
-
-// --------------------------
-// Command
-// --------------------------
-commands.addUserCommand(['feedmap','fmap'],'Feed Map a key sequence',
- function(args){
- if(!args.string){
- liberator.echo(template.table("feedmap list",feedMaps.map(function(map) [map.names[0], map.rhs])), true);
- return;
- }
- if (args.bang) destroy();
- var depth = args["-depth"] ? args["-depth"] : "";
- var useVkey = "-vkey" in args;
- var eventName = args["-event"] ? args["-event"] : "keypress";
-
- args.forEach(function(keypair){
- var [lhs, rhs] = keypair.split(",");
- if (!rhs) rhs = lhs;
- replaceUserMap(lhs, depth + rhs, useVkey, eventName);
- });
- },{
- bang: true,
- argCount: "*",
- options: [
- [["-depth","-d"], commands.OPTION_INT],
- [["-vkey","-v"], commands.OPTION_NOARG],
- [["-event", "-e"], commands.OPTION_STRING, null, [["keypress","-"],["keydown","-"],["keyup","-"]]]
- ]
- }
-);
-commands.addUserCommand(['feedmapclear','fmapc'],'Clear Feed Maps',destroy);
-var converter = {
- get origMap() origMaps,
- get feedMap() feedMaps,
- setup: init,
- reset: destroy
-};
-return converter;
-})();
-// vim: fdm=marker sw=4 ts=4 et:
diff --git a/jetpackHack.js b/jetpackHack.js
deleted file mode 100644
index 2e97688..0000000
--- a/jetpackHack.js
+++ /dev/null
@@ -1,177 +0,0 @@
-let INFO =
-<plugin name="jetpackHack" version="1.0"
- href="http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/jetpackHack.js"
- summary="enable to access to Jetpack inner context"
- xmlns="http://vimperator.org/namespaces/liberator">
- <author email="teramako@gmail.com">teramako</author>
- <license>BSD</license>
- <project name="Vimperator" minVersion="2.2"/>
- <p>Example: list executing Jetpack feature</p>
- <code>
-:echo jetpack.contexts.map(function(ctx) ctx.feed.title);
- </code>
- <p>Example: access to the sandbox of the feature</p>
- <code>
-:echo jetpack.contexts[0].unsafeSandbox
- </code>
- <p>Example: select and open slidebar</p>
- <code>
-:js jetpack.slideBar.select("featureTitle")
- </code>
- <p>Example: toggle slidebar</p>
- <code>
-:js jetpack.slideBar.toggle()
- </code>
- <p>Example: install a feature form local file</p>
- <code>
-:js jetpack.install("~/var/jetpackScripts/test.js")
- </code>
- <p>Example: refresh the feature</p>
- <code>
-:js jetpack.refresh("test")
- </code>
- <p>Example: uninstall the feature</p>
- <code>
-:js jetpack.uninstall("test")
- </code>
- <p>Example: reinstall the feature</p>
- <code>
-:js jetpack.reinstall("test")
- </code>
- <p>Example: purge the feature</p>
- <code>
-:js jetpack.purge("test")
- </code>
-</plugin>;
-
-let EXT = {};
-liberator.modules.jetpack = (function(){
- let id = "jetpack@labs.mozilla.com";
- if (!Application.extensions.has(id) || !Application.extensions.get(id).enabled){
- liberator.echoerr("Jetpack is not enable or installed");
- return {};
- }
- Cu.import("resource://jetpack/modules/init.js", EXT);
- let self = {
- get jWin() EXT.get("chrome://jetpack/content/index.html"),
- get JetpackRuntime() this.jWin.JetpackRuntime,
- get contexts() this.jWin.JetpackRuntime.contexts,
- get feedManager() this.jWin.JetpackRuntime.FeedPlugin.FeedManager,
- get slideBar(){
- let slideBar = window.slideBar;
- slideBar.__proto__ = slideBarProto;
- return slideBar;
- },
- getContextByTitle: function jetpack_getContextByTitle(title){
- let contexts = this.contexts.filter(function(ctx){
- return ctx.feed.title == title;
- });
- liberator.assert(contexts.length > 0, "no jetpack features");
- return contexts[0];
- },
- getFeedByTitle: function jetpack_getFeedByTitle(title){
- return getFeedByTitle(title, FEED_FLAG.ALL);
- },
- install: function jetpack_install(path){
- let file = io.File(path);
- let uri = util.createURI(file.path);
- let name = file.leafName.replace(/\..*/, "").replace(/-([a-z])/g, function (m, n1) n1.toUpperCase());
- this.feedManager.addSubscribedFeed({
- canAutoUpdate: false,
- sourceCode: file.read("UTF-8"),
- sourceUrl: uri.spec,
- title: name,
- type: "jetpack",
- url: uri.spec
- });
- },
- refresh: function jetpack_refresh(title){
- let feed = getFeedByTitle(title, FEED_FLAG.SUBSCRIBED | FEED_FLAG.NOT_BUILTIN);
- this.JetpackRuntime.forceFeedUpdate(feed);
- },
- uninstall: function jetpack_uninstall(title){
- let feed = getFeedByTitle(title, FEED_FLAG.SUBSCRIBED | FEED_FLAG.NOT_BUILTIN);
- feed.remove();
- },
- reinstall: function jetpack_reinstall(title){
- let feed = getFeedByTitle(title, FEED_FLAG.UNSUBSCRIBED);
- feed.unremove();
- },
- purge: function jetpack_purge(title){
- let feed = getFeedByTitle(title, FEED_FLAG.ALL | FEED_FLAG.NOT_BUILTIN);
- if (feed.isSubscribed)
- feed.remove();
-
- feed.purge();
- },
- };
- let slideBarProto = {
- select: function jetpack_slideBar_select(title){
- let features = this.features.filter(function(f){
- return f.context.feed.title == title;
- });
- liberator.assert(features.length > 0, "no such jetpack feature");
- this.selectFeature(features[0]);
- }
- };
- const FEED_FLAG= {
- NOT_BUILTIN: 1 << 0,
- SUBSCRIBED: 1 << 1,
- UNSUBSCRIBED: 1 << 2,
- ALL: 6
- };
- function getFeedByTitle(title, flag){
- let feeds = [];
- if (flag >= FEED_FLAG.ALL)
- feeds = getAllFeeds();
- else if (flag & FEED_FLAG.UNSUBSCRIBED)
- feeds = getUnsubscribedFeeds();
- else if (flag & FEED_FLAG.SUBSCRIBED)
- feeds = getSubscribedFeeds(true);
-
- if (flag & FEED_FLAG.NOT_BUILTIN)
- feeds = feeds.filter(function(f) !f.isBuiltIn);
-
- feeds = feeds.filter(function(f) f.title == title);
- liberator.assert(feeds.length > 0, "not such jetpack feature");
- return feeds[0];
- }
- function getAllFeeds(includeBuiltin){
- return [].concat(getSubscribedFeeds(includeBuiltin), getUnsubscribedFeeds());
- }
- function getSubscribedFeeds(includeBuiltin){
- let feeds = self.feedManager.getSubscribedFeeds();
- if (includeBuiltin)
- return feeds;
- else
- return feeds.filter(function(f) !f.isBuiltIn);
- }
- function getUnsubscribedFeeds(){
- return self.feedManager.getUnsubscribedFeeds();
- }
- JavaScript.setCompleter([self.getContextByTitle],
- [function(){ return getSubscribedFeeds(true).map(function(f) [f.title, f.uri.spec]); }]);
-
- JavaScript.setCompleter([self.refresh, self.uninstall],
- [function(){ return getSubscribedFeeds(false).map(function(f) [f.title, f.uri.spec]); }]);
-
- JavaScript.setCompleter([self.purge],
- [function(){ return getAllFeeds(false).map(function(f) [f.title, f.uri.spec]); }]);
-
- JavaScript.setCompleter([self.getFeedByTitle],
- [function(){ return getAllFeeds(true).map(function(f) [f.title, f.uri.spec]); }]);
-
- JavaScript.setCompleter([self.reinstall],
- [function(){ return getUnsubscribedFeeds().map(function(f) [f.title, f.uri.spec]); }]);
-
- JavaScript.setCompleter([self.install],
- [function (context, obj, args) {
- context.quote[2] = "";
- completion.file(context, true);
- }]);
- JavaScript.setCompleter([slideBarProto.select],
- [function(){ return self.slideBar.features.map(function(f) [f.context.feed.title, f.context.feed.uri.spec]); }]);
- return self;
-})();
-
-// vim: sw=2 ts=2 et:
diff --git a/twitter.js b/twitter.js
deleted file mode 100644
index c8c011a..0000000
--- a/twitter.js
+++ /dev/null
@@ -1,323 +0,0 @@
-// Vimperator plugin: "Update Twitter"
-// Last Change: 21-Jan-2009. Jan 2008
-// License: Creative Commons
-// Maintainer: Trapezoid <trapezoid.g@gmail.com> - http://unsigned.g.hatena.ne.jp/Trapezoid
-//
-// The script allows you to update Twitter status from Vimperator 0.6.*.
-//
-// Commands:
-// :twitter some thing text
-// post "some thing text" to Twitter.
-// :twitter! someone
-// show someone's statuses.
-// :twitter!? someword
-// show search result of 'someword' from "http://search.twitter.com/".
-// :twitter!@
-// show mentions.
-// :twitter!+ someone
-// fav someone's last status..
-// :twitter!- someone
-// un-fav someone's last status..
-let PLUGIN_INFO =
-<VimperatorPlugin>
-<name>{NAME}</name>
-<description>The script allows you to update Twitter status from Vimperator</description>
-<version>1.2.0</version>
-<updateURL>https://github.com/vimpr/vimperator-plugins/raw/master/twitter.js</updateURL>
-<author>Trapezoid</author>
-<license>Creative Commons</license>
-<detail><![CDATA[
- == Subject ==
- The script allows you to update Twitter status from Vimperator 0.6.*.
-
- == Commands ==
- :twitter some thing text:
- post "some thing text" to Twitter.
- :twitter! someone:
- show someone's statuses.
- :twitter!? someword:
- show search result of 'someword' from "http://search.twitter.com/".
- :twitter!@:
- show mentions.
- :twitter!+ someone:
- fav someone's last status..
- :twitter!- someone:
- un-fav someone's last status..
-]]></detail>
-</VimperatorPlugin>;
-
-liberator.modules.twitter = (function(){
- var statuses = null;
- var expiredStatus = false;
- var autoStatusUpdate = !!parseInt(liberator.globalVariables.twitter_auto_status_update || 0);
- var statusValidDuration = parseInt(liberator.globalVariables.twitter_status_valid_duration || 90);
- var statusRefreshTimer;
- var passwordManager = Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
- var evalFunc = window.eval;
- try {
- var sandbox = new Components.utils.Sandbox("about:blank");
- if (Components.utils.evalInSandbox("true", sandbox) === true){
- evalFunc = function(text){
- return Components.utils.evalInSandbox(text, sandbox);
- };
- }
- } catch (e){ liberator.log("warning: twitter.js is working with unsafe sandbox."); }
-
- function sprintf(format){
- var i = 1, re = /%s/, result = "" + format;
- while (re.test(result) && i < arguments.length) result = result.replace(re, arguments[i++]);
- return result;
- }
- function getElementsByXPath(xpath, node){
- node = node || document;
- var nodesSnapshot = (node.ownerDocument || node).evaluate(xpath, node, null,
- XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
- var data = [];
- for(var i = 0, l = nodesSnapshot.snapshotLength; i < l;
- data.push(nodesSnapshot.snapshotItem(i++)));
- return (data.length > 0) ? data : null;
- }
- function getFirstElementByXPath(xpath, node){
- node = node || document;
- var doc = node.ownerDocument;
- var result = (node.ownerDocument || node).evaluate(xpath, node, null,
- XPathResult.FIRST_ORDERED_NODE_TYPE, null);
- return result.singleNodeValue ? result.singleNodeValue : null;
- }
- function sayTwitter(username, password, stat){
- var sendData = '';
- if (stat.match(/^(.*)@([^\s#]+)(?:#(\d+))(.*)$/)){
- var [replyUser, replyID] = [RegExp.$2, RegExp.$3];
- stat = RegExp.$1 + "@" + replyUser + RegExp.$4;
- sendData = "status=" + encodeURIComponent(stat) + "&in_reply_to_status_id=" + replyID;
- } else {
- sendData = "status=" + encodeURIComponent(stat);
- }
- sendData += "&source=Vimperator";
- var xhr = new XMLHttpRequest();
- xhr.open("POST", "https://twitter.com/statuses/update.json", false, username, password);
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xhr.send(sendData);
- liberator.echo("[Twitter] Your post " + '"' + stat + '" (' + stat.length + " characters) was sent. " );
- }
- function favTwitter(username, password, user){
- var xhr = new XMLHttpRequest();
- xhr.open("GET", "https://twitter.com/statuses/user_timeline/" + user + ".json?count=1", false, username, password);
- xhr.send(null);
- xhr.open("POST", "https://twitter.com/favourings/create/" + window.eval(xhr.responseText)[0].id + ".json", false, username, password);
- xhr.send(null);
- }
- function unfavTwitter(username, password, user){
- var xhr = new XMLHttpRequest();
- xhr.open("GET", "https://twitter.com/statuses/user_timeline/" + user + ".json?count=1", false, username, password);
- xhr.send(null);
- xhr.open("DELETE", "https://twitter.com/favourings/destroy/" + window.eval(xhr.responseText)[0].id + ".json", false, username, password);
- xhr.send(null);
- }
- function showTwitterMentions(username, password){
- var xhr = new XMLHttpRequest();
- xhr.open("GET", "https://twitter.com/statuses/mentions.json", false, username, password);
- xhr.send(null);
- statuses = evalFunc(xhr.responseText);
-
- var html = <style type="text/css"><![CDATA[
- span.twitter.entry-content a { text-decoration: none; }
- img.twitter.photo { border; 0px; width: 16px; height: 16px; vertical-align: baseline; }
- ]]></style>.toSource()
- .replace(/(?:\r\n|[\r\n])[ \t]*/g, " ") +
- statuses.map(function(status)
- <>
- <img src={status.user.profile_image_url}
- alt={status.user.screen_name}
- title={status.user.screen_name}
- class="twitter photo"/>
- <strong>{status.user.name}&#x202C;</strong>
- </>.toSource()
- .replace(/(?:\r\n|[\r\n])[ \t]*/g, " ") +
- sprintf(': <span class="twitter entry-content">%s&#x202C;</span>', status.text))
- .join("<br/>");
-
- //liberator.log(html);
- liberator.echo(html, true);
- }
- function getFollowersStatus(username, password, target, onComplete){
- // for debug
- //target = "otsune"
- function setRefresher(){
- expiredStatus = false;
- if (statusRefreshTimer)
- clearTimeout(statusRefreshTimer);
- statusRefreshTimer = setTimeout(function () expiredStatus = true, statusValidDuration * 1000);
- }
-
- var xhr = new XMLHttpRequest();
- var endPoint = target ? "https://twitter.com/statuses/user_timeline/" + target + ".json"
- : "https://twitter.com/statuses/friends_timeline.json";
- xhr.open("GET", endPoint, onComplete, username, password);
- liberator.log('get!');
- if (onComplete) {
- xhr.onreadystatechange = function () {
- if (xhr.readyState == 4 && xhr.status == 200) {
- liberator.log('got!');
- setRefresher();
- onComplete(statuses = evalFunc(xhr.responseText) || []);
- }
- }
- }
- xhr.send(null);
- if (onComplete)
- return;
- setRefresher();
- statuses = evalFunc(xhr.responseText) || [];
- }
- function showFollowersStatus(username, password, target){
- // for debug
- //target = "otsune"
- getFollowersStatus.apply(null, arguments);
-
- var html = <style type="text/css"><![CDATA[
- span.twitter.entry-content a { text-decoration: none; }
- img.twitter.photo { border; 0px; width: 16px; height: 16px; vertical-align: baseline; margin: 1px; }
- ]]></style>.toSource()
- .replace(/(?:\r\n|[\r\n])[ \t]*/g, " ") +
- statuses.map(function(status)
- <>
- <img src={status.user.profile_image_url}
- alt={status.user.screen_name}
- title={status.user.screen_name}
- class="twitter photo"/>
- <strong>{status.user.name}&#x202C;</strong>
- : <span class="twitter entry-content">{detectLink(status.text)}</span>
- </>.toSource()
- .replace(/(?:\r\n|[\r\n])[ \t]*/g, " "))
- .join("<br/>");
-
- //liberator.log(html);
- liberator.echo(html, true);
- }
- function detectLink(str){
- let m = str.match(/https?:\/\/\S+/);
- if (m) {
- let left = str.substr(0, m.index);
- let url = m[0];
- let right = str.substring(m.index + m[0].length);
- return <>{detectLink(left)}<a highlight="URL" href={url}> {url} </a>{detectLink(right)}</>;
- }
- return str;
- }
- function getAccount(){
- try {
- var logins = passwordManager.findLogins({}, "http://twitter.com", "https://twitter.com", null);
- if (logins.length)
- return [logins[0].username, logins[0].password];
- else
- throw "Twitter: account not found";
- }
- catch (ex){
- liberator.echoerr(ex);
- }
-
- }
- function showTwitterSearchResult(word){
- var xhr = new XMLHttpRequest();
- xhr.open("GET", "http://search.twitter.com/search.json?q=" + encodeURIComponent(word), false);
- xhr.send(null);
- var results = (evalFunc("("+xhr.responseText+")") || {"results":[]}).results;
-
- var html = <style type="text/css"><![CDATA[
- span.twitter.entry-content a { text-decoration: none; }
- img.twitter.photo { border; 0px; width: 16px; height: 16px; vertical-align: baseline; margin: 1px; }
- ]]></style>.toSource()
- .replace(/(?:\r\n|[\r\n])[ \t]*/g, " ") +
- results.map(function(result)
- <>
- <img src={result.profile_image_url}
- alt={result.from_user}
- title={result.from_user}
- class="twitter photo"/>
- <strong>{result.from_user}&#x202C;</strong>
- : <span class="twitter entry-content">{result.text}</span>
- </>.toSource()
- .replace(/(?:\r\n|[\r\n])[ \t]*/g, " "))
- .join("<br/>");
-
- //liberator.log(html);
- liberator.echo(html, true);
- }
- liberator.modules.commands.addUserCommand(["twitter"], "Change Twitter status",
- function(arg){
- var special = arg.bang;
- var [username, password] = getAccount();
- arg = arg.string.replace(/%URL%/g, liberator.modules.buffer.URL)
- .replace(/%TITLE%/g, liberator.modules.buffer.title);
-
- if (special && arg.match(/^\?\s*(.*)/))
- showTwitterSearchResult(RegExp.$1);
- else
- if (special && arg.match(/^\+\s*(.*)/))
- favTwitter(username, password, RegExp.$1);
- else
- if (special && arg.match(/^-\s*(.*)/))
- unfavTwitter(username, password, RegExp.$1);
- else
- if (special && arg.match(/^@/))
- showTwitterMentions(username, password);
- else
- if (special || arg.length == 0)
- showFollowersStatus(username, password, arg);
- else
- sayTwitter(username, password, arg);
- },{
- bang: true,
- literal: 0,
- completer: let (getting, targetContext) function(context, args){
- function compl(){
- if (args.bang){
- targetContext.title = ["Name","Entry"];
- list = statuses.map(function(s) ["@" + s.user.screen_name, s.text]);
- } else if (/RT\s+@\w*$/.test(args[0])){
- targetContext.title = ["Name + Text"];
- list = statuses.map(function(s) ["@" + s.user.screen_name + ": " + s.text, "-"]);
- } else {
- targetContext.title = ["Name#ID","Entry"];
- list = statuses.map(function(s) ["@" + s.user.screen_name+ "#" + s.id + " ", s.text]);
- }
-
- if (target){
- list = list.filter(function($_) $_[0].indexOf(target) >= 0);
- }
- targetContext.completions = list;
- targetContext.incomplete = false;
- targetContext = getting = null;
- }
-
- var matches= context.filter.match(/@(\w*)$/);
- if (!matches) return;
- var list = [];
- var target = matches[1];
- var doGet = (expiredStatus || !(statuses && statuses.length)) && autoStatusUpdate;
- context.offset += matches.index;
- context.incomplete = doGet;
- context.hasitems = !doGet;
- targetContext = context;
- if (doGet) {
- if (!getting) {
- getting = true;
- var [username, password] = getAccount();
- getFollowersStatus(username, password, null, compl);
- }
- } else {
- compl();
- }
- }
- },
- true
- );
- let self = {
- get statuses(){
- return statuses;
- },
- };
- return self;
-})();
-// vim:sw=4 ts=4 et:
diff --git a/xpathBlink.js b/xpathBlink.js
deleted file mode 100644
index 3175dc1..0000000
--- a/xpathBlink.js
+++ /dev/null
@@ -1,104 +0,0 @@
-let INFO =
-<plugin name="xpathBlink" version="1.1.2"
- href="http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/xpathBlink.js"
- summary="blink elements by XPath"
- xmlns="http://vimperator.org/namespaces/liberator">
- <author email="teramako@gmail.com">teramako</author>
- <license href="http://www.mozilla.org/MPL/MPL-1.1.txt">MPL 1.1</license>
- <project name="Vimperator" minVersion="2.2"/>
- <p>
- For test XPath.
- </p>
- <p>CAUTION: This plugin needs "DOM Inspector" addon.</p>
- <item>
- <tags>:xpathb :xpathblink</tags>
- <spec>:xpathb<oa>link</oa> <a>expression</a></spec>
- <description>
- <p>
- blink specified elements with XPath <a>expression</a>
- </p>
- </description>
- </item>
-</plugin>;
-
-let PLUGIN_INFO =
-<VimperatorPlugin>
-<name>{NAME}</name>
-<description>blink elements by XPath</description>
-<author mail="teramako@gmail.com" homepage="http://vimperator.g.hatena.ne.jp/teramako/">teramako</author>
-<require type="extension" id="inspector@mozilla.org">DOM Inspector</require>
-<license>MPL 1.1</license>
-<version>1.1.2</version>
-<minVersion>2.2</minVersion>
-<maxVersion>3.0</maxVersion>
-<updateURL>https://github.com/vimpr/vimperator-plugins/raw/master/xpathBlink.js</updateURL>
-<detail><![CDATA[
-for test xpath
-
-== Usage==
-:xpathb[link] {expression}:
-:xb {expression}
- blink specified elements with XPath {expression}
-
-== Caution ==
-It's need "DOM Inspector" addon
-]]></detail>
-</VimperatorPlugin>;
-
-(function(){
-let extid = "inspector@mozilla.org";
-Application.getExtensions(
- function (extensions){
- if (!extensions.has(extid) || !extensions.get(extid).enabled){
- liberator.echomsg("DOM Inspector is not installed or enabled", 2);
- return;
- }
- let flasher = null;
- function getFlasher(){
- if (!flasher){
- flasher = Cc['@mozilla.org/inspector/flasher;1'].createInstance(Ci.inIFlasher);
- flasher.color = '#FF0000';
- flasher.thickness = 2;
- }
- return flasher;
- }
- /**
- * @param {Node} aNode
- */
- function blink(aNode){
- if (aNode.nodeType == 3) aNode = aNode.parentNode;
- let toggle = true;
- let flasher = getFlasher();
- function setOutline(){
- if (toggle){
- flasher.drawElementOutline(aNode);
- } else {
- flasher.repaintElement(aNode);
- }
- toggle = !toggle;
- }
- for (let i=1; i<7; ++i){
- setTimeout(setOutline, i * 100);
- }
- }
- commands.addUserCommand(['xpathb[link]','xb'],'XPath blink nodes',
- function(expression){
- let result;
- try {
- result = util.evaluateXPath(expression.string);
- } catch(e) {
- liberator.echoerr('XPath blink: ' + e);
- }
- if (!result.snapshotLength){
- liberator.echo('XPath blink: none');
- return;
- }
- for (let i=0; i<result.snapshotLength; i++){
- blink(result.snapshotItem(i));
- }
- },{}
- );
-});
-})();
-
-// vim: set fdm=marker sw=4 ts=4 noet: