aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--alert.js13
-rw-r--r--erection.js10
-rw-r--r--nicolist.js107
-rw-r--r--translaten.js160
-rw-r--r--umihara.js2
-rw-r--r--youtubeamp.js100
-rw-r--r--zip-de-download.js13
7 files changed, 179 insertions, 226 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/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/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/umihara.js b/umihara.js
index c6657ed..be6d557 100644
--- a/umihara.js
+++ b/umihara.js
@@ -149,7 +149,7 @@ 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) {
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");