Created
December 14, 2008 18:01
-
-
Save Constellation/35741 to your computer and use it in GitHub Desktop.
miya2000さんの http://github.com/miya2000/user.js/tree/master/nicovideo_view_without_login.js をFirefox用に変更したもの.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name nicovideo - view without login. | |
// @namespace http://d.hatena.ne.jp/miya2000/ | |
// @author miya2000 | |
// @version 1.1.0 | |
// @include http://www.nicovideo.jp/watch/* | |
// @exclude http://*http* | |
// a little modified for Firefox. | |
// ==/UserScript== | |
(function(win){ | |
var doc = win.document; | |
var bak_write = doc.write; | |
function main(){ | |
var page = win.$('PAGEBODY'); | |
win.removeEventListener('load', main, false); | |
if (win.User && win.User.id) return; | |
var video_id = location.href.match(/[^/]*$/); | |
if (!video_id) return; | |
function createDocumentFragmentByString(html){ | |
var range = doc.createRange(); | |
range.selectNode(doc.body); | |
return range.createContextualFragment(html); | |
} | |
var thumb_script = doc.createElement('script'); | |
thumb_script.src = 'http://www.nicovideo.jp/thumb_watch/' + video_id; | |
thumb_script.style.display = 'none'; | |
doc.write = function(html){ | |
doc.write = bak_write; | |
var node = createDocumentFragmentByString(html).firstChild; | |
page.insertBefore(node, page.firstChild); | |
}; | |
win.Element.setStyle('PAGEBODY',{'text-align':'center'}); | |
doc.body.appendChild(thumb_script); | |
} | |
win.addEventListener('load', main, false); | |
})(this.unsafeWindow || this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment