diff options
-rw-r--r-- | delicious_search.js | 18 | ||||
-rw-r--r-- | direct_bookmark.js | 2 | ||||
-rw-r--r-- | feedSomeKeys_2.js | 379 | ||||
-rw-r--r-- | jetpackHack.js | 177 | ||||
-rw-r--r-- | ldrize_cooperation.js | 18 | ||||
-rw-r--r-- | panorama.js | 940 | ||||
-rw-r--r-- | statusline-toolbar.js | 53 | ||||
-rw-r--r-- | twitter.js | 323 | ||||
-rw-r--r-- | twittperator/setuden.tw | 10 | ||||
-rw-r--r-- | twittperator/sstp.tw | 89 | ||||
-rw-r--r-- | xpathBlink.js | 104 |
11 files changed, 152 insertions, 1961 deletions
diff --git a/delicious_search.js b/delicious_search.js index a66aa7f..3f431ca 100644 --- a/delicious_search.js +++ b/delicious_search.js @@ -6,7 +6,7 @@ let PLUGIN_INFO = <author mail="teramako@gmail.com" homepage="http://vimperator.g.hatena.ne.jp/teramako/">teramako</author> <version>0.3</version> <minVersion>2.0pre</minVersion> -<maxVersion>2.0</maxVersion> +<maxVersion>4.0</maxVersion> <detail><![CDATA[ == Command == :ds[earch] -tags tag, ...: @@ -44,10 +44,16 @@ set go-=D liberator.plugins.delicious = (function(){ let uuid = PLUGIN_INFO.require[0].@id.toString(); -if (Application.extensions.has(uuid) && Application.extensions.get(uuid).enabled){ - const ydls = Cc["@yahoo.com/nsYDelLocalStore;1"].getService(Ci.nsIYDelLocalStore); -} else { - return null; +let ydls = null; +if ( typeof Application.extensions === "object" && Application.extensions.has(uuid) && Application.extensions.get(uuid).enabled ){ + ydls = Cc["@yahoo.com/nsYDelLocalStore;1"].getService(Ci.nsIYDelLocalStore); +} +else if ( typeof Application.getExtensions === "function" ) { + Application.getExtensions(function(extensions) { + if ( extensions.has(uuid) && extensions.get(uuid).enabled ) { + ydls = Cc["@yahoo.com/nsYDelLocalStore;1"].getService(Ci.nsIYDelLocalStore); + } + }); } const ss = Cc["@mozilla.org/storage/service;1"].getService(Ci.mozIStorageService); @@ -170,6 +176,8 @@ function bookmarkSearch(tags, query){ tags: ydls.getTags(url, {}) }); } + } catch (e) { + liberator.echoerr(e); } finally { st.reset(); if (finalize) st.finalize(); diff --git a/direct_bookmark.js b/direct_bookmark.js index 8fb14e8..1d3688b 100644 --- a/direct_bookmark.js +++ b/direct_bookmark.js @@ -471,7 +471,7 @@ for Migemo search: require XUL/Migemo Extension xhr.send(null);
var mypage_html = parseHTML(xhr.responseText);
- var tags = getElementsByXPath("id(\"tag_list\")/span",mypage_html);
+ var tags = getElementsByXPath("id(\"tag_list\")/div/span",mypage_html);
tags.forEach(function(tag){
ldc_tags.push(tag.textContent);
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 <Space> <S-Space> z b < > - </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 <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/ldrize_cooperation.js b/ldrize_cooperation.js index 94944df..35952e4 100644 --- a/ldrize_cooperation.js +++ b/ldrize_cooperation.js @@ -184,18 +184,18 @@ if (liberator.plugins.LDRizeCooperation == undefined) (function(){ } else {
var [code,codebase,sandbox] = arguments;
}
- if(sandbox.LDRize != undefined && sandbox.Minibuffer != undefined){
+ if(sandbox.window.LDRize != undefined && sandbox.window.Minibuffer != undefined){
sandbox.window.addEventListener("focus",function(){
- self.LDRize = liberator.eval("self",sandbox.LDRize.getSiteinfo);
- self.Minibuffer = liberator.eval("command",sandbox.Minibuffer.addCommand);
- if (typeof self.LDRize.getSiteinfo != 'function') self.LDRize = sandbox.LDRize;
- if (typeof self.Minibuffer.addCommand != 'function') self.Minibuffer = sandbox.Minibuffer.command;
+ self.LDRize = liberator.eval("self",sandbox.window.LDRize.getSiteinfo);
+ self.Minibuffer = liberator.eval("command",sandbox.window.Minibuffer.addCommand);
+ if (typeof self.LDRize.getSiteinfo != 'function') self.LDRize = sandbox.window.LDRize;
+ if (typeof self.Minibuffer.addCommand != 'function') self.Minibuffer = sandbox.window.Minibuffer.command;
},false);
if(window.content.wrappedJSObject == sandbox.unsafeWindow){
- self.LDRize = liberator.eval("self",sandbox.LDRize.getSiteinfo);
- self.Minibuffer = liberator.eval("command",sandbox.Minibuffer.addCommand);
- if (typeof self.LDRize.getSiteinfo != 'function') self.LDRize = sandbox.LDRize;
- if (typeof self.Minibuffer.addCommand != 'function') self.Minibuffer = sandbox.Minibuffer.command;
+ self.LDRize = liberator.eval("self",sandbox.window.LDRize.getSiteinfo);
+ self.Minibuffer = liberator.eval("command",sandbox.window.Minibuffer.addCommand);
+ if (typeof self.LDRize.getSiteinfo != 'function') self.LDRize = sandbox.window.LDRize;
+ if (typeof self.Minibuffer.addCommand != 'function') self.Minibuffer = sandbox.window.Minibuffer.command;
}
}
});
diff --git a/panorama.js b/panorama.js deleted file mode 100644 index aa1e793..0000000 --- a/panorama.js +++ /dev/null @@ -1,940 +0,0 @@ -/** - * Use at your OWN RISK. - */ -let INFO = <> -<plugin name="panorama" version="0.6.6" - href="https://github.com/vimpr/vimperator-plugins/blob/master/panorama.js" - summary="Add supports for Panorama" - lang="en-US" - xmlns="http://vimperator.org/namespaces/liberator"> - <author email="teramako@gmail.com">teramako</author> - <license>MPL 1.1/GPL 2.0/LGPL 2.1</license> - <project name="Vimperator" minVersion="3.0pre"/> - <p> - For adding Panorama supports. - This plugin makes the default feature to not switch to the other group suddenly. - And add some mappings and commands for Parnorama. - </p> - <p> - Use at your OWN RISK. - This pluin overwrite many mappings, some commands, and some completions. - </p> - <h3 tag="panorama-new">New Mappings and Commands</h3> - <item> - <tags>g@</tags> - <spec><oa>count</oa>g@</spec> - <description> - <p>Switch to AppTab.</p> - <p>If the current tab is already AppTab, switch to the next AppTab.</p> - </description> - </item> - <item> - <tags><![CDATA[<C-S-n>]]></tags> - <spec><oa>count</oa><C-S-n></spec> - <description> - <p>Switch to next group.</p> - <p>Caution: cannot switch to empty group.</p> - </description> - </item> - <item> - <tags><![CDATA[<C-S-p>]]></tags> - <spec><oa>count</oa><C-S-p></spec> - <description> - <p>Switch to previous group.</p> - </description> - </item> - <h3 tag="panorama-command">Main Command</h3> - <item> - <tags>:panorama :tabview :tabcandy</tags> - <spec>:panorama <a>SubCommand</a></spec> - <spec>:tabview <a>SubCommand</a></spec> - <spec>:tabcandy <a>SubCommand</a></spec> - <description> - <p>See the following SubCommands.</p> - </description> - </item> - <h3 tag="panorama-sub-command">SubCommands</h3> - <item> - <tags>mkgroup mkg</tags> - <spec>mkg<oa>roup</oa><oa>!</oa> <oa>GroupName</oa></spec> - <description> - <p>Create new tab group named <a>GroupName</a>. And then, switch to the group.</p> - <p>If specified <a>!</a>, move the current tab to the group.</p> - </description> - </item> - <item> - <tags>stashtogroup stash</tags> - <spec>stash<oa>togroup</oa><oa>!</oa> <a>GroupName</a></spec> - <description> - <p>Stash the current tab to <a>GroupName</a>.</p> - <p>Caution: connnot stash AppTab (pinned tab)</p> - </description> - </item> - <item> - <tags>switchgroup swg g</tags> - <spec>switchgroup <a>GroupName</a></spec> - <spec>swg <a>GroupName</a></spec> - <spec>g <a>GroupName</a></spec> - <spec><oa>count</oa>switchgroup</spec> - <spec><oa>count</oa>swg</spec> - <spec><oa>count</oa>g</spec> - <description> - <p>Switch group to <a>GroupName</a></p> - </description> - </item> - <item> - <tags>rmgroup rmg</tags> - <spec>rmg<oa>group</oa><oa>!</oa> <oa>GroupName</oa></spec> - <description> - <p>remove group. The current group is used if ommited <oa>GroupName</oa></p> - </description> - </item> - <item> - <tags>pulltab pull</tags> - <spec>pull<oa>tab</oa> <oa>buffer</oa></spec> - <description> - <p>pull a tab from the other group</p> - </description> - </item> - <item> - <tags>pintab pin</tags> - <spec>pin<oa>tab</oa></spec> - <description> - <p>pin the current tab, if already pinned, unpin.</p> - </description> - </item> - <item> - <tags>title</tags> - <spec>t<oa>itle</oa> <a>title</a> <oa>GroupName</oa></spec> - <description> - <p>update <a>GroupName</a>'s title to <a>title</a>.</p> - <p>if omitted <a>GroupName</a>, update the current group.</p> - </description> - </item> -</plugin> -</>; - -/** - * @method selectVisible {{{ - * 現在表示されているタブでの絶対/相対位置によるタブ選択を行う - * (tabs.select() だと全タブが対象となる) - * @param {String} spec - * @param {Boolean} wrap - */ -function selectVisible (spec, wrap) { - if (spec === void(0) || spec === "") - return; - - let tabs = gBrowser.visibleTabs; - let index; - if (typeof spec === "number" || /^\d+$/.test(spec)) { - index = parseInt(spec, 10); - } else if (spec === "$") { - index = tabs.length - 1; - } else if (/^[+-]\d+$/.test(spec)) { - index = tabs.indexOf(gBrowser.mCurrentTab) + parseInt(spec, 10); - } else { - return; - } - let length = tabs.length; - if (index > length - 1) - index = wrap ? index % length : length - 1; - else if (index < 0) - index = wrap ? index % length + length : 0; - - gBrowser.mTabContainer.selectedItem = tabs[index]; -} // }}} - -/** - * @method switchTo {{{ - * tabs.switchTo 相当の関数 - * @param {String} buffer - * @param {Boolean} allowNonUnique - * @param {Number} count - * @param {Boolean} reverse - */ -function switchTo (buffer, allowNonUnique, count, reverse) { - if (buffer == "") - return null; - if (buffer != null) { - tabs._lastBufferSwitchArgs = buffer; - tabs._lastBufferSwitchSpecial = allowNonUnique; - } else { - buffer = this._lastBufferSwitchArgs; - if (allowNonUnique === void(0) || allowNonUnique === null) - allowNonUnique = tabs._lastBufferSwitchSpecial; - } - - if (buffer == "#") { - tabs.selectAlternateTab(); - return; - } - - let tab = searchTab(buffer); - if (tab) { - tabs.select(tab._tPos, false); - return; - } - - if (!count || count < 1) - count = 1; - reverse = !!reverse; - - let m = []; - let lowerBuffer = buffer.toLowerCase(); - let first = tabs.index() + (reverse ? 0 : 1); - let length = config.tabbrowser.browsers.length; - for (let [i, ] in tabs.browsers) { - let index = (i + first) % length; - let browser = config.tabbrowser.browsers[index]; - let url, title; - if ("__SS_restoreState" in browser) { - let entry = browser.__SS_data.entries.slice(-1)[0]; - url = entry.url; - title = entry.title || url; - } else { - url = browser.contentDocument.location.href; - title = browser.contentDocument.title; - } - title = title.toLowerCase(); - if (url == buffer) { - tabs.select(index, false); - return; - } - if (url.indexOf(buffer) >= 0 || title.indexOf(lowerBuffer) >= 0) - m.push(index); - } - if (m.length == 0) - liberator.echoerr("E94: No matching buffer for " + buffer); - else if (m.length > 1 && !allowNonUnique) - liberator.echoerr("E93: More than one match for " + buffer); - else { - if (reverse) { - index = m.length - count; - while (index < 0) - index + m.length; - } else { - index = (count - 1) % m.length; - } - tabs.select(m[index], false); - } -} // }}} - - -/** - * @method searchTab {{{ - * @param {String} buffer - * - "{Number}:" - * - "{GroupName} {Number}:" - * @return {Element|null} - */ -function searchTab (buffer) { - if (buffer == "#") { - if (tabs.alternate != null && tabs.getTab() != tabs.alternate) - return tabs.alternate; - return null; - } - let m = buffer.match(/^(\d+):?/); - if (m) - return tabs.getTab(parseInt(m[1], 10) -1); - m = buffer.match(/^(.+?)\s+(\d+):?/); - if (m) { - let [, groupName, tabNum] = m; - tabNum = parseInt(tabNum, 10); - let group = getGroupByName(groupName)[0]; - if (!group) - return null; - let tabItem = group.getChild(tabNum -1); - if (!tabItem) - return null; - return tabItem.tab; - } - return null; -} // }}} - -let TV = window.TabView; -/** - * @type {Window} TabView._window {{{ - */ -this.__defineGetter__("tabView", function() { - if (TV && TV._window && TV._window.GroupItems) { - delete this.tabView; - this.tabView = TV._window; - return TV._window; - } else { - let wating = true; - TV._initFrame(function(){ wating = false; }) - while (wating) - liberator.threadYield(false, true); - return this.tabView; - } -}); // }}} - -/** - * @type {Array} Array of AppTabs - */ -this.__defineGetter__("appTabs", function() gBrowser.visibleTabs.filter(function(t) t.pinned)); - -/** - * @method createGroup {{{ - * @param {String} name GroupName - * @return {GroupItem} - */ -function createGroup (name) { - let pageBounds = tabView.Items.getPageBounds(); - pageBounds.inset(20, 20); - let box = new tabView.Rect(pageBounds); - box.width = 50; - box.height = 50; - let group = new tabView.GroupItem([], { bounds: box, title: name }); - if (name && group.$title.hasClass("defaultName")) - group.$title.removeClass("defaultName"); - return group; -} // }}} - -/** - * @param {String|Number} name GroupName or GroupId - * @return {GroupItem[]} - */ -function getGroupByName (name) { - if (typeof name === "number") - return tabView.GroupItems.groupItems.filter(function(g) g.id == name); - return tabView.GroupItems.groupItems.filter(function(g) g.getTitle() == name); -} -/** - * @param {Element} tab - * @param {GroupItem|Number} group GroupItem object or group id - */ -function tabMoveToGroup (tab, group) { - let id = (typeof group == "object") ? group.id : group; - tabView.GroupItems.moveTabToGroupItem(tab, id); -} - -/** - * @method switchToGroup {{{ - * @param {String|Number} spec - * @param {Boolean} wrap - */ -function switchToGroup (spec, wrap) { - const GI = tabView.GroupItems - let current = GI.getActiveGroupItem() || GI.getActiveOrphanTab(); - let groupsAndOrphans = GI.groupItems.concat(GI.getOrphanedTabs()); - let offset = 1, relative = false, index; - if (typeof spec === "number") - index = parseInt(spec, 10); - else if (/^[+-]\d+$/.test(spec)) { - let buf = parseInt(spec, 10); - index = groupsAndOrphans.indexOf(current) + buf; - offset = buf >= 0 ? 1 : -1; - relative = true; - } else if (spec != "") { - if (/^\d+$/.test(spec)) - spec = parseInt(spec, 10); - let targetGroup = getGroupByName(spec)[0]; - if (targetGroup) - index = groupsAndOrphans.indexOf(targetGroup); - else { - liberator.echoerr("No such group: " + spec); - return; - } - } else { - return; - } - let length = groupsAndOrphans.length; - let apps = appTabs; - function groupSwitch (index, wrap) { - if (index > length - 1) - index = wrap ? index % length : length - 1; - else if (index < 0) - index = wrap ? index % length + length : 0; - - let target = groupsAndOrphans[index], - group = null; - if (target instanceof tabView.GroupItem) { - group = target; - target = target.getActiveTab() || target.getChild(0); - } - - if (target) { - gBrowser.mTabContainer.selectedItem = target.tab; - } else if (group && apps.length != 0) { - GI.setActiveGroupItem(group); - tabView.UI.goToTab(tabs.getTab(0)); - } else if (relative) { - groupSwitch(index + offset, true); - } else { - liberator.echoerr("Cannot switch to " + spec); - return; - } - } - groupSwitch(index, wrap); -} // }}} - -/** - * removeTab {{{ - * @param {Element} tab - * @param {Number} count - * @param {Boolean} focusLeftTab - * @param {Number} quitOnLastTab - * @see tabs.remove - */ -function removeTab (tab, count, focusLeftTab, quitOnLastTab) { - const gb = gBrowser; - function remove (tab) { - if (vTabs.length > 1) { - gb.removeTab(tab); - } else if (buffer.URL != "about:blank" || gb.webNavigation.sessionHistory.count > 0) { - gb.loadURI("about:blank"); - } else { - liberator.beep(); - } - } - let vTabs = gb.visibleTabs; - - if (typeof count != "number" || count < 1) - count = 1; - - if (quitOnLastTab >= 1 && gb.tabs.length <= count) { - if (liberator.windows.length > 1) - window.close(); - else - liberator.quit(quitOnLastTab == 2); - - return; - } - - // delegate selecting a tab to Firefox after the tab removed - if (count === 1 && !focusLeftTab && tab.owner) { - remove(tab); - return; - } - - let index = vTabs.indexOf(tab); - liberator.assert(index >= 0, "No such tab(s) in the current tabs"); - - let start, end, selIndex; - if (focusLeftTab) { - end = index; - start = Math.max(0, index - count + 1); - selIndex = Math.max(0, start - 1); - } else { - start = index; - end = Math.min(index + count, vTabs.length) - 1; - selIndex = end + 1; - if (selIndex >= vTabs.length) - selIndex = start > 0 ? start - 1 : 0; - } - gb.mTabContainer.selectedItem = vTabs[selIndex]; - for (let i = end; i >= start; i--) { - remove(vTabs[i]); - } -} // }}} - -/** - * setGroupTitile {{{ - * @param {String} title - * @param {GroupItem} group - */ -function setGroupTitle (title, group) { - let activeGroup = tabView.GroupItems.getActiveGroupItem(); - if (!group) - group = activeGroup; - liberator.assert(group, "Missing group"); - group.setTitle(title); - if (title && group.$title.hasClass("defaultName")) - group.$title.removeClass("defaultName"); - if (group === activeGroup) - gBrowser.updateTitlebar(); -} // }}} - -// ============================================================================ -// Mappings {{{ -// ============================================================================ - -/** - * {count}g@ select {count} of AppTab - * g@ select AppTab, - * if already selected, select the next AppTab - */ -mappings.add([modes.NORMAL], ["g@"], - "Go to AppTab", - function (count) { - let apps = appTabs; - let i = 0; - if (count != null) - i = count - 1; - else { - let currentTab = tabs.getTab(); - if (currentTab.pinned) - i = apps.indexOf(currentTab) + 1; - i %= apps.length; - } - if (apps[i]) - selectVisible(i); - }, { count: true }); - -/** - * Switch to next group - */ -mappings.add([modes.NORMAL], ["<C-S-n>"], - "switch to next group", - function (count) { switchToGroup("+" + (count || 1), true); }, - { count: true }); - -/** - * Switch to previous group - */ -mappings.add([modes.NORMAL], ["<C-S-p>"], - "switch to previous group", - function (count) { switchToGroup("-" + (count || 1), true); }, - { count: true }); - -// overwrite 'd' -mappings.getDefault(modes.NORMAL, "d").action = function(count) { - removeTab(tabs.getTab(), count, false, 0); -}; -// overwrite 'D' -mappings.getDefault(modes.NORMAL, "D").action = function(count) { - removeTab(tabs.getTab(), count, true, 0); -}; -// overwrite 'g0", 'g^' -mappings.getDefault(modes.NORMAL, "g0").action = function (count) { selectVisible(0); }; -// overwrite 'g$' -mappings.getDefault(modes.NORMAL, "g$").action = function (count) { selectVisible("$"); }; -// overwrite 'gt' -mappings.getDefault(modes.NORMAL, "gt").action = function (count) { - if (count != null) - selectVisible(count - 1, false); - else - selectVisible("+1", true); -}; -// overwrite 'C-n', 'C-Tab', 'C-PageDown' -mappings.getDefault(modes.NORMAL, "<C-n>").action = function (count) { - selectVisible("+" + (count || 1), true); -}; -// overwrite 'gT' -mappings.getDefault(modes.NORMAL, "gT").action = function (count) { - selectVisible("-" + (count || 1), true); -} -// overwrite 'b' -mappings.getDefault(modes.NORMAL, "b").action = function (count) { - if (count != null) - selectVisible(count - 1); - else - commandline.open("", "buffer! ", modes.EX); -} - -// }}} - -// ============================================================================ -// Command {{{ -// ============================================================================ -/** - * overwrite :ls :buffers - */ -let (cmd = commands.get("buffers")) { - cmd.action = function (args) { - completion.listCompleter("buffer", args.literalArg, null, - args.bang ? completion.buffer.ALL : completion.buffer.VISIBLE); - }; - cmd.bang = true; -} - -/** - * overwrite :buffer - */ -let (cmd = commands.get("buffer")) { - cmd.action = function (args) { - let arg = args.literalArg; - if (arg && args.count > 0) - switchTo(arg, args.bang); - else if (args.count > 0) - switchTo(args.count.toString(), args.bang); - else - switchTo(arg, args.bang); - }; - cmd.completer = function (context) completion.buffer(context, completion.buffer.ALL); -} - -let subCmds = [ - /** - * SubCommand help {{{ - */ - new Command(["help"], "Show Help", - function (args) { - let list = template.genericOutput("Panorama Help", - <dl>{ template.map(subCmds, function(cmd) <><dt>{cmd.names.join(", ")}</dt><dd>{cmd.description}</dd></>) }</dl> - ); - commandline.echo(list, commandline.HL_NORMAL); - }, {}, true) // }}} - , - /** - * SubCommad mkgroup {{{ - * make a group and switch to the group - * if bang(!) exists, take up the current tab to the group - */ - new Command(["mkg[roup]"], "create Group", - function (args) { - let groupName = args.literalArg; - let group = createGroup(groupName); - let currentTab = tabs.getTab(); - if (args.bang) { - if (!currentTab.pinned) - TV.moveTabTo(currentTab, group.id); - } - let apps = appTabs, - child = group.getChild(0); - if (child) { - tabView.GroupItems.setActiveGroupItem(group); - tabView.UI.goToTab(child.tab); - } else if (apps.length == 0) { - group.newTab(); - } else { - tabView.GroupItems.setActiveGroupItem(group); - tabView.UI.goToTab(currentTab.pinned ? currentTab : apps[apps.length - 1]); - } - }, { - bang: true, - literal: 0, - }, true) /// }}} - , - /** - * SubCommand switchgroup {{{ - * swtich to the {group} - * if {count} exists, switch to relative {count} - */ - new Command(["switchgroup", "swg", "g"], "Switch Group", - function (args) { - if (args.count > 0) { - switchToGroup("+" + args.count, true); - } else { - switchToGroup(args.literalArg); - } - }, { - count: true, - literal: 0, - completer: function (context) completion.tabgroup(context, true), - }, true) // }}} - , - /** - * SubCommand stashgroup {{{ - * stash the current tab to other {group} - * if bang(!) exists and {group} doesn't exists, - * create {group} and stash - */ - new Command(["stash[togroup]"], "Stash the current tab to other group", - function (args) { - let currentTab = tabs.getTab(); - if (currentTab.pinned) { - liberator.echoerr("Connot stash an AppTab"); - return; - } - let groupName = args.literalArg; - let group = getGroupByName(groupName)[0]; - if (!group) { - if (args.bang) { - group = createGroup(groupName); - } else { - liberator.echoerr("No such group: " + groupName.quote() + ". if want create, add \"!\""); - return; - } - } - TV.moveTabTo(currentTab, group.id); - } ,{ - bang: true, - literal: 0, - completer: function (context) completion.tabgroup(context, true), - }, true) // }}} - , - /** - * SubCommand rmgroup {{{ - * remove {group} - * if {group} is ommited, remove the current group - */ - new Command(["rmg[roup]"], "close all tabs in the group", - function (args) { - let groupName = args.literalArg; - const GI = tabView.GroupItems; - let activeGroup = GI.getActiveGroupItem(); - let group = groupName ? getGroupByName(groupName)[0] : activeGroup; - liberator.assert(group, "No such group: " + groupName); - - if (group === activeGroup) { - if (gBrowser.visibleTabs.length < gBrowser.tabs.length) { - switchToGroup("+1", true); - } else { - let apps = appTabs; - let gb = gBrowser; - let vtabs = gb.visibleTabs; - if (apps.length == 0) { - // 最後尾にabout:blankなタブをフォアグランドに開く - gb.loadOneTab("about:blank", { inBackground: false, relatedToCurrent: false }); - } else { - // AppTabがあればそれをとりあえず選択しておく - gb.mTabContainer.selectedIndex = apps.length -1; - } - for (let i = vtabs.length -1, tab; (tab = vtabs[i]) && !tab.pinned; i--) { - gb.removeTab(tab); - } - return; - } - } - group.closeAll(); - }, { - literal: 0, - completer: function (context) completion.tabgroup(context, false), - }, true) // }}} - , - /** - * SubCommand pulltab {{{ - * pull a tab from the other group - */ - new Command(["pull[tab]"], "pull a tab from the other group", - function (args) { - const GI = tabView.GroupItems; - let activeGroup = GI.getActiveGroupItem(); - liberator.assert(activeGroup, "Cannot move to the current"); - let arg = args.literalArg; - if (!arg) - return; - let tab = searchTab(arg); - liberator.assert(tab, "No such tab: " + arg); - TV.moveTabTo(tab, activeGroup.id); - gBrowser.mTabContainer.selectedItem = tab; - }, { - literal: 0, - completer: function (context) completion.buffer(context, completion.buffer.GROUPS | completion.buffer.ORPHANS), - }, true) // }}} - , - /** - * SubCommand pinTab {{{ - */ - new Command(["pin[tab]"], "toggle AppTab the current tab", - function (args) { - let currentTab = tabs.getTab(); - if (currentTab.pinned) - gBrowser.unpinTab(currentTab); - else - gBrowser.pinTab(currentTab); - }, { - }, true) // }}} - , - /** - * SubCommand title {{{ - */ - new Command(["t[itle]"], "set group title", - function (args) { - let title = args[0], - groupName = args.literalArg; - let group = getGroupByName(groupName)[0]; - setGroupTitle(title, group); - }, { - literal: 1, - completer: function (context, args) { - if (args.length > 1) { - completion.tabgroup(context, false); - } - }, - }, true) // }}} -]; - -/** - * MainCommand panorama {{{ - */ -commands.addUserCommand(["panorama"], "Parnorama", - function (args) { - // show help, call SubCommand help - if (args.length < 1 || args["-help"]) { - subCmds[0].execute(""); - return; - } - // delegate subcommand - let [count, subCmdName, bang, subArgs] = commands.parseCommand(args.literalArg); - let cmd = subCmds.filter(function(c) c.hasName(subCmdName))[0]; - liberator.assert(cmd, "No such sub-command: " + subCmdName); - cmd.execute(subArgs, bang, count, {}); - }, { - bang: true, - literal: 0, - options: [ - [["-help", "-h"], commands.OPTION_NOARG], - ], - completer: function (context) { - let [count, subCmdName, bang, args] = commands.parseCommand(context.filter); - let [, prefix, junk] = context.filter.match(/^(:*\d*)\w*(.?)/) || []; - context.advance(prefix.length); - if (!junk) { - context.title = ["Panorama SubCommands"]; - context.keys = { text: "longNames", description: "description" }; - context.completions = [k for ([, k] in Iterator(subCmds))]; - return; - } - - let cmd = subCmds.filter(function(c) c.hasName(subCmdName))[0]; - if (!cmd) { - context.highlight(0, subCmdName.length, "SPELLCHECK"); - return; - } - [prefix] = context.filter.match(/^(?:\w*[\s!]|!)\s*/); - let cmdContext = context.fork(subCmdName, prefix.length); - let argContext = context.fork("args", prefix.length); - args = cmd.parseArgs(cmdContext.filter, argContext, { count: count, bang: bang }); - if (args) { - args.count = count; - args.bang = bang; - if (!args.completeOpt && cmd.completer) { - cmdContext.advance(args.completeStart); - cmdContext.quote = args.quote; - cmdContext.filter = args.completeFilter; - cmd.completer.call(cmd, cmdContext, args); - } - } - }, - }, true); -// }}} - -// }}} - -// ============================================================================ -// Completion {{{ -// ============================================================================ -completion.tabgroup = function TabGroupCompleter (context, excludeActiveGroup) { - const GI = tabView.GroupItems; - let groupItems = GI.groupItems; - if (excludeActiveGroup) { - let activeGroup = GI.getActiveGroupItem(); - groupItems = groupItems.filter(function(group) group.id != activeGroup.id); - } - context.title = ["TabGroup"]; - context.completions = groupItems.map(function(group) { - let title = group.getTitle(); - let desc = [ - "Title:", title || "(Untitled)", - "TabNum:", group.getChildren().length, - ].join(" "); - if (!title) - title = group.id; - return [title, desc]; - }); -}; - -/** - * overwite completion.buffer - */ -(function(TV, gBrowser) { - const UNTITLE_LABEL = "(Untitled)"; - - function getIndicator (tab) { - if (tab == gBrowser.mCurrentTab) - return "%"; - else if (tab == tabs.alternate) - return "#"; - return " "; - } - function getURLFromTab (tab) - ("__SS_restoreState" in tab.linkedBrowser && "__SS_data" in tab.linkedBrowser) ? - tab.linkedBrowser.__SS_data.entries.slice(-1)[0].url : - tab.linkedBrowser.contentDocument.location.href; - - function createItem (prefix, label, url, indicator, icon) - ({ text: [prefix + label, prefix + url], url: template.highlightURL(url), indicator: indicator, icon: icon || DEFAULT_FAVICON }) - - function generateVisibleTabs () { - for (let [i, tab] in Iterator(gBrowser.visibleTabs)) { - let indicator = getIndicator(tab) + (tab.pinned ? "@" : " "), - label = tab.label || UNTITLE_LABEL, - url = getURLFromTab(tab), - index = (tab._tPos + 1) + ": "; - let item = createItem(index, label, url, indicator, tab.image); - if (!tab.pinned && tab._tabViewTabItem && tab._tabViewTabItem.parent) { - let groupName = tab._tabViewTabItem.parent.getTitle(); - if (groupName) { - let prefix = groupName + " " + (i + 1) + ": "; - item.text.push(prefix + label); - item.text.push(prefix + url); - } - } - yield item; - } - } - function generateGroupList (group, groupName) { - let hasName = !!groupName; - for (let [i, tabItem] in Iterator(group.getChildren())) { - let index = (tabItem.tab._tPos + 1) + ": ", - label = tabItem.tab.label || UNTITLE_LABEL, - url = getURLFromTab(tabItem.tab); - let item = createItem(index, label, url, getIndicator(tabItem.tab), tabItem.tab.image); - if (hasName) { - let gIndex = groupName + " " + (i + 1) + ": "; - item.text.push(gIndex + label, gIndex + url); - } - yield item; - } - } - function generateOrphanedList (tabItems) { - for (let [i, tabItem] in Iterator(tabItems)) { - let indicator = getIndicator(tabItem.tab), - index = (tabItem.tab._tPos + 1) + ": ", - label = tabItem.tab.label || UNTITLE_LABEL, - url = getURLFromTab(tabItem.tab); - yield createItem(index, label, url, getIndicator(tabItem.tab), tabItem.tab.image); - } - } - - completion.buffer = function bufferCompletion (context, flag) { - if (!flag) - flag = this.buffer.VISIBLE; - - context.anchored = false; - context.keys = { text: "text", description: "url", icon: "icon" }; - context.compare = CompletionContext.Sort.number; - let process = context.process[0]; - context.process = [ - function (item, text) <> - <span highlight="Indicator" style="display: inline-block; width: 2em; text-align: center">{item.item.indicator}</span> - { process.call(this, item, text) } - </> - ]; - if (flag & this.buffer.VISIBLE) { - context.title = ["Buffers"]; - context.completions = [item for (item in generateVisibleTabs())]; - } - if (!(flag & this.buffer.GROUPS | flag & this.buffer.ORPHANS)) - return; - let self = this; - TV._initFrame(function() { - let groups = TV._window.GroupItems; - if (flag & self.buffer.GROUPS) { - let activeGroup = groups.getActiveGroupItem(); - let activeGroupId = activeGroup === null ? null : activeGroup.id; - for (let [i, group] in Iterator(groups.groupItems)) { - if (group.id != activeGroupId) { - let groupName = group.getTitle(); - context.fork("GROUP_" + group.id, 0, self, function (context) { - context.title = [groupName || UNTITLE_LABEL]; - context.completions = [item for (item in generateGroupList(group, groupName))]; - }); - } - } - } - if (flag & self.buffer.ORPHANS) { - let orphanedTabs = [tabItem for ([, tabItem] in Iterator(groups.getOrphanedTabs())) if (tabItem.tab.hidden)]; - if (orphanedTabs.length == 0) - return; - context.fork("__ORPHANED__", 0, self, function (context) { - context.title = ["Orphaned"]; - context.completions = [item for (item in generateOrphanedList(orphanedTabs))]; - }); - } - }); - }; - completion.buffer.ALL = 1 | 2 | 4; - completion.buffer.VISIBLE = 1 << 0; - completion.buffer.GROUPS = 1 << 1; - completion.buffer.ORPHANS = 1 << 2; - -})(window.TabView, window.gBrowser); - -// }}} - -// vim: sw=2 ts=2 et fdm=marker: diff --git a/statusline-toolbar.js b/statusline-toolbar.js index 3293041..b4d2e53 100644 --- a/statusline-toolbar.js +++ b/statusline-toolbar.js @@ -19,8 +19,8 @@ var INFO = </ul> </description> <item> - <tags>'statustoolbars'</tags> - <spec>'statustoolbars'</spec> + <tags>'slt' 'statustoolbars'</tags> + <spec>'statustoolbars' 'slt'</spec> <type>stringlist</type> <default></default> <description> @@ -32,9 +32,6 @@ var INFO = </plugin> var updater = { - "noscript-tbb": [ - function add(id) { noscriptOverlay.initPopups(); }, - ], "star-button": [ null, function rm(elm) { @@ -42,6 +39,17 @@ var updater = { } ], }; +var css = <css><![CDATA[ + #liberator-customize-toolbar { + border: none !important; + min-width: 5px !important; + max-height: 17px; + } + #liberator-customize-toolbar > :-moz-any(image, toolbarbutton) { max-height: 16px; } + #liberator-customize-toolbar .statusbar-resizerpanel { display: none; } + #liberator-customize-toolbar toolbarbutton { padding: 0 !important; } +]]></css>.trim(); + function $(id) document.getElementById(id); function createElement (name, attrs) { var elm = document.createElement("toolbar"); @@ -50,24 +58,18 @@ function createElement (name, attrs) { } return elm; } +function customizeDone () { + window.BrowserToolboxCustomizeDone(true); +} +var gToolbox = gNavToolbox; var id = "liberator-customize-toolbar"; if (!$(id)) { init(); } function init () { - styles.addSheet(true, "customize-toolbar", "chrome://*", <css><![CDATA[ - #liberator-customize-toolbar { - border: none !important; - min-width: 5px !important; - max-height: 17px; - } - #liberator-customize-toolbar > :-moz-any(image, toolbarbutton) { - max-height: 16px; - } - #liberator-customize-toolbar .statusbar-resizerpanel { display: none; } - ]]></css>.toString(), false); + styles.addSheet(true, "customize-toolbar", "chrome://*", css, false); var t = createToolbar(); t.appendChild($("status-bar")); @@ -76,7 +78,7 @@ function init () { config.toolbars.statuslinetoolbar = [[id], "Statusline Toolbar"]; - options.add(["statustoolbars"], "Statusline Toolbar Sets", + options.add(["statuslinetoolbars", "slt"], "Statusline Toolbar Sets", "stringlist", "", { toolbar: t, getter: function () { @@ -96,7 +98,7 @@ function init () { removeSets.splice(i, 1); continue; } - let elm = document.getElementById(id); + let elm = $(id); if (elm) { if (elm.parentNode !== t) { t.appendChild(elm); @@ -104,7 +106,7 @@ function init () { updater[id][0](elm); } newSets.push(id); - } else if (gNavToolbox.palette.querySelector("#" + id)) { + } else if (gToolbox.palette.querySelector("#" + id)) { newSets.push(id); } } @@ -112,17 +114,22 @@ function init () { t.setAttribute("currentset", newSets.join(",")); updateSets(this.toolbar, newSets, removeSets); document.persist(this.toolbar.id, "currentset"); + customizeDone(); return val; }, completer: function (context) { - context.completions = [["none","-"]].concat(Array.map(gNavToolbox.palette.children, function(elm) { + context.completions = [["none","-"]].concat(Array.map(gToolbox.palette.children, function(elm) { return [ elm.id, elm.getAttribute("label") || "-" ]; })); }, - validator: function (val) { - return true; + validator: function (ids) { + return ids.every(function(id) { + return ($(id) || gToolbox.palette.querySelector("#" + id)); + }); }, }); + + customizeDone(); } function updateSets (toolbar, newSets, removeSets) { @@ -132,7 +139,7 @@ function updateSets (toolbar, newSets, removeSets) { } } for (let [, id] in Iterator(removeSets)) { - let elm = document.getElementById(id); + let elm = $(id); if (!elm) continue; 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}‬</strong> - </>.toSource() - .replace(/(?:\r\n|[\r\n])[ \t]*/g, " ") + - sprintf(': <span class="twitter entry-content">%s‬</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}‬</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}‬</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/twittperator/setuden.tw b/twittperator/setuden.tw new file mode 100644 index 0000000..1a78d35 --- /dev/null +++ b/twittperator/setuden.tw @@ -0,0 +1,10 @@ + +(function () { + plugins.libly.$U.around( + plugins.twittperator.Twitter, + 'say', + function (next, [status, inReplyTo]) { + return next([status.toString().slice(0, 17), inReplyTo]); + } + ); +})(); diff --git a/twittperator/sstp.tw b/twittperator/sstp.tw new file mode 100644 index 0000000..d00afa1 --- /dev/null +++ b/twittperator/sstp.tw @@ -0,0 +1,89 @@ +/* NEW BSD LICENSE {{{ +Copyright (c) 2011, anekos. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + 3. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +################################################################################### +# http://sourceforge.jp/projects/opensource/wiki/licenses%2Fnew_BSD_license # +# に参考になる日本語訳がありますが、有効なのは上記英文となります。 # +################################################################################### + +}}} */ + +// INFO {{{ +let INFO = +<> + <plugin name="SSTP Sender" version="1.0.0" + href="http://vimpr.github.com/" + summary="Send tweets to SSTP app." + lang="en-US" + xmlns="http://vimperator.org/namespaces/liberator"> + <author email="anekos@snca.net">anekos</author> + <license>New BSD License</license> + <project name="Vimperator" minVersion="3.0"/> + <p>Just install.</p> + </plugin> +</>; +// }}} + +(function () { + let socketService = + let (stsvc = Components.classes["@mozilla.org/network/socket-transport-service;1"]) + let (svc = stsvc.getService()) + svc.QueryInterface(Components.interfaces["nsISocketTransportService"]); + + function talk (name, msg) { + let transport = socketService.createTransport(null, 0, '127.0.0.1', 9801, null); + let outputStream = transport.openOutputStream(0, 0, 0); + let conv = Cc['@mozilla.org/intl/converter-output-stream;1']. + createInstance(Ci.nsIConverterOutputStream); + + msg = msg.replace(/\\/g, "\\\\").replace(/[\r\n]+/g, "\\n"); + + let buf = [ + "SEND SSTP/1.1", + "Sender: Twittperator", + "Charset: UTF-8", + "Script: \\h\\s0" + name + "\\n\\n" + msg + "\\e", + "Options: nodescript,notranslate", + "Charset: UTF-8", + "", + ].map(function (it) (it + "\r\n")).join(''); + + conv.init(outputStream, 'UTF-8', buf.length, Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER); + conv.writeString(buf); + + outputStream.close(); + } + + plugins.twittperator.ChirpUserStream.addListener( + function (msg, raw) + (msg.text && msg.user && msg.user.screen_name && talk(msg.user.screen_name, msg.text)) + ); + +})(); + +// vim:sw=2 ts=2 et si fdm=marker: + 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: |