diff options
author | janus_wel | 2008-09-26 06:02:21 +0000 |
---|---|---|
committer | janus_wel | 2008-09-26 06:02:21 +0000 |
commit | 7347cb12756ea01c5dcbef0f0d7e373909032b8e (patch) | |
tree | 050ed1496e73fce06ee2827fcff471b7f8a72954 | |
parent | c319c9b3ed7490e0bd15b3133a4a836660996691 (diff) | |
download | vimperator-plugins-7347cb12756ea01c5dcbef0f0d7e373909032b8e.tar.bz2 |
correspond mode toggling (fullscreen, random, loop).
change caption: display now-playing title and mode's statuses.
mode's statuses are displayed with the following word.
R: random mode is on
L: loop mode is on
F: fullscreen mode is on
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@19949 d0d07461-0603-4401-acd4-de1884942a52
-rw-r--r-- | nnp_cooperation.js | 78 |
1 files changed, 51 insertions, 27 deletions
diff --git a/nnp_cooperation.js b/nnp_cooperation.js index e615a5b..918cd7c 100644 --- a/nnp_cooperation.js +++ b/nnp_cooperation.js @@ -2,53 +2,65 @@ * ==VimperatorPlugin==
* @name niconicoplaylist_cooperation.js
* @description this script give you keyboard opration for NicoNicoPlaylist.
- * @description-ja NicoNicoPlaylist をキーボードで操作できるようにする。
+ * @description-ja NicoNicoPlaylist 繧偵く繝シ繝懊シ繝峨〒謫堺ス懊〒縺阪k繧医≧縺ォ縺吶k縲
* @author janus_wel <janus_wel@fb3.so-net.ne.jp>
* @version 0.30
* @minversion 1.2
* ==VimperatorPlugin==
*
* CONSTRAINT
- * need NicoNicoPlaylist version 1.11 or above
+ * need NicoNicoPlaylist version 1.12 or above
*
* LICENSE
* New BSD License
*
* USAGE
* :nnppushallvideos
- * 現在のページ内のすべての動画を再生リストに送る。
- * ランキングやマイリストのほか、動画ページではオススメ動画が追加される。
+ * 迴セ蝨ィ縺ョ繝壹シ繧ク蜀縺ョ縺吶∋縺ヲ縺ョ蜍慕判繧貞咲函繝ェ繧ケ繝医↓騾√k縲
+ * 繝ゥ繝ウ繧ュ繝ウ繧ー繧繝槭う繝ェ繧ケ繝医ョ縺サ縺九∝虚逕サ繝壹シ繧ク縺ァ縺ッ繧ェ繧ケ繧ケ繝。蜍慕判縺瑚ソス蜉縺輔l繧九
* :nnppushthisvideo
- * 現在見ている動画を再生リストに送る。
+ * 迴セ蝨ィ隕九※縺繧句虚逕サ繧貞咲函繝ェ繧ケ繝医↓騾√k縲
* :nnpplaynext [next]
- * 再生リストの次の動画を再生する。
+ * 蜀咲函繝ェ繧ケ繝医ョ谺。縺ョ蜍慕判繧貞咲函縺吶k縲
* :nnpremove [index]
- * index 番目の動画を再生リストから取り除く。 index は 0 から数える。
- * 指定しない場合は一番上が取り除かれる。
+ * index 逡ェ逶ョ縺ョ蜍慕判繧貞咲函繝ェ繧ケ繝医°繧牙叙繧企勁縺上 index 縺ッ 0 縺九i謨ー縺医k縲
+ * 謖螳壹@縺ェ縺蝣エ蜷医ッ荳逡ェ荳翫′蜿悶j髯、縺九l繧九
* :nnpclear
- * 再生リストをすべてクリアする。
+ * 蜀咲函繝ェ繧ケ繝医r縺吶∋縺ヲ繧ッ繝ェ繧「縺吶k縲
* :nnpgetlist [numof]
- * 再生リストの上から numof 個を表示する。指定しない場合は g:nnp_coop_numoflist が使われる。
+ * 蜀咲函繝ェ繧ケ繝医ョ荳翫°繧 numof 蛟九r陦ィ遉コ縺吶k縲よ欠螳壹@縺ェ縺蝣エ蜷医ッ g:nnp_coop_numoflist 縺御スソ繧上l繧九
+ * :nnprandom
+ * 繝ゥ繝ウ繝繝繝「繝シ繝峨ョ on / off
+ * :nnploop
+ * 繝ォ繝シ繝励Δ繝シ繝峨ョ on / off
+ * :nnpfullscreen
+ * 蜈ィ逕サ髱「繝「繝シ繝峨ョ on / off
*
* VARIABLES
* g:nnp_coop_numoflist
- * :NNPGetList で表示するリストの個数を指定する。デフォルトは 10 。
+ * :NNPGetList 縺ァ陦ィ遉コ縺吶k繝ェ繧ケ繝医ョ蛟区焚繧呈欠螳壹☆繧九ゅョ繝輔か繝ォ繝医ッ 10 縲
*
* HISTORY
* 2008/07/11 ver. 0.1 initial written.
* 2008/07/15 ver. 0.2 refactoring.
- * 2008/09/25 ver. 0.3 change XPath expression.
+ * 2008/09/26 ver. 0.3 change XPath expression.
+ * correspond mode toggling (fullscreen, random, loop).
+ * change caption: display now-playing title and mode's statuses.
+ * mode's statuses are displayed with the following word.
+ * R: random mode is on
+ * L: loop mode is on
+ * F: fullscreen mode is on
*
* */
/*
-以下のコードを _vimperatorrc に貼り付けると幸せになれるかも。
-コマンド ( [',nn'] や [',nr'] の部分 ) は適宜変えてね。
+莉・荳九ョ繧ウ繝シ繝峨r _vimperatorrc 縺ォ雋シ繧贋サ倥¢繧九→蟷ク縺帙↓縺ェ繧後k縺九b縲
+繧ウ繝槭Φ繝 ( [',nn'] 繧 [',nr'] 縺ョ驛ィ蛻 ) 縺ッ驕ゥ螳懷、峨∴縺ヲ縺ュ縲
javascript <<EOM
// [N],nn
-// N 番目の動画を再生する。
-// 指定なしの場合次の動画が再生される。
+// N 逡ェ逶ョ縺ョ蜍慕判繧貞咲函縺吶k縲
+// 謖螳壹↑縺励ョ蝣エ蜷域ャ。縺ョ蜍慕判縺悟咲函縺輔l繧九
liberator.mappings.addUserMap(
[liberator.modes.NORMAL],
[',nn'],
@@ -61,8 +73,8 @@ liberator.mappings.addUserMap( );
// [N],nr
-// 上から N 個の動画を削除する。
-// 指定なしの場合一番上の動画が削除される。
+// 荳翫°繧 N 蛟九ョ蜍慕判繧貞炎髯、縺吶k縲
+// 謖螳壹↑縺励ョ蝣エ蜷井ク逡ェ荳翫ョ蜍慕判縺悟炎髯、縺輔l繧九
liberator.mappings.addUserMap(
[liberator.modes.NORMAL],
[',nr'],
@@ -86,7 +98,7 @@ const thumbnailURL = 'http://tn-skr1.smilevideo.jp/smile?i='; // style
const styles = [
- '<style>',
+ '<style type="text/css">',
'table.nnp_coop .index { text-align:right; width:2em; }',
'table.nnp_coop .thumbnail { text-align:center; }',
'table.nnp_coop caption { color:green; }',
@@ -104,7 +116,7 @@ const tableTemplate = [ ].join('');
// table caption
-const captionTemplate = '<caption>$NUMOFDISPLAY / $NUMOFTOTAL items from NicoNicoPlaylist</caption>';
+const captionTemplate = '<caption>now playing: $PLAYTITLE (display $NUMOFDISPLAY / $NUMOFTOTAL$STATUSES)</caption>';
// table head
const thead = [
@@ -131,7 +143,7 @@ const itemHTML = [ // scrape from div element that inserted by NicoNicoPlaylist
liberator.commands.addUserCommand(['nnpgetlist'], 'get NicoNicoPlaylist',
- function(arg) {
+ function (arg) {
// check existence of NicoNicoPlaylist
var playlist = $f('//div[contains(@id, "playlistcontroller_")]');
if(!playlist) {
@@ -139,6 +151,13 @@ liberator.commands.addUserCommand(['nnpgetlist'], 'get NicoNicoPlaylist', return;
}
+ var playTitle = $f('//h1').textContent;
+ var statuses = '';
+ if ($f('.//input[contains(@id, "-checkbox-random")]', playlist).checked) statuses += 'R';
+ if ($f('.//input[contains(@id, "-checkbox-loop")]', playlist).checked) statuses += 'L';
+ if ($f('.//input[contains(@id, "-checkbox-full")]', playlist).checked) statuses += 'F';
+ if (statuses) statuses = ' ' + statuses;
+
// check existence of items in NicoNicoPlaylist
var nodes = $s('./div[contains(concat(" ", @class, " "), " playlist-list-outer ")]/ul/li/a', playlist);
var nodesLength = nodes.length
@@ -171,7 +190,9 @@ liberator.commands.addUserCommand(['nnpgetlist'], 'get NicoNicoPlaylist', // evaluate variables
var caption = captionTemplate
.replace(/\$NUMOFDISPLAY/g, (nodesLength < numofList) ? nodesLength : numofList)
- .replace(/\$NUMOFTOTAL/g, nodesLength);
+ .replace(/\$NUMOFTOTAL/g, nodesLength)
+ .replace(/\$PLAYTITLE/g, playTitle)
+ .replace(/\$STATUSES/g, statuses);
// final processing
var str = styles + tableTemplate.replace(/\$CAPTION/g, caption)
@@ -214,11 +235,14 @@ function $s(query, node) { // define other commands
// only send CommandEvent to NicoNicoPlaylist script
[
- [['nnppushallvideos'], "push all videos to NicoNicoPlaylist", 'GMNNPPushAllVideos'],
- [['nnppushthisvideo'], "push current video to NicoNicoPlaylist", 'GMNNPPushThisVideo'],
- [['nnpplaynext'], "play next in NicoNicoPlaylist", 'GMNNPPlayNext'],
- [['nnpremove'], "remove item in NicoNicoPlaylist", 'GMNNPRemove'],
- [['nnpclear'], "clear all items in NicoNicoPlaylist", 'GMNNPClear'],
+ [['nnppushallvideos'], "push all videos to NicoNicoPlaylist", 'GMNNPPushAllVideos'],
+ [['nnppushthisvideo'], "push current video to NicoNicoPlaylist", 'GMNNPPushThisVideo'],
+ [['nnpplaynext'], "play next in NicoNicoPlaylist", 'GMNNPPlayNext'],
+ [['nnpremove'], "remove item in NicoNicoPlaylist", 'GMNNPRemove'],
+ [['nnpclear'], "clear all items in NicoNicoPlaylist", 'GMNNPClear'],
+ [['nnprandom'], "toggle random mode of NicoNicoPlaylist", 'GMNNPRandom'],
+ [['nnploop'], "toggle loop mode of NicoNicoPlaylist", 'GMNNPLoop'],
+ [['nnpfullscreen'], "toggle fullscreen mode of NicoNicoPlaylist", 'GMNNPFullScreen'],
].forEach(
function ([command, description, eventname]){
liberator.commands.addUserCommand(command, description,
|