Created
July 12, 2009 08:30
-
-
Save miya2000/145569 to your computer and use it in GitHub Desktop.
This file contains 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 - wnp | |
// @description windowised nicovideo player. | |
// @author miya2000 | |
// @namespace http://d.hatena.ne.jp/miya2000/ | |
// @version 1.0.7 | |
// @include http://www.nicovideo.jp/* | |
// @exclude http://www.nicovideo.jp/watch/* | |
// @exclude http://*http* | |
// ==/UserScript== | |
/* | |
[usage] | |
Open http://www.nicovideo.jp/ | |
and you can start with the right-bottom button on the page. | |
@see http://d.hatena.ne.jp/kotas/20070925/playlist | |
http://abc.s65.xrea.com/prox/wiki/%A5%D5%A5%A3%A5%EB%A5%BF%A1%A2%A5%EA%A5%B9%A5%C8%B8%F8%B3%AB/nicovideo/#iroiro | |
http://blog.fulltext-search.biz/articles/2008/01/31/nico-nico-player-wrapper | |
http://blog.guron.net/2009/06/04/636.php | |
*/ | |
// ==== preparation ==== // | |
(function(f) { | |
if (typeof unsafeWindow == "undefined") return f; | |
return function() { | |
var s = document.createElement('script'); | |
s.setAttribute('type', 'text/javascript'); | |
s.setAttribute('style', 'display: none;'); | |
s.textContent = '(' + f.toString() + ')()'; | |
(document.body || document.documentElement).appendChild(s); | |
}; | |
}) | |
// ==== wnp ==== // | |
(function() { | |
if (typeof window.wnp != 'undefined') return; | |
var WNP = {}; | |
// ==== Prefs ==== // | |
WNP.Prefs = { | |
/* | |
observe_interval : 500, // (ms) observe interval. | |
page_timeout : 80, // (sec) page load timeout. | |
video_timeout : 60, // (sec) video play timeout. | |
menu_width_ratio : 50, // (%) menu width ratio when showing menu. | |
loop : false, // "loop" on startup. | |
comment_off : false, // "comment-off" on startup. | |
always_on_top : false, // "always on top" on startup. | |
playlist_style_simple : false, // "playlist style simple" on startup. | |
remove_on_finish : true, // "remove on finish" on startup. | |
use_history : true, // "use history" on startup. | |
skip_deleted_video : true, // "skip deleted movie" on startup. | |
use_offtimer : true, // use offtimer or not. | |
offtimer_minute : 60, // (min) off timer. | |
use_loop_break : true, // use loop break or not. | |
loop_break_count : 3 // exit from loop video by specified count. | |
*/ | |
}; | |
// ==== const ==== // | |
var Consts = { | |
WNP_TITLE : 'WNP', | |
WNP_GLOBAL_NAME : 'WNP', // global name of WNP entry object. | |
WNP_IMAGE_SAVE : 'data:image/gif;base64,R0lGODlhEAAQAIAAAAAAAPD4%2FyH5BAEAAAAALAAAAAAQABAAAAIhhI%2Bpq%2BEPHYo0zAovlscy4BnhMo7N9IHoV6Ytq23pTAMFADs%3D', | |
WNP_IMAGE_PLAY : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAAt0lEQVQ4y2NgoCL4%2F%2F8%2FXnnB0NBQFyAtQA0DJVatWtUPVHALRAP5kpQaqAmUvAzE%2F4D4OxDvB4rZAzE7uQZqASWvQA2EgSchISG5oKAgy4X%2F%2Fv27DMR%2Fgfg%2FDAPBm5UrV07AFQSkuvA%2FoSAgx0BkcAnkE3K8jAxgXn8CTFL56OFJjgvxxjipBr4BpskJ%2BNIkPgO1gV67geZFvEmGkIFKQMntQPyB2ERNTF6WAnoxjdhsR4yBZJU2AAcDLeBOG3M7AAAAAElFTkSuQmCC', | |
WNP_IMAGE_PAUSE : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAAe0lEQVQ4y2NgoCL4%2F%2F8%2FfgWhoaFuxIgRYyDLqlWrooAKfoJoEB%2BHGCOxBnIAJTf9h4BNID4OsYEzkP3fv38b%2F0HARhAfhxjDqJeHsJc5gN7aAdIJomEGYhEj2stsQMl2UGCBaBAfhxjRLgQDYBZrICBGmoG4NOISAxkIAIbuKTCbOZywAAAAAElFTkSuQmCC', | |
WNP_IMAGE_EMPTY : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQI12P4DwQACfsD%2FWMmxY8AAAAASUVORK5CYII%3D', | |
WNP_IMAGE_PREF : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAOUlEQVQoz2NgoCbg4uIC0x9%2B%2FP%2BPjInSTHVNeA3Bp4lojTCFRDkbXSNR%2Fh1YTSQHP20jm%2Bg4ohYAAAU6%2FYWVfvgIAAAAAElFTkSuQmCC', | |
WNP_STORAGE_SWF : 'http://github.com/miya2000/wnp/raw/master/storage/wnp.swf', | |
WNP_INITIAL_PLAYER_WIDTH : 610, | |
WNP_INITIAL_PLAYER_HEIGHT : 470, | |
ORG_PLAYER_VIEW_WIDTH : 544, | |
ORG_PLAYER_VIEW_HEIGHT : 384, | |
ORG_PLAYER_CONTROL_HEIGHT : 63, | |
ORG_PLAYER_MINIMUM_WIDTH : 561 | |
} | |
WNP.Consts = Consts; | |
Consts.svg_xml_base = [ | |
'<?xml version="1.0" encoding="utf-8" ?>', | |
'<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 380 230">', | |
'<defs>', | |
' <linearGradient id="liGrad" x1="0" y1="0" x2="0" y2="1">', | |
' <stop offset="0" stop-color="white" stop-opacity="0.2" />', | |
' <stop offset="0.3" stop-color="white" stop-opacity="1" />', | |
' </linearGradient>', | |
' <clipPath id="clip_txt">', | |
' <path d="m 0 0 h 220 v 150 h -220 v -150 z" />', | |
' </clipPath>', | |
'</defs>', | |
'<rect width="380" height="250" fill="white" />', | |
'<g transform="translate(0,50)">', | |
' <image x="10" width="130" height="100" xlink:href="%u%" />', | |
' <image id="mirror" x="10" width="130" height="100" xlink:href="%u%" transform="matrix(1,0,0,-1,0,200)" />', | |
' <rect id="grad" y="100" width="150" height="100" fill="url(#liGrad)" />', | |
'</g>', | |
'<g clip-path="url(#clip_txt)" transform="translate(150,50)" font-family="Verdana,sans-serif" font-weight="bold">', | |
' <text y="30" style="font-size: 15px;">%t%', | |
' <animate attributeName="x" values="0;0;-300" keyTimes="0;0.25;1" dur="10s" repeatDur="indefinite" /> ', | |
' </text>', | |
' <text x="5" y="75" style="font-size: 12px;">%c%</text>', | |
' <g id="videoinfo" style="display: none">', | |
' <text x="5" y="110" style="font-size: 10px;">\u518D\u751F</text>', | |
' <text x="60" y="110" style="font-size: 10px;" id="count">%vp%</text>', | |
// ' <text x="5" y="120" style="font-size: 10px;">\u30B3\u30E1\u30F3\u30C8</text>', | |
// ' <text x="60" y="120" style="font-size: 10px;">%vc%</text>', | |
' <text x="5" y="120" style="font-size: 10px;">\u30DE\u30A4\u30EA\u30B9\u30C8</text>', | |
' <text x="60" y="120" style="font-size: 10px;">%vm%</text>', | |
' </g>', | |
'</g>', | |
'<script type="text/javascript">', | |
'<![CDATA[', | |
' if (navigator.userAgent.indexOf("Gecko/") != -1) {', | |
' document.getElementById("mirror").style.display = "none";', | |
' document.getElementById("grad").style.display = "none";', | |
' }', | |
' if (navigator.userAgent.indexOf("Safari") != -1) {', | |
' document.getElementById("mirror").setAttribute("transform", "matrix(1,0,0,-1,0,199)");', | |
' }', | |
' if (document.getElementById("count").textContent.length > 0) {', | |
' document.getElementById("videoinfo").style.display = "";', | |
' }', | |
']]>', | |
'</script>', | |
'</svg>' | |
].join('\n'); | |
Consts.svg_mime_type = 'image/svg+xml'; | |
// ==== color settings ==== // | |
var Colors = { | |
item_hover: '#D7EBFF', | |
item_selected: '#B4DAFF', | |
item_dragging: '#FFCCCC', | |
status_error: 'red', | |
control_loop: 'yellow', | |
control_repeat: 'yellow', | |
control_comment_off: 'yellow', | |
control_mute: 'yellow', | |
control_always_on_top: 'yellow' | |
}; | |
WNP.Colors = Colors; | |
var Lang = { | |
PREF_SIMPLE_PLAYLIST_VIEW : '\u30D7\u30EC\u30A4\u30EA\u30B9\u30C8\u3092\u30B7\u30F3\u30D7\u30EB\u8868\u793A\u306B\u3059\u308B', | |
PREF_REMOVE_ON_FINISH : '\u518D\u751F\u304C\u7D42\u308F\u3063\u305F\u3089\u30D7\u30EC\u30A4\u30EA\u30B9\u30C8\u304B\u3089\u524A\u9664\u3059\u308B', | |
PREF_USE_HISTORY : '\u5C65\u6B74\u3092\u4F7F\u7528\u3059\u308B', | |
PREF_SKIP_DELETED_VIDEO : '\u524A\u9664\u3055\u308C\u305F\u52D5\u753B\u3092\u30B9\u30AD\u30C3\u30D7\u3059\u308B', | |
PREF_USE_OFFTIMER : '\u30AA\u30D5\u30BF\u30A4\u30DE\u30FC\u3092\u4F7F\u7528\u3059\u308B', | |
PREF_MINUTE : '\u5206', | |
PREF_USE_LOOP_BREAK : '\u30EB\u30FC\u30D7\u3059\u308B\u52D5\u753B\u3092\u6307\u5B9A\u56DE\u6570\u3067\u6B62\u3081\u308B', | |
PREF_COUNT : '\u56DE', | |
PLEASE_LOGIN : '\u30ED\u30B0\u30A4\u30F3\u3057\u3066\u304F\u3060\u3055\u3044', | |
OVER_ACCESS : '\u77ED\u6642\u9593\u3067\u306E\u9023\u7D9A\u30A2\u30AF\u30BB\u30B9', | |
SAVE_PLAYLIST_USAGE : '\u3053\u306E\u30EA\u30F3\u30AF\u306F\u30D6\u30C3\u30AF\u30DE\u30FC\u30AF\u30EC\u30C3\u30C8\u3067\u3059\u3002\u30D6\u30C3\u30AF\u30DE\u30FC\u30AF\u306B\u767B\u9332\u3059\u308B\u3053\u3068\u3067\u3053\u306E\u30D7\u30EC\u30A4\u30EA\u30B9\u30C8\u3092\u5FA9\u5143\u3067\u304D\u307E\u3059\u3002\n\u30D6\u30C3\u30AF\u30DE\u30FC\u30AF\u30EC\u30C3\u30C8\u306F\u30CB\u30B3\u30CB\u30B3\u52D5\u753B(http://www.nicovideo.jp/)\u306E\u30C9\u30E1\u30A4\u30F3\u4E0A\u3067\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002' | |
}; | |
WNP.Lang = Lang; | |
// ==== main ==== // | |
var fn = {}; | |
WNP.fn = fn; | |
BUILD_FUNC(fn); | |
var browser = fn.browser; | |
var ie = fn.ie; | |
var $e = fn.$e; | |
var toJSON = fn.toJSON; | |
var getAbsolutePosition = fn.getAbsolutePosition; | |
var addStyle = fn.addStyle; | |
var getStyle = fn.getStyle; | |
var $XS = fn.$XS; | |
var findVideoTitle = fn.findVideoTitle; | |
var createPlayInfo = fn.createPlayInfo; | |
WNP.html = function() { | |
var browser = WNP.fn.browser; | |
var borderBox = browser.mozilla ? '-moz-box-sizing : border-box;' : browser.webkit ? '-webkit-box-sizing : border-box;' : ''; | |
return [ | |
'<!DOCTYPE html PUBLIC "-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN" "http:\/\/www.w3.org/TR/html4/loose.dtd">', | |
'<html>', | |
'<head>', | |
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8">', | |
'<meta http-equiv="Content-Script-Type" content="text/javascript">', | |
'<meta http-equiv="Content-Style-Type" content="text/css">', | |
'<meta http-equiv="X-UA-Compatible" content="IE=8">', | |
'<title>' + Consts.WNP_TITLE + '</title>', | |
'<style type="text/css">', | |
'html, body, div, p, ul, dl, li, img { margin: 0; padding: 0; border: none; }', | |
'html, body {', | |
' width: 100%; height: 100%; background-color: black;', | |
'}', | |
'div.wnp_player { ', | |
' width: 100%; height: 100%;', | |
' position: relative;', | |
' overflow: hidden;', | |
' background-color: black;', | |
' line-height: 1.1em;', | |
' font-size: 12px;', | |
'}', | |
'div.wnp_header, div.wnp_footer {', | |
' box-sizing: border-box;', borderBox, | |
' width: 100%;', | |
' height: 20px;', | |
' color: #F0F8FF;', | |
' background-color: #050608; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment