ニコレポ同時投稿型の「またニコ」を少しばかり改変
ニコレポにも投稿できる私家版「またニコニコ動画見てる」公開してみる。 - Myrmecoleon in Paradoxical Library. ニコニコ分室 - ニコニコ部
myrmecoleonさんの所のスクリプトを改変して、動画に対するコメント部分が前に来るようにしてみました。自分がニコニコ動画のURL貼る時はこういう形式なので
中身
// ==UserScript== // @name mata nicovideo //myrmecoleon custom ver +addmylist //goldbook front Comment ver // @namespace http://muumoo.jp/ // @include http://www.nicovideo.jp/watch/* // @author pool (patched @myrmecoleon -> @goldbook) // ==/UserScript== var w = unsafeWindow || window; (function(){ Number.prototype.z = function(len){ var s = '0'.fill(len) + this.toString(); return s.substr(s.length - len); }; String.prototype.fill = function(len){ var result = ''; for(var i = 0; i < len; i++) result += this; return result; }; var h1 = document.getElementsByTagName('h1').item(0); var insertpoint = document.getElementById('video_controls'); if(!h1) return; var span = document.createElement('span'); insertpoint.parentNode.insertBefore(span, insertpoint); var a = document.createElement('a'); a.appendChild(document.createTextNode('[\u307E\u305F\u898B\u3066\u308B]')); a.href = 'javascript:void 0'; a.addEventListener('click', function(){ this.parentNode.removeChild(this); var text = document.createElement('input'); text.type = 'text'; text.value = ''; text.size = 20; text.setAttribute('maxlength', 35); var a = document.createElement('a'); a.appendChild(document.createTextNode('[\u307E\u305F\u898B\u3066\u308B!]')); a.href = 'javascript:void 0'; a.addEventListener('click', function(){ unsafeWindow.matanicovideo_callback = function(){}; var script = document.createElement('script'); script.setAttribute('src', 'http://twitter.com/account/verify_credentials.json?callback=matanicovideo_callback'); script.setAttribute('type', 'application/javascript'); script.setAttribute('charset', 'utf-8'); script.addEventListener('load', function(){ var subject = h1.getElementsByTagName('a')[0].innerHTML; var url = location.href; var len = w.Video.length; var lmin = Math.floor(len / 60); var lsec = len % 60; //Twitterへ投稿する GM_xmlhttpRequest({ method: 'POST', url: 'http://twitter.com/statuses/update.json', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, data: 'status=' + encodeURIComponent( //「またニコ」部分をコメント欄に ((0 < text.value.length) ? ' ' + text.value : '') + ' : ' + subject + ' ' + url + ' (' + (0 < len ? lmin.z(2) : '--') + ':' + (0 < len ? lsec.z(2) : '--') + ')' /* '\u307E\u305F\u30CB\u30B3 : ' + subject + ' ' + url + ' (' + (0 < len ? lmin.z(2) : '--') + ':' + (0 < len ? lsec.z(2) : '--') + ')' + ((0 < text.value.length) ? ' ' + text.value : '') */ ), onload: function(res){ GM_log('\u6295\u7A3F\u3057\u307E\u3057\u305F\u3002'); }, onerror: function(res){ GM_log(res.status + ':' + res.statusText); } }); //このへんからがマイリスト追加関係。 var item_id = document.getElementById("mymemory_add_form").getElementsByTagName('input')[0].value; var token = document.getElementById('flvplayer').wrappedJSObject.GetVariable('csrfToken'); if(/(user\/\d+)/.test(document.body.innerHTML)) { var user = RegExp.$1; } GM_xmlhttpRequest({ method: 'GET', url: "http://www.nicovideo.jp/" + user, headers: { "User-Agent": "Mozilla/5.0" }, onload: function(res){ if( /<title>(.+)さんのユーザーページ/.test(res.responseText) ){ var nickname = decodeURIComponent(RegExp.$1); } GM_xmlhttpRequest({ method: 'POST', url: 'http://www.nicovideo.jp/api/deflist/add', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, data: 'item_type=0&item_id=' + item_id + '&token=' + token + '&description=' + encodeURIComponent("[うp主: " + nickname + " " + user + " ]" +text.value), onload: function(res){ GM_log('\u6295\u7A3F\u3057\u307E\u3057\u305F\u3002'); }, onerror: function(res){ GM_log(res.status + ':' + res.statusText); } }); }, onerror: function(res){ GM_log(res.status + ':' + res.statusText); } }); a.parentNode.parentNode.removeChild(a.parentNode); }, false); document.getElementsByTagName('head').item(0).appendChild(script); }, false); span.appendChild(a); span.appendChild(text); text.focus(); }, false); span.appendChild(a); })();