Skip to content

Instantly share code, notes, and snippets.

@Constellation
Created December 14, 2008 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Constellation/35741 to your computer and use it in GitHub Desktop.
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用に変更したもの.
// ==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