aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--alert.js13
-rw-r--r--erection.js10
-rw-r--r--exopen.js1
-rw-r--r--happy_hacking_vimperator.js8
-rw-r--r--hatenaStar.js9
-rw-r--r--maine_coon.js4
-rw-r--r--nicolist.js107
-rw-r--r--readitlater.js12
-rw-r--r--translaten.js160
-rw-r--r--twittperator.js2
-rwxr-xr-xtwittperator/me.tw38
-rw-r--r--twittperator/pebble.tw37
-rw-r--r--twittperator/taioooooooooonoooooooooooooooooooooooooooooon.tw66
-rw-r--r--umihara.js4
-rw-r--r--youtubeamp.js100
-rw-r--r--zip-de-download.js13
16 files changed, 341 insertions, 243 deletions
diff --git a/alert.js b/alert.js
index 957da6a..b2e2085 100644
--- a/alert.js
+++ b/alert.js
@@ -349,6 +349,15 @@ let PLUGIN_INFO = xml`
};
}
+ function torelativetime(h, m) {
+ if (m > 59)
+ return false;
+ h %= 24;
+ var now = new Date();
+ var d = (h * 60 + parseInt(m)) - (now.getHours() * 60 + now.getMinutes() + now.getSeconds() / 60);
+ return d >= 0 ? d : d + 60 * 24;
+ }
+
let alertMethods = {
alert: function (next, msg) {
window.alert(msg);
@@ -436,11 +445,13 @@ let PLUGIN_INFO = xml`
function (args) {
let methods = [], time = null, message = '';
args.forEach(function (v) {
- let m, f;
+ let m, f, t;
if ((m = v.match(/^-(\w+)(?:=(.*))?$/)) && (f = alertMethods[m[1]]))
methods.push([f, m[2]]);
else if (!time && v.match(/^\d+(\.\d+)?$/))
time = parseFloat(v);
+ else if (!time && (m = v.match(/^(\d{1,2}):(\d{1,2})$/)) && (t = torelativetime(m[1], m[2])))
+ time = parseFloat(t);
else
message += ' ' + v;
});
diff --git a/erection.js b/erection.js
index b78182c..21bc908 100644
--- a/erection.js
+++ b/erection.js
@@ -217,7 +217,7 @@ let INFO = xml`
['c[opy]'],
'Copy text',
makeErectionCommand(function (e) {
- util.copyToClipboard(String(`{e.text} - {e.by} {e.from} {e.imageURL}`));
+ util.copyToClipboard(String(`${e.text} - ${e.by} ${e.from} ${e.imageURL}`));
}),
subOption
),
@@ -227,9 +227,9 @@ let INFO = xml`
makeErectionCommand(function (e) {
liberator.echo(xml`
<div style="height: 800px">
- <h1>{e.text}</h1>
- <img src={e.imageURL} />
- <span>{e.by}</span> <span>{e.from}</span>
+ <h1>${e.text}</h1>
+ <img src=${e.imageURL} />
+ <span>${e.by}</span> <span>${e.from}</span>
</div>
`);
}),
@@ -239,7 +239,7 @@ let INFO = xml`
['e[xcommand]'],
'Open command line with select erection',
makeErectionCommand(function (e, args) {
- let cmdArgs = String(`{e.text} - {e.by} {e.from} {e.imageURL}`);
+ let cmdArgs = String(`${e.text} - ${e.by} ${e.from} ${e.imageURL}`);
setTimeout(function () commandline.open('', args[0] + ' ' + cmdArgs, modes.EX), 1);
}),
{
diff --git a/exopen.js b/exopen.js
index 0e40adf..84a55a1 100644
--- a/exopen.js
+++ b/exopen.js
@@ -164,6 +164,7 @@ liberator.plugins.exOpen = (function() {
var self = this;
commands.addUserCommand(['exopen'], 'Open byextension URL',
function(args) self.open(args), {
+ bang: true,
completer: function(context, args) {
context.title = ['Template', 'Description - Value'];
if (!context.filter) {
diff --git a/happy_hacking_vimperator.js b/happy_hacking_vimperator.js
index d721295..3a6607d 100644
--- a/happy_hacking_vimperator.js
+++ b/happy_hacking_vimperator.js
@@ -3276,16 +3276,16 @@ let PLUGIN_INFO = xml`
let sz = innerWidth / msg.length / 1.5;
if (plugins.namakubi && typeof plugins.namakubi.talk == 'function')
plugins.namakubi.talk(msg);
- liberator.echo(
+ liberator.echo(xml`
<div style="background: white; color: black;">
<table>
<tr>
- <td><img src={gunsou}/></td>
- <td style={"font-size: " + sz + "px; white-space: nowrap;"}>{msg}</td>
+ <td><img src=${gunsou}/></td>
+ <td style=${"font-size: " + sz + "px; white-space: nowrap;"}>${msg}</td>
</tr>
</table>
</div>
- );
+ `);
}
function kill (msg) {
diff --git a/hatenaStar.js b/hatenaStar.js
index faca1a1..2f55b20 100644
--- a/hatenaStar.js
+++ b/hatenaStar.js
@@ -4,7 +4,7 @@ var PLUGIN_INFO = xml`
<description>Add Hatena Star.</description>
<description lang="ja">はてなスターをつける。</description>
<author mail="mattn.jp@gmail.com">mattn</author>
- <version>0.1.3</version>
+ <version>0.1.4</version>
<minVersion>2.3pre</minVersion>
<maxVersion>2.3pre</maxVersion>
<updateURL>https://github.com/vimpr/vimperator-plugins/raw/master/hatenaStar.js</updateURL>
@@ -48,12 +48,11 @@ function blink(aNode) {
}
function addHatenaStar (elem) {
- var e = document.createEvent('MouseEvents');
+ var e = content.document.createEvent('MouseEvents');
// "Hatena.Star.AddButton.selectedText" is initialized on mouseover.
- e.initMouseEvent('mouseover', true, true, window, 1, 10, 50, 10, 50, 0, 0, 0, 0, 1, elem);
- elem.dispatchEvent(e);
- e.initMouseEvent('click', true, true, window, 1, 10, 50, 10, 50, 0, 0, 0, 0, 1, elem);
+ e.initMouseEvent('mouseover', true, true, content.window, 1, 10, 50, 10, 50, 0, 0, 0, 0, 1, elem);
elem.dispatchEvent(e);
+ buffer.followLink(elem, liberator.CURRENT_TAB);
}
liberator.modules.commands.addUserCommand(['hatenastar', 'hatenas'], 'add Hatena Star',
diff --git a/maine_coon.js b/maine_coon.js
index fab21ca..af4ff57 100644
--- a/maine_coon.js
+++ b/maine_coon.js
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2008-2011, anekos.
+Copyright (c) 2008-2013, anekos.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
@@ -272,7 +272,7 @@ let PLUGIN_INFO = xml`
}) +
elemStyle
);
- let elem = U.xmlToDom(<div id="liberator_maine_coon" style={style}>{message}</div>, doc);
+ let elem = U.xmlToDom(xml`<div id="liberator_maine_coon" style=${style}>${message}</div>`, doc);
doc.body.appendChild(elem);
let count = time;
let handle = setInterval(function () {
diff --git a/nicolist.js b/nicolist.js
index c4892d9..0ebb7a4 100644
--- a/nicolist.js
+++ b/nicolist.js
@@ -33,6 +33,7 @@ var INFO = xml`
</item>
</plugin>`;
+let video = {};
commands.addUserCommand(
['nicolist'],
'ニコニコ動画のマイリストを操作する',
@@ -45,13 +46,13 @@ commands.addUserCommand(
['a[dd]'],
'マイリストに追加する',
function (args) {
- let video_id = content.window.wrappedJSObject.video_id;
+ let video_id = content.window.wrappedJSObject.WatchJsApi.video.getVideoID();
if (!video_id) {
return liberator.echoerr('nicolist : watchページじゃない!');
}
let [mylist_id, description] = args;
if (!description){ description = ''; } //undefinedが入っているとそれをマイリストコメントにしてしまうので。
- let token = content.window.wrappedJSObject.so.variables.csrfToken;
+ let token = getToken(true);
let url = 'http://www.nicovideo.jp/api/mylist/add?group_id=' + mylist_id + '&token=' + token + '&item_id=' + video_id + '&description=' + description;
liberator.echo('nicolist add : ' + JSON.parse(util.httpGet(url).responseText).status);
},
@@ -61,6 +62,84 @@ commands.addUserCommand(
}
),
new Command(
+ ['p[lay]'],
+ '動画を再生する',
+ function (args) {
+ let [mylist_id, video_id] = args;
+ let video_ids = []
+ if (video_id) {
+ video_ids = [video_id];
+ } else if (mylist_id) {
+ let list = JSON.parse(util.httpGet('http://www.nicovideo.jp/api/mylist/list?group_id=' + mylist_id).responseText).mylistitem;
+ list.forEach(function(v){
+ video_ids.push(v.item_data.video_id);
+ });
+ } else { return; }
+ video_ids = video_ids.shuffle();
+ let i = 0;
+
+ video.container = document.createElementNS('http://www.w3.org/1999/xhtml', 'video');
+ video.container.volume = 0.7; // 効いてない
+ video.container.autoplay = true;
+ ['error', 'ended'].forEach(function(event) {
+ video.container.addEventListener(event, function() {
+ if (video.container.src === 'chrome://browser/content/browser.xul') { return; }
+ if (!video_ids[i]) { return; }
+ i++;
+ setupVideo();
+ });
+ });
+
+ setupVideo();
+
+ function setupVideo() {
+ video.flv = {}
+ util.httpGet('http://flapi.nicovideo.jp/api/getflv/' + video_ids[i]).responseText.split('&').forEach(function(param){
+ let tmp = param.split('=');
+ video.flv[tmp[0]] = decodeURIComponent(tmp[1]);
+ });
+
+ video.thumbinfo = util.httpGet('http://ext.nicovideo.jp/api/getthumbinfo/' + video_ids[i]).responseXML;
+ video.video_id = video.thumbinfo.getElementsByTagName('video_id')[0].firstChild.nodeValue;
+ video.title = video.thumbinfo.getElementsByTagName('title')[0].firstChild.nodeValue;
+ video.description = video.thumbinfo.getElementsByTagName('description')[0].firstChild.nodeValue;
+
+ util.httpGet('http://www.nicovideo.jp/watch/' + video_ids[i]); // watchページにアクセスしておかないと読み込み時403
+ video.container.src = video.flv.url;
+ }
+ },
+ {
+ literal: 1,
+ completer: mylistCompleter,
+ }
+ ),
+ new Command(
+ ['s[top]'],
+ '動画の再生を止める',
+ function (args) {
+ video.container.pause();
+ video.container.src = ''; // chrome://browser/content/browser.xul になる
+ }
+ ),
+ new Command(
+ ['now[Playing]'],
+ '再生中の動画情報',
+ function (arg) {
+ if (arg) {
+ let url = 'http://www.nicovideo.jp/watch/' + arg;
+ liberator.open(url, liberator.NEW_TAB);
+ }
+ },
+ {
+ literal: 0,
+ completer: function(context, args) {
+ context.filters = [CompletionContext.Filter.textDescription];
+ context.title = ['id', 'title']
+ context.completions = [[video.video_id, video.title]]
+ }
+ }
+ ),
+ new Command(
['o[pen]'],
'マイリストか動画を開く',
function (args) {
@@ -141,7 +220,7 @@ function mylistCompleter (context, args) {
util.httpGet(url, function (xhr) {
context.incomplete = false;
- if (/open/.test(context.name)) {
+ if (/open|play/.test(context.name)) {
context.completions = [
[v.item_data.video_id, v.item_data.title]
for ([k, v] in Iterator(JSON.parse(xhr.responseText).mylistitem.sort(sorter)))
@@ -160,7 +239,23 @@ function sorter (a, b) {
return - (a.create_time - b.create_time);
}
-function getToken () {
- let url = 'http://www.nicovideo.jp/my/mylist';
- return util.httpGet(url).responseText.match(/NicoAPI\.token.+/)[0].match(/\d{5}-\d{10}-[\d\w]{40}/)[0];
+function getToken (isWatchPage) {
+ if (isWatchPage) {
+ let watchAPIData = JSON.parse(content.document.wrappedJSObject.getElementById('watchAPIDataContainer').firstChild.nodeValue);
+ return watchAPIData.flashvars.csrfToken;
+ } else {
+ let url = 'http://www.nicovideo.jp/my/mylist';
+ return util.httpGet(url).responseText.match(/NicoAPI\.token.+/)[0].match(/\d{5}-\d{10}-[\d\w]{40}/)[0];
+ }
+}
+
+Array.prototype.shuffle = function() {
+ var i = this.length;
+ while(i){
+ var j = Math.floor(Math.random()*i);
+ var t = this[--i];
+ this[i] = this[j];
+ this[j] = t;
+ }
+ return this;
}
diff --git a/readitlater.js b/readitlater.js
index c51d3a2..5ca7a2e 100644
--- a/readitlater.js
+++ b/readitlater.js
@@ -277,11 +277,16 @@ let PLUGIN_INFO = xml`
}, // }}}
+ getLogins : function() {
+ let manager = Components.classes["@mozilla.org/login-manager;1"].getService(Components.interfaces.nsILoginManager);
+ return manager.findLogins({},"https://getpocket.com","",null).concat(
+ manager.findLogins({}, "http://getpocket.com","",null))
+ },
+
get : function(state, callback){ // {{{
// document => http://readitlaterlist.com/api/docs#get
- let manager = Components.classes["@mozilla.org/login-manager;1"].getService(Components.interfaces.nsILoginManager);
- let logins = manager.findLogins({},"http://getpocket.com","",null);
+ let logins = this.getLogins();
let req = new libly.Request(
"https://readitlaterlist.com/v2/get" , // url
@@ -316,8 +321,7 @@ let PLUGIN_INFO = xml`
add : function(url,title,callback){ // {{{
- let manager = Components.classes["@mozilla.org/login-manager;1"].getService(Components.interfaces.nsILoginManager);
- let logins = manager.findLogins({},"http://readitlaterlist.com","",null);
+ let logins = this.getLogins();
let req = new libly.Request(
"https://readitlaterlist.com/v2/add" , // url
null, // headers
diff --git a/translaten.js b/translaten.js
deleted file mode 100644
index 7e75dd1..0000000
--- a/translaten.js
+++ /dev/null
@@ -1,160 +0,0 @@
-/* {{{
-Copyright (c) 2008, 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 #
-# に参考になる日本語訳がありますが、有効なのは上記英文となります。 #
-###################################################################################
-
-}}} */
-
-// PLUGIN_INFO {{{
-let PLUGIN_INFO = xml`
-<VimperatorPlugin>
- <name>translaten</name>
- <name lang="ja">自動一括翻訳</name>
- <description>Automatically translate by clipboard changes</description>
- <description lang="ja">クリップボードの変更を監視して、一括翻訳サービスに流し込む</description>
- <version>1.0</version>
- <author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author>
- <license>new BSD License (Please read the source code comments of this plugin)</license>
- <license lang="ja">修正BSDライセンス (ソースコードのコメントを参照してください)</license>
- <minVersion>2.0pre</minVersion>
- <maxVersion>2.0pre</maxVersion>
- <detail><![CDATA[
- == Activation ==
- >||
- set translaten
- ||<
- ]]></detail>
- <detail lang="ja"><![CDATA[
- == Usage ==
- 特に操作は必要ありません。
- >||
- set translaten
- ||<
- で、有効化した後に、クリップボードに変化があれば、その内容を 'http://7go.biz/translation/' に流し込んで翻訳します。
- == Link ==
- http://vimperator.g.hatena.ne.jp/nokturnalmortum/20090104/1231070505
- ]]></detail>
-</VimperatorPlugin>`;
-// }}}
-
-(function () {
-
- const URL = 'http://7go.biz/translation/';
-
- function TranslaTen () {
- this.handle;
- this.running = false;
- }
-
- function inTheSite ()
- (~buffer.URL.indexOf(URL))
-
- TranslaTen.prototype = {
- get clipboard () util.readFromClipboard(),
-
- open: function () {
- if (inTheSite())
- return;
- if (buffer.URL == 'about:blank')
- return liberator.open(URL, liberator.CURRENT_TAB);
- for (let [number, browser] in Iterator(tabs.browsers)) {
- if (~browser.contentDocument.location.href.indexOf(URL))
- return liberator.modules.tabs.select(number, false);
- }
- liberator.open(URL, liberator.NEW_TAB);
- },
-
- stop: function () {
- if (this.handle) {
- clearInterval(this.handle);
- this.handle = null;
- }
- this.running = false;
- },
-
- run: function () {
- let self = this;
- if (this.running)
- return;
- this.running = true;
- this.prev = this.clipboard;
- this.open();
- this.handle = setInterval(
- function () {
- let now = self.clipboard;
- if (now == self.prev)
- return;
- self.prev = now;
- self.open();
- let f = function () { self.elements.textarea.value = now; self.elements.submit.click(); };
- if (inTheSite()) {
- f();
- } else {
- let handle = setInterval(
- function () {
- if (inTheSite() && buffer.loaded) {
- clearInterval(handle);
- f();
- }
- },
- 200
- );
- }
- },
- 100
- );
- },
-
- elements: {
- get submit () content.document.getElementsByTagName('INPUT')[0],
- get textarea () content.document.getElementsByTagName('TEXTAREA')[0]
- }
- };
-
- let translaten = new TranslaTen();
-
- options.add(
- ['translaten'],
- 'Automatically translate by clipboard changes',
- 'boolean',
- false,
- {
- setter: function (value) {
- if (value)
- translaten.run();
- else
- translaten.stop();
- }
- }
- );
-
-})();
-
-// vim:sw=2 ts=2 et si fdm=marker:
diff --git a/twittperator.js b/twittperator.js
index 1061c78..609a36a 100644
--- a/twittperator.js
+++ b/twittperator.js
@@ -2135,7 +2135,7 @@ let INFO = xml`
notMine: function (st)
let (n = setting.screenName)
(n ? (!st.user || st.user.screen_name !== n) : st),
- mine: function (st)
+ selectMine: function (st)
(!Predicates.notMine(st))
}; // }}}
let Completers = (function() { // {{{
diff --git a/twittperator/me.tw b/twittperator/me.tw
new file mode 100755
index 0000000..e6dd41d
--- /dev/null
+++ b/twittperator/me.tw
@@ -0,0 +1,38 @@
+/*
+ * Please write the below line into .vimperatorrc.
+ * let g:twittperator_plugin_me = 1
+ *
+ */
+
+(function () {
+ const TW = liberator.plugins.twittperator;
+
+ TW.SubCommands.add(
+ TW.SubCommand({
+ command: ['me'],
+ description: 'reply to myself',
+ action: function(arg) {
+ setTimeout(
+ function () {
+ commandline.open(
+ '',
+ 'tw ' + arg + ' ',
+ modes.EX
+ );
+ },
+ 0
+ );
+ },
+ timelineComplete: true,
+ completer: TW.Completers.name_id(
+ function (s)
+ (s.user &&
+ s.user.screen_name == liberator.globalVariables.twittperator_screen_name)
+ ? s.id : false
+ )
+ })
+ );
+})();
+
+// vim: set et fdm=syntax ft=javascript sts=2 sw=2 ts=2 :
+
diff --git a/twittperator/pebble.tw b/twittperator/pebble.tw
new file mode 100644
index 0000000..1feb454
--- /dev/null
+++ b/twittperator/pebble.tw
@@ -0,0 +1,37 @@
+/*
+ * Please write the below line into .vimperatorrc.
+ * let g:twittperator_plugin_pebble = 1
+ * let g:twittperator_plugin_pebble_user_id = '<USER_ID>';
+ * let g:twittperator_plugin_pebble_user_token = '<USER_TOKEN>';
+ * let g:twittperator_screen_name = "<YOUR_SCREEN_NAME>"
+ */
+
+(function () {
+ let screenName = liberator.globalVariables.twittperator_screen_name;
+ let userId = liberator.globalVariables.twittperator_plugin_pebble_user_id;
+ let userToken = liberator.globalVariables.twittperator_plugin_pebble_user_token;
+
+ function notify (username) {
+ let body = [
+ 'userId=' + userId,
+ 'userToken=' + userToken,
+ 'title=Twitter',
+ 'body=' + encodeURIComponent('reply from ' + username),
+ 'type=notification'].join('&');
+
+ let xhr = new XMLHttpRequest();
+ xhr.open('POST', 'https://ofkorth.net/pebble/send', true, null, null);
+ xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+
+ xhr.send(body);
+ }
+
+ plugins.twittperator.ChirpUserStream.addListener(
+ function onMsg (msg, raw) {
+ if (msg.text && msg.user && msg.in_reply_to_screen_name === screenName)
+ notify(msg.user.screen_name, msg.text);
+ }
+ );
+})();
+
+// vim: sw=2 ts=2 et fdm=marker ft=javascript:
diff --git a/twittperator/taioooooooooonoooooooooooooooooooooooooooooon.tw b/twittperator/taioooooooooonoooooooooooooooooooooooooooooon.tw
new file mode 100644
index 0000000..dacaa73
--- /dev/null
+++ b/twittperator/taioooooooooonoooooooooooooooooooooooooooooon.tw
@@ -0,0 +1,66 @@
+/*
+ * Please write the below line into .vimperatorrc.
+ * let g:twittperator_plugin_taioooooooooonoooooooooooooooooooooooooooooon = 1
+ * let g:twittperator_plugin_taioooooooooonoooooooooooooooooooooooooooooon_template = '体温 %s'
+ */
+
+(function () {
+
+ let tmpl = liberator.globalVariables.twittperator_plugin_taioooooooooonoooooooooooooooooooooooooooooon_template || '体温 %s (%S)';
+
+ let taionds = [
+ ['焼死体', 666],
+ ['鶏', 41.5],
+ ['豚', 39.0],
+ ['やぎ', 39.0],
+ ['ひつじ', 39.0],
+ ['うさぎ', 39.5],
+ ['牛', 38.5],
+ ['犬', 38.5],
+ ['猫', 38.1],
+ ['馬', 37.7],
+ ['ヒト', 36.0],
+ ['死体', 0],
+ ];
+ taionds.reverse();
+
+ function whatAmI (myon) {
+ let result = '石';
+ for ([name, taion] of taionds) {
+ if (taion <= myon)
+ result = name;
+ }
+ return result;
+ }
+
+ commands.addUserCommand(
+ ['taioooooooooonoooooooooooooooooooooooooooooon'],
+ 'Description',
+ function (args) {
+ plugins.twittperator.Twittperator.say(
+ tmpl.replace(/%s/g, args.literalArg).replace(/%S/g, function (it) {
+ return whatAmI(parseFloat(args.literalArg.match(/\d{1,2}(\.\d)?/).toString()))
+ })
+ );
+ },
+ {
+ literal: 0,
+ completer: function (context, args) {
+ context.title = ['温度', 'description'];
+
+ let cs = [];
+ for (let i = 30.0; i < 50.0; i += 0.1) {
+ cs.push([i.toString().replace(/\.\d*$/, function (it) it.substring(0, 2)), whatAmI(i)]);
+ }
+ liberator.__cs = cs;
+
+ context.filters = [CompletionContext.Filter.textDescription];
+ context.completions = cs;
+ },
+ },
+ true // replace
+ );
+
+})();
+
+// vim: sw=2 ts=2 et fdm=marker ft=javascript:
diff --git a/umihara.js b/umihara.js
index c076524..be6d557 100644
--- a/umihara.js
+++ b/umihara.js
@@ -149,14 +149,14 @@ let PLUGIN_INFO = xml`
if (to == '-')
to = defaultTarget;
//let url = 'http://quote.yahoo.co.jp/m5?a=' + value + '&s=' + from + '&t=' + to;
- let url = 'http://info.finance.yahoo.co.jp/exchange/convert/?a=' + value + '&s=' + from + '&t=' + to;
+ let url = 'http://info.finance.yahoo.co.jp/fx/convert/?a=' + value + '&s=' + from + '&t=' + to;
var req = new XMLHttpRequest();
req.open('GET', url);
req.onreadystatechange = function (aEvt) {
if (req.readyState == 4 && req.status == 200) {
let html = req.responseText;
let doc = plugins.libly.$U.createHTMLDocument(html);
- let a = doc.querySelector('tbody.yjM > tr > td > a[href^="http://stocks.finance.yahoo.co.jp"]');
+ let a = doc.querySelector('tbody > tr > td > a[href^="http://rdsig.yahoo.co.jp"]');
if (a) {
let tr = a.parentNode.parentNode;
liberator.__tr = tr;
diff --git a/youtubeamp.js b/youtubeamp.js
index 1ab8833..2f89c16 100644
--- a/youtubeamp.js
+++ b/youtubeamp.js
@@ -64,8 +64,8 @@ YouTubePlayerController.prototype = {
CARDINAL_NUMBER: 10,
YOUTUBE_DOMAIN: '.youtube.jp',
- YOUTUBE_URL: '^http://[^.]+\\.youtube\\.com/',
- WATCH_URL: 'http://[^.]+\\.youtube\\.com/watch',
+ YOUTUBE_URL: '^https?://[^.]+\\.youtube\\.com/',
+ WATCH_URL: 'https?://[^.]+\\.youtube\\.com/watch',
WATCH_PAGE: 1,
PLAYER_NODE_ID: 'movie_player',
@@ -94,6 +94,23 @@ YouTubePlayerController.prototype = {
'chrome-promo',
'watch-video-quality-setting',
],
+
+ PLAYER_WRAPPER_NODE_ID: 'player-api',
+ TOGGLE_PLAYER_WRAPPER_STYLE: {
+ position: 'fixed',
+ visibility: 'visible',
+ top: '0px',
+ left: '0px',
+ margin: '0px',
+ padding: '0px',
+ width: '100%',
+ height: '100%',
+ zIndex: '99999999999',
+ borderWidth: '0px',
+ backgroundImage: 'none',
+ backgroundColor: '#000',
+ overflow: 'hidden',
+ },
},
getControllerVersion: function() { return this.constants.VERSION; },
@@ -128,10 +145,11 @@ YouTubePlayerController.prototype = {
},
toggleSize: function() {
- var p = this._player();
- (p.width == this.constants.SIZE_WIDTH_DEFAULT && p.height == this.constants.SIZE_HEIGHT_DEFAULT)
- ? this._fullSize()
- : this._normalSize();
+ var playerWrapper = this._getElementById(this.constants.PLAYER_WRAPPER_NODE_ID);
+
+ (playerWrapper.style.position == 'fixed')
+ ? this._normalSize()
+ : this._fullSize();
},
_changeToFull: function() {
@@ -152,53 +170,36 @@ YouTubePlayerController.prototype = {
},
_fullSize: function() {
- var b = this._getElementById('baseDiv');
- this.defMargin = b.style.margin;
- this.defPadding = b.style.padding;
- this.defWidth = b.style.width;
- b.style.margin = 0;
- b.style.padding = 0;
- b.style.width = '100%';
-
- for(let i=0, max=this.constants.HIDE_NODES.length ; i<max ; ++i) {
- let h = this._getElementById(this.constants.HIDE_NODES[i]);
- if(h) { h.style.display = 'none'; }
- }
-
- this._changeToFull();
-
- window.addEventListener(
- 'resize',
- this.fuller,
- false
- );
+ var playerWrapper = this._getElementById(this.constants.PLAYER_WRAPPER_NODE_ID);
+ this._setStyle(playerWrapper, this.constants.TOGGLE_PLAYER_WRAPPER_STYLE);
},
_normalSize: function() {
- var b = this._getElementById('baseDiv');
- b.style.margin = this.defMargin;
- b.style.padding = this.defPadding;
- b.style.width = this.defWidth;
-
- for(let i=0, max=this.constants.HIDE_NODES.length ; i<max ; ++i) {
- let h = this._getElementById(this.constants.HIDE_NODES[i]);
- if(h) { h.style.display = 'block'; }
- }
+ var playerWrapper = this._getElementById(this.constants.PLAYER_WRAPPER_NODE_ID);
+ this._clearStyle(playerWrapper, this.constants.TOGGLE_PLAYER_WRAPPER_STYLE);
+ },
- var p = this._player();
- p.width = this.constants.SIZE_WIDTH_DEFAULT;
- p.height = this.constants.SIZE_HEIGHT_DEFAULT;
-
- window.removeEventListener(
- 'resize',
- this.fuller,
- false
- );
+ _setStyle: function(ele, style) {
+ Object.keys(style).forEach(function (key) {
+ ele.style[key] = style[key];
+ });
+ },
+
+ _clearStyle: function(ele, style) {
+ Object.keys(style).forEach(function (key) {
+ ele.style[key] = '';
+ });
},
seekTo: function(position) {
+ var p = this._player();
+
if(position) {
- if(position.match(/^(\d+):(\d+)$/)) {
+ if(position.match(/^(\d+)%$/)) {
+ var duration = p.getDuration();
+ position = parseInt((duration * RegExp.$1 / 100), this.constants.CARDINAL_NUMBER);
+ }
+ else if(position.match(/^(\d+):(\d+)$/)) {
position = parseInt(RegExp.$1, this.constants.CARDINAL_NUMBER) * 60
+ parseInt(RegExp.$2, this.constants.CARDINAL_NUMBER);
}
@@ -206,17 +207,22 @@ YouTubePlayerController.prototype = {
}
else position = this.constants.SEEKTO_DEFAULT;
- var p = this._player();
p.seekTo(position);
},
seekBy: function(delta) {
+ var p = this._player();
+
if(delta) {
+ if(delta.match(/^([-+]?)(\d+)%$/)) {
+ var duration = p.getDuration();
+ delta = parseInt((duration * RegExp.$2 / 100), this.constants.CARDINAL_NUMBER);
+ if(RegExp.$1 == '-') delta = -delta;
+ }
if(isNaN(delta)) throw new Error('assign signed number : seekBy()');
}
else delta = this.constants.SEEKBY_DEFAULT;
- var p = this._player();
var position = p.getCurrentTime();
position += parseInt(delta, this.constants.CARDINAL_NUMBER);
diff --git a/zip-de-download.js b/zip-de-download.js
index f7a25b4..ea15952 100644
--- a/zip-de-download.js
+++ b/zip-de-download.js
@@ -152,7 +152,7 @@ let SITE_INFO = [
try {
mime = mimeService.getTypeFromURI(uri);
} catch(e) {
- liberator.reportError(e);
+ liberator.log('zip-de-download: error: ' + e);
};
let ext = mimeService.getPrimaryExtension(mime ? mime : mimeType, null)
let name = uri.path.split("/").pop();
@@ -320,15 +320,16 @@ let SITE_INFO = [
}
if ("-list" in arg){
let [file, urls, comment] = self.download(arg[0], true, option);
- let xml = `
- <h1><span>Download :</span><span>{file.path}</span></h1>
- <p>{comment}</p>
+ let listUrlsXml = liberator.modules.template.map(urls, function(url) xml`<li>${url}</li>`);
+ let listXml = xml`
+ <h1><span>Download :</span><span>${file.path}</span></h1>
+ <p>${comment}</p>
<ol>
- {liberator.modules.template.map(urls, function(url) <li>{url}</li>)}
+ ${listUrlsXml}
</ol>
<br/>
`;
- liberator.echo(xml, true);
+ liberator.echo(listXml, true);
return;
}
liberator.echo("Started DownloadZip");