├── 2.0 ├── README.md ├── acfun.php ├── bilibili.php ├── combine.js ├── combinelite.js ├── getyoukuid.php ├── node_modules │ ├── .bin │ │ └── uglifyjs │ └── uglify-js │ │ ├── .npmignore │ │ ├── README.html │ │ ├── README.org │ │ ├── bin │ │ └── uglifyjs │ │ ├── docstyle.css │ │ ├── lib │ │ ├── consolidator.js │ │ ├── parse-js.js │ │ ├── process.js │ │ └── squeeze-more.js │ │ ├── package.json │ │ ├── test │ │ ├── beautify.js │ │ ├── testconsolidator.js │ │ ├── testparser.js │ │ └── unit │ │ │ ├── compress │ │ │ ├── expected │ │ │ │ ├── 1e21.js │ │ │ │ ├── array1.js │ │ │ │ ├── array2.js │ │ │ │ ├── array3.js │ │ │ │ ├── array4.js │ │ │ │ ├── assignment.js │ │ │ │ ├── concatstring.js │ │ │ │ ├── const.js │ │ │ │ ├── div-with-regexp.js │ │ │ │ ├── empty-blocks.js │ │ │ │ ├── forstatement.js │ │ │ │ ├── if-not.js │ │ │ │ ├── if.js │ │ │ │ ├── ifreturn.js │ │ │ │ ├── ifreturn2.js │ │ │ │ ├── infinite.js │ │ │ │ ├── issue10.js │ │ │ │ ├── issue11.js │ │ │ │ ├── issue13.js │ │ │ │ ├── issue14.js │ │ │ │ ├── issue16.js │ │ │ │ ├── issue17.js │ │ │ │ ├── issue20.js │ │ │ │ ├── issue21.js │ │ │ │ ├── issue25.js │ │ │ │ ├── issue27.js │ │ │ │ ├── issue278.js │ │ │ │ ├── issue28.js │ │ │ │ ├── issue29.js │ │ │ │ ├── issue30.js │ │ │ │ ├── issue34.js │ │ │ │ ├── issue349.js │ │ │ │ ├── issue353.js │ │ │ │ ├── issue372.js │ │ │ │ ├── issue4.js │ │ │ │ ├── issue48.js │ │ │ │ ├── issue50.js │ │ │ │ ├── issue53.js │ │ │ │ ├── issue54.1.js │ │ │ │ ├── issue68.js │ │ │ │ ├── issue69.js │ │ │ │ ├── issue9.js │ │ │ │ ├── issues222_324.js │ │ │ │ ├── mangle.js │ │ │ │ ├── null_string.js │ │ │ │ ├── strict-equals.js │ │ │ │ ├── var.js │ │ │ │ ├── whitespace.js │ │ │ │ └── with.js │ │ │ └── test │ │ │ │ ├── 1e21.js │ │ │ │ ├── array1.js │ │ │ │ ├── array2.js │ │ │ │ ├── array3.js │ │ │ │ ├── array4.js │ │ │ │ ├── assignment.js │ │ │ │ ├── concatstring.js │ │ │ │ ├── const.js │ │ │ │ ├── div-with-regexp.js │ │ │ │ ├── empty-blocks.js │ │ │ │ ├── forstatement.js │ │ │ │ ├── if-not.js │ │ │ │ ├── if.js │ │ │ │ ├── ifreturn.js │ │ │ │ ├── ifreturn2.js │ │ │ │ ├── infinite.js │ │ │ │ ├── issue10.js │ │ │ │ ├── issue11.js │ │ │ │ ├── issue13.js │ │ │ │ ├── issue14.js │ │ │ │ ├── issue16.js │ │ │ │ ├── issue17.js │ │ │ │ ├── issue20.js │ │ │ │ ├── issue21.js │ │ │ │ ├── issue25.js │ │ │ │ ├── issue27.js │ │ │ │ ├── issue278.js │ │ │ │ ├── issue28.js │ │ │ │ ├── issue29.js │ │ │ │ ├── issue30.js │ │ │ │ ├── issue34.js │ │ │ │ ├── issue349.js │ │ │ │ ├── issue353.js │ │ │ │ ├── issue372.js │ │ │ │ ├── issue4.js │ │ │ │ ├── issue48.js │ │ │ │ ├── issue50.js │ │ │ │ ├── issue53.js │ │ │ │ ├── issue54.1.js │ │ │ │ ├── issue68.js │ │ │ │ ├── issue69.js │ │ │ │ ├── issue9.js │ │ │ │ ├── issues222_324.js │ │ │ │ ├── mangle.js │ │ │ │ ├── null_string.js │ │ │ │ ├── strict-equals.js │ │ │ │ ├── var.js │ │ │ │ ├── whitespace.js │ │ │ │ └── with.js │ │ │ └── scripts.js │ │ ├── tmp │ │ ├── hoist.js │ │ ├── instrument.js │ │ └── test.js │ │ └── uglify-js.js ├── sohu.php ├── source │ ├── 163open.js │ ├── 56.js │ ├── acfun.js │ ├── bilibili.js │ ├── header.js │ ├── iqiyi.js │ ├── letv.js │ ├── player.js │ ├── playerlite.js │ ├── qq.js │ ├── sina.js │ ├── sohu.js │ ├── start.js │ ├── test.js │ ├── tudou.js │ ├── xunlei.js │ └── youku.js ├── youkuhtml5playerbookmark2.css ├── youkuhtml5playerbookmark2.js ├── youkuhtml5playerbookmark2lite.css └── youkuhtml5playerbookmark2lite.js ├── README.md ├── index.html ├── iqiyihtml5playerbookmark.js ├── sohuhtml5playerbookmark.js ├── tudouhtml5playerbookmark.js └── youkuhtml5playerbookmark.js /2.0/README.md: -------------------------------------------------------------------------------- 1 | 妈妈再也不用担心我的mba看优酷发热了计划 2 | --- 3 | 4 | 服务位置: [http://zythum.sinaapp.com/youkuhtml5playerbookmark/](http://zythum.sinaapp.com/youkuhtml5playerbookmark/) 5 | 6 | >在优酷等在线视频网站切换html5方式播放视频。以免macbook可以烫到可以煎牛排。 7 | 现在的动漫不是原来越向文字长。无厘头的方向发展不是么。那么朱一也这么来把。妈妈再也不用担心我的macbook发烫了计划2.0 Beta!! 8 | 友情提示。目前计划已经支持safari和chrome浏览器 9 | 10 | + 目前支持 优酷,土豆,搜狐视频,爱奇艺,乐视网,qq,迅雷离线,56视频 的单视频播放页面 11 | 12 | --- 13 | 14 | ![](http://ww4.sinaimg.cn/large/a74ecc4cjw1e4a7f4njqxj20mq0dzwgx.jpg) 15 | 16 | --- 17 | 18 | 更新项: 19 | + 2013-5-4 20 | + 支持迅雷云点播(m3u8) 21 | + 支持网易公开课(m3u8) 22 | + 2013-5-2 23 | + 新的ui界面。 24 | + 修复土豆的bug 25 | + 2013-4-6 26 | + 土豆换地址了。例行更新 27 | + 2013-2-9 28 | + 支持acfun.tv 以及弹幕 29 | + 2013-3-17 30 | + 支持bilibili.tv 以及弹幕 31 | + 2013-2-9 32 | + 支持56视频,呼呼。 33 | + 除了letv权限支持chrome浏览器 34 | + 2013-2-2 35 | + 支持v.qq.com,呼呼。 36 | + 支持迅雷离线,呼呼。 37 | + ui调整,支持满屏模式。 38 | + 最早 39 | + 将原本的代码挪到了sae上,速度更有保证。 40 | + 支持iqiyi.com,呼呼。 41 | + 支持letv.com,呼呼。 42 | + 新的播放界面以及全屏播放界面。 43 | + 代码重构,但是用起来应该没什么感觉。 44 | 45 | --- 46 | 47 | 目前js代码结构: 48 | 49 | combine.js 是一个node程序。直接执行 `node combine.js ` 可以将sorce中的文件打包成youkuhtml5playerbookmark2.js 50 | 51 | 打包顺序在combine.js文件中,player.js在最前。 start.js 在最后。其他没有依赖关系。 52 | 53 | 每个组件的栗子: 54 | 55 | ```javascript 56 | 'acfun' && youkuhtml5playerbookmark2.add(function(core, canPlayM3U8){ 57 | //core 一些代码方法集。详见player.js 58 | //canPlayM3U8 浏览器是否支持播放M3U8方法 bool 59 | return{ 60 | //判断是否在这个网站执行这个组件 61 | reg: /acfun\.tv/.test(window.location.host) && window.system, 62 | //执行方法 63 | //callback回调 64 | //urls 栗子 {‘高清’: 'http://xxxxxxxxxxxxx.mp4',…} 65 | //flashElementId 需要隐藏的flash元素的id 66 | //comment 如果有弹幕的话。 弹幕格式需要使用bilibili格式,不是acfun格式。 67 | call: function(callback){ 68 | return callback({ urls: urls, flashElementId: 'area-player', comment: commentInfo }); 69 | } 70 | }; 71 | }); 72 | ``` 73 | 74 | --- 75 | 76 | 用到的项目: 77 | 78 | + [https://github.com/FortAwesome/Font-Awesome]() 79 | + [https://github.com/mishoo/UglifyJS2]() 80 | -------------------------------------------------------------------------------- /2.0/acfun.php: -------------------------------------------------------------------------------- 1 | = 0){ 39 | preg_match("/\/([0-9\-]+)\.html/i", $json['vurl'], $matches); 40 | if($matches){ 41 | $json['vurl'] = 'http://video.sina.com.cn/v/b/'.$matches[1].'.html'; 42 | } 43 | } 44 | $rs = acfun($json['vurl']); 45 | preg_match("/ipad_vid\:\'([0-9a-zA-Z]+)\'\,/i", $rs, $matches); 46 | if($matches){ 47 | $vid = $matches[1]; 48 | } 49 | } 50 | echo('"'.$vid.'"'); 51 | echo(','); 52 | echo('"'.$type.'"'); 53 | } 54 | echo(","); 55 | $rs = acfun("http://comment.acfun.tv/".$cid.".json"); 56 | $rs = get_object_vars(json_decode('{"comment":'.$rs.'}')); 57 | $rs = $rs['comment']; 58 | foreach ($rs as $one){ 59 | $one = get_object_vars($one); 60 | $one['c'] = explode(',', $one['c']); 61 | $arrInfo['p'][0] = $one['c'][0]; 62 | $arrInfo['p'][1] = $one['c'][2]; 63 | $arrInfo['p'][2] = $one['c'][3]; 64 | $arrInfo['p'][3] = $one['c'][1]; 65 | $arrInfo['p'][4] = $one['c'][5]; 66 | $arrInfo['p'][5] = "0"; 67 | $arrInfo['p'][6] = $one['c'][4]; 68 | $arrInfo['p'][7] = ""; 69 | $arrInfo['msg'] = $one['m']; 70 | $arrInfos[] = $arrInfo; 71 | } 72 | echo(json_encode($arrInfos)); 73 | echo(");"); 74 | // echo("}catch(e){".$callback."(-1)}"); 75 | ?> -------------------------------------------------------------------------------- /2.0/bilibili.php: -------------------------------------------------------------------------------- 1 | loadXML($rs); 41 | $ds = $dom->getElementsByTagName('d'); 42 | foreach($ds as $d){ 43 | $arrInfo['p'] = $d->getAttribute('p'); 44 | $arrInfo['p'] = explode(',', $arrInfo['p']); 45 | $arrInfo['msg'] = $d->nodeValue; 46 | $arrInfos[] = $arrInfo; 47 | } 48 | echo(json_encode($arrInfos)); 49 | echo(")}catch(e){".$callback."(-1)}"); 50 | ?> -------------------------------------------------------------------------------- /2.0/combine.js: -------------------------------------------------------------------------------- 1 | var files = [ 2 | './source/header.js', 3 | './source/player.js', 4 | './source/youku.js', 5 | './source/tudou.js', 6 | './source/qq.js', 7 | './source/sina.js', 8 | './source/sohu.js', 9 | './source/56.js', 10 | './source/iqiyi.js', 11 | './source/letv.js', 12 | './source/acfun.js', 13 | './source/bilibili.js', 14 | './source/xunlei.js', 15 | './source/163open.js', 16 | // './source/test.js', 17 | './source/start.js' 18 | ]; 19 | 20 | var combineFile = ''; 21 | 22 | var fs = require('fs'); 23 | var jsp = require('uglify-js').parser; 24 | var pro = require('uglify-js').uglify; 25 | 26 | 27 | var loopRead = function(callback){ 28 | var file = files.shift(); 29 | if(file){ 30 | fs.readFile(file, function(err, data){ 31 | combineFile += data; 32 | loopRead(callback); 33 | }); 34 | }else{ 35 | callback && callback(); 36 | } 37 | }; 38 | 39 | loopRead(function(){ 40 | var ast; 41 | combineFile = '(function(){' + combineFile + '})();'; 42 | ast = jsp.parse(combineFile); 43 | ast = pro.ast_mangle(ast); 44 | ast = pro.ast_squeeze(ast); 45 | ast = pro.gen_code(ast); 46 | fs.writeFile('youkuhtml5playerbookmark2.js', ast, function() { 47 | console.log('-----youkuhtml5playerbookmark2.js updated!----'); 48 | }); 49 | }); -------------------------------------------------------------------------------- /2.0/combinelite.js: -------------------------------------------------------------------------------- 1 | var files = [ 2 | './source/header.js', 3 | './source/playerlite.js', 4 | './source/youku.js', 5 | './source/tudou.js', 6 | './source/qq.js', 7 | './source/sina.js', 8 | './source/sohu.js', 9 | './source/56.js', 10 | './source/iqiyi.js', 11 | './source/letv.js', 12 | './source/acfun.js', 13 | './source/bilibili.js', 14 | './source/xunlei.js', 15 | './source/163open.js', 16 | // './source/test.js', 17 | './source/start.js' 18 | ]; 19 | 20 | var combineFile = ''; 21 | 22 | var fs = require('fs'); 23 | var jsp = require('uglify-js').parser; 24 | var pro = require('uglify-js').uglify; 25 | 26 | 27 | var loopRead = function(callback){ 28 | var file = files.shift(); 29 | if(file){ 30 | fs.readFile(file, function(err, data){ 31 | combineFile += data; 32 | loopRead(callback); 33 | }); 34 | }else{ 35 | callback && callback(); 36 | } 37 | }; 38 | 39 | loopRead(function(){ 40 | var ast; 41 | combineFile = '(function(){' + combineFile + '})();'; 42 | ast = jsp.parse(combineFile); 43 | ast = pro.ast_mangle(ast); 44 | ast = pro.ast_squeeze(ast); 45 | ast = pro.gen_code(ast); 46 | fs.writeFile('youkuhtml5playerbookmark2lite.js', ast, function() { 47 | console.log('-----youkuhtml5playerbookmark2lite.js updated!----'); 48 | }); 49 | }); -------------------------------------------------------------------------------- /2.0/getyoukuid.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2.0/node_modules/.bin/uglifyjs: -------------------------------------------------------------------------------- 1 | /Applications/MAMP/htdocs/youkuhtml5playerbookmark/node_modules/uglify-js/bin/uglifyjs -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/.npmignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .tmp*~ 3 | *.local.* 4 | .pinf-* 5 | node_modules/ 6 | npm-debug.log 7 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/bin/uglifyjs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // -*- js -*- 3 | 4 | global.sys = require(/^v0\.[012]/.test(process.version) ? "sys" : "util"); 5 | var fs = require("fs"), path = require("path"); 6 | var uglify = require("../uglify-js"), // symlink ~/.node_libraries/uglify-js.js to ../uglify-js.js 7 | consolidator = uglify.consolidator, 8 | jsp = uglify.parser, 9 | pro = uglify.uglify; 10 | 11 | var options = { 12 | ast: false, 13 | consolidate: false, 14 | mangle: true, 15 | mangle_toplevel: false, 16 | no_mangle_functions: false, 17 | squeeze: true, 18 | make_seqs: true, 19 | dead_code: true, 20 | verbose: false, 21 | show_copyright: true, 22 | out_same_file: false, 23 | max_line_length: 32 * 1024, 24 | unsafe: false, 25 | reserved_names: null, 26 | defines: { }, 27 | lift_vars: false, 28 | codegen_options: { 29 | ascii_only: false, 30 | beautify: false, 31 | indent_level: 4, 32 | indent_start: 0, 33 | quote_keys: false, 34 | space_colon: false, 35 | inline_script: false 36 | }, 37 | make: false, 38 | output: true // stdout 39 | }; 40 | 41 | var args = jsp.slice(process.argv, 2); 42 | var filename; 43 | 44 | out: while (args.length > 0) { 45 | var v = args.shift(); 46 | switch (v) { 47 | case "-b": 48 | case "--beautify": 49 | options.codegen_options.beautify = true; 50 | break; 51 | case "-c": 52 | case "--consolidate-primitive-values": 53 | options.consolidate = true; 54 | break; 55 | case "-i": 56 | case "--indent": 57 | options.codegen_options.indent_level = args.shift(); 58 | break; 59 | case "-q": 60 | case "--quote-keys": 61 | options.codegen_options.quote_keys = true; 62 | break; 63 | case "-mt": 64 | case "--mangle-toplevel": 65 | options.mangle_toplevel = true; 66 | break; 67 | case "-nmf": 68 | case "--no-mangle-functions": 69 | options.no_mangle_functions = true; 70 | break; 71 | case "--no-mangle": 72 | case "-nm": 73 | options.mangle = false; 74 | break; 75 | case "--no-squeeze": 76 | case "-ns": 77 | options.squeeze = false; 78 | break; 79 | case "--no-seqs": 80 | options.make_seqs = false; 81 | break; 82 | case "--no-dead-code": 83 | options.dead_code = false; 84 | break; 85 | case "--no-copyright": 86 | case "-nc": 87 | options.show_copyright = false; 88 | break; 89 | case "-o": 90 | case "--output": 91 | options.output = args.shift(); 92 | break; 93 | case "--overwrite": 94 | options.out_same_file = true; 95 | break; 96 | case "-v": 97 | case "--verbose": 98 | options.verbose = true; 99 | break; 100 | case "--ast": 101 | options.ast = true; 102 | break; 103 | case "--unsafe": 104 | options.unsafe = true; 105 | break; 106 | case "--max-line-len": 107 | options.max_line_length = parseInt(args.shift(), 10); 108 | break; 109 | case "--reserved-names": 110 | options.reserved_names = args.shift().split(","); 111 | break; 112 | case "--lift-vars": 113 | options.lift_vars = true; 114 | break; 115 | case "-d": 116 | case "--define": 117 | var defarg = args.shift(); 118 | try { 119 | var defsym = function(sym) { 120 | // KEYWORDS_ATOM doesn't include NaN or Infinity - should we check 121 | // for them too ?? We don't check reserved words and the like as the 122 | // define values are only substituted AFTER parsing 123 | if (jsp.KEYWORDS_ATOM.hasOwnProperty(sym)) { 124 | throw "Don't define values for inbuilt constant '"+sym+"'"; 125 | } 126 | return sym; 127 | }, 128 | defval = function(v) { 129 | if (v.match(/^"(.*)"$/) || v.match(/^'(.*)'$/)) { 130 | return [ "string", RegExp.$1 ]; 131 | } 132 | else if (!isNaN(parseFloat(v))) { 133 | return [ "num", parseFloat(v) ]; 134 | } 135 | else if (v.match(/^[a-z\$_][a-z\$_0-9]*$/i)) { 136 | return [ "name", v ]; 137 | } 138 | else if (!v.match(/"/)) { 139 | return [ "string", v ]; 140 | } 141 | else if (!v.match(/'/)) { 142 | return [ "string", v ]; 143 | } 144 | throw "Can't understand the specified value: "+v; 145 | }; 146 | if (defarg.match(/^([a-z_\$][a-z_\$0-9]*)(=(.*))?$/i)) { 147 | var sym = defsym(RegExp.$1), 148 | val = RegExp.$2 ? defval(RegExp.$2.substr(1)) : [ 'name', 'true' ]; 149 | options.defines[sym] = val; 150 | } 151 | else { 152 | throw "The --define option expects SYMBOL[=value]"; 153 | } 154 | } catch(ex) { 155 | sys.print("ERROR: In option --define "+defarg+"\n"+ex+"\n"); 156 | process.exit(1); 157 | } 158 | break; 159 | case "--define-from-module": 160 | var defmodarg = args.shift(); 161 | var defmodule = require(defmodarg); 162 | var sym, val; 163 | for (sym in defmodule) { 164 | if (defmodule.hasOwnProperty(sym)) { 165 | options.defines[sym] = function(val) { 166 | if (typeof val == "string") 167 | return [ "string", val ]; 168 | if (typeof val == "number") 169 | return [ "num", val ]; 170 | if (val === true) 171 | return [ 'name', 'true' ]; 172 | if (val === false) 173 | return [ 'name', 'false' ]; 174 | if (val === null) 175 | return [ 'name', 'null' ]; 176 | if (val === undefined) 177 | return [ 'name', 'undefined' ]; 178 | sys.print("ERROR: In option --define-from-module "+defmodarg+"\n"); 179 | sys.print("ERROR: Unknown object type for: "+sym+"="+val+"\n"); 180 | process.exit(1); 181 | return null; 182 | }(defmodule[sym]); 183 | } 184 | } 185 | break; 186 | case "--ascii": 187 | options.codegen_options.ascii_only = true; 188 | break; 189 | case "--make": 190 | options.make = true; 191 | break; 192 | case "--inline-script": 193 | options.codegen_options.inline_script = true; 194 | break; 195 | default: 196 | filename = v; 197 | break out; 198 | } 199 | } 200 | 201 | if (options.verbose) { 202 | pro.set_logger(function(msg){ 203 | sys.debug(msg); 204 | }); 205 | } 206 | 207 | jsp.set_logger(function(msg){ 208 | sys.debug(msg); 209 | }); 210 | 211 | if (options.make) { 212 | options.out_same_file = false; // doesn't make sense in this case 213 | var makefile = global.eval("(" + fs.readFileSync(filename || "Makefile.uglify.js").toString() + ")"); 214 | var dir = path.dirname(filename); 215 | output(makefile.files.map(function(file){ 216 | var code = fs.readFileSync(path.join(dir, file.name)).toString(); 217 | if (file.module) { 218 | code = "!function(exports, global){global = this;\n" + code + "\n;this." + file.module + " = exports;}({})"; 219 | } 220 | else if (file.hide) { 221 | code = "(function(){" + code + "}());"; 222 | } 223 | return squeeze_it(code); 224 | }).join("\n")); 225 | } 226 | else if (filename) { 227 | fs.readFile(filename, "utf8", function(err, text){ 228 | if (err) throw err; 229 | output(squeeze_it(text)); 230 | }); 231 | } 232 | else { 233 | var stdin = process.openStdin(); 234 | stdin.setEncoding("utf8"); 235 | var text = ""; 236 | stdin.on("data", function(chunk){ 237 | text += chunk; 238 | }); 239 | stdin.on("end", function() { 240 | output(squeeze_it(text)); 241 | }); 242 | } 243 | 244 | function output(text) { 245 | var out; 246 | if (options.out_same_file && filename) 247 | options.output = filename; 248 | if (options.output === true) { 249 | out = process.stdout; 250 | } else { 251 | out = fs.createWriteStream(options.output, { 252 | flags: "w", 253 | encoding: "utf8", 254 | mode: 0644 255 | }); 256 | } 257 | out.write(text.replace(/;*$/, ";")); 258 | if (options.output !== true) { 259 | out.end(); 260 | } 261 | }; 262 | 263 | // --------- main ends here. 264 | 265 | function show_copyright(comments) { 266 | var ret = ""; 267 | for (var i = 0; i < comments.length; ++i) { 268 | var c = comments[i]; 269 | if (c.type == "comment1") { 270 | ret += "//" + c.value + "\n"; 271 | } else { 272 | ret += "/*" + c.value + "*/"; 273 | } 274 | } 275 | return ret; 276 | }; 277 | 278 | function squeeze_it(code) { 279 | var result = ""; 280 | if (options.show_copyright) { 281 | var tok = jsp.tokenizer(code), c; 282 | c = tok(); 283 | result += show_copyright(c.comments_before); 284 | } 285 | try { 286 | var ast = time_it("parse", function(){ return jsp.parse(code); }); 287 | if (options.consolidate) ast = time_it("consolidate", function(){ 288 | return consolidator.ast_consolidate(ast); 289 | }); 290 | if (options.lift_vars) { 291 | ast = time_it("lift", function(){ return pro.ast_lift_variables(ast); }); 292 | } 293 | ast = time_it("mangle", function(){ 294 | return pro.ast_mangle(ast, { 295 | mangle : options.mangle, 296 | toplevel : options.mangle_toplevel, 297 | defines : options.defines, 298 | except : options.reserved_names, 299 | no_functions : options.no_mangle_functions 300 | }); 301 | }); 302 | if (options.squeeze) ast = time_it("squeeze", function(){ 303 | ast = pro.ast_squeeze(ast, { 304 | make_seqs : options.make_seqs, 305 | dead_code : options.dead_code, 306 | keep_comps : !options.unsafe, 307 | unsafe : options.unsafe 308 | }); 309 | if (options.unsafe) 310 | ast = pro.ast_squeeze_more(ast); 311 | return ast; 312 | }); 313 | if (options.ast) 314 | return sys.inspect(ast, null, null); 315 | result += time_it("generate", function(){ return pro.gen_code(ast, options.codegen_options) }); 316 | if (!options.codegen_options.beautify && options.max_line_length) { 317 | result = time_it("split", function(){ return pro.split_lines(result, options.max_line_length) }); 318 | } 319 | return result; 320 | } catch(ex) { 321 | sys.debug(ex.stack); 322 | sys.debug(sys.inspect(ex)); 323 | sys.debug(JSON.stringify(ex)); 324 | process.exit(1); 325 | } 326 | }; 327 | 328 | function time_it(name, cont) { 329 | if (!options.verbose) 330 | return cont(); 331 | var t1 = new Date().getTime(); 332 | try { return cont(); } 333 | finally { sys.debug("// " + name + ": " + ((new Date().getTime() - t1) / 1000).toFixed(3) + " sec."); } 334 | }; 335 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/docstyle.css: -------------------------------------------------------------------------------- 1 | html { font-family: "Lucida Grande","Trebuchet MS",sans-serif; font-size: 12pt; } 2 | body { max-width: 60em; } 3 | .title { text-align: center; } 4 | .todo { color: red; } 5 | .done { color: green; } 6 | .tag { background-color:lightblue; font-weight:normal } 7 | .target { } 8 | .timestamp { color: grey } 9 | .timestamp-kwd { color: CadetBlue } 10 | p.verse { margin-left: 3% } 11 | pre { 12 | border: 1pt solid #AEBDCC; 13 | background-color: #F3F5F7; 14 | padding: 5pt; 15 | font-family: monospace; 16 | font-size: 90%; 17 | overflow:auto; 18 | } 19 | pre.src { 20 | background-color: #eee; color: #112; border: 1px solid #000; 21 | } 22 | table { border-collapse: collapse; } 23 | td, th { vertical-align: top; } 24 | dt { font-weight: bold; } 25 | div.figure { padding: 0.5em; } 26 | div.figure p { text-align: center; } 27 | .linenr { font-size:smaller } 28 | .code-highlighted {background-color:#ffff00;} 29 | .org-info-js_info-navigation { border-style:none; } 30 | #org-info-js_console-label { font-size:10px; font-weight:bold; 31 | white-space:nowrap; } 32 | .org-info-js_search-highlight {background-color:#ffff00; color:#000000; 33 | font-weight:bold; } 34 | 35 | sup { 36 | vertical-align: baseline; 37 | position: relative; 38 | top: -0.5em; 39 | font-size: 80%; 40 | } 41 | 42 | sup a:link, sup a:visited { 43 | text-decoration: none; 44 | color: #c00; 45 | } 46 | 47 | sup a:before { content: "["; color: #999; } 48 | sup a:after { content: "]"; color: #999; } 49 | 50 | h1.title { border-bottom: 4px solid #000; padding-bottom: 5px; margin-bottom: 2em; } 51 | 52 | #postamble { 53 | color: #777; 54 | font-size: 90%; 55 | padding-top: 1em; padding-bottom: 1em; border-top: 1px solid #999; 56 | margin-top: 2em; 57 | padding-left: 2em; 58 | padding-right: 2em; 59 | text-align: right; 60 | } 61 | 62 | #postamble p { margin: 0; } 63 | 64 | #footnotes { border-top: 1px solid #000; } 65 | 66 | h1 { font-size: 200% } 67 | h2 { font-size: 175% } 68 | h3 { font-size: 150% } 69 | h4 { font-size: 125% } 70 | 71 | h1, h2, h3, h4 { font-family: "Bookman",Georgia,"Times New Roman",serif; font-weight: normal; } 72 | 73 | @media print { 74 | html { font-size: 11pt; } 75 | } 76 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/lib/squeeze-more.js: -------------------------------------------------------------------------------- 1 | var jsp = require("./parse-js"), 2 | pro = require("./process"), 3 | slice = jsp.slice, 4 | member = jsp.member, 5 | curry = jsp.curry, 6 | MAP = pro.MAP, 7 | PRECEDENCE = jsp.PRECEDENCE, 8 | OPERATORS = jsp.OPERATORS; 9 | 10 | function ast_squeeze_more(ast) { 11 | var w = pro.ast_walker(), walk = w.walk, scope; 12 | function with_scope(s, cont) { 13 | var save = scope, ret; 14 | scope = s; 15 | ret = cont(); 16 | scope = save; 17 | return ret; 18 | }; 19 | function _lambda(name, args, body) { 20 | return [ this[0], name, args, with_scope(body.scope, curry(MAP, body, walk)) ]; 21 | }; 22 | return w.with_walkers({ 23 | "toplevel": function(body) { 24 | return [ this[0], with_scope(this.scope, curry(MAP, body, walk)) ]; 25 | }, 26 | "function": _lambda, 27 | "defun": _lambda, 28 | "new": function(ctor, args) { 29 | if (ctor[0] == "name") { 30 | if (ctor[1] == "Array" && !scope.has("Array")) { 31 | if (args.length != 1) { 32 | return [ "array", args ]; 33 | } else { 34 | return walk([ "call", [ "name", "Array" ], args ]); 35 | } 36 | } else if (ctor[1] == "Object" && !scope.has("Object")) { 37 | if (!args.length) { 38 | return [ "object", [] ]; 39 | } else { 40 | return walk([ "call", [ "name", "Object" ], args ]); 41 | } 42 | } else if ((ctor[1] == "RegExp" || ctor[1] == "Function" || ctor[1] == "Error") && !scope.has(ctor[1])) { 43 | return walk([ "call", [ "name", ctor[1] ], args]); 44 | } 45 | } 46 | }, 47 | "call": function(expr, args) { 48 | if (expr[0] == "dot" && expr[1][0] == "string" && args.length == 1 49 | && (args[0][1] > 0 && expr[2] == "substring" || expr[2] == "substr")) { 50 | return [ "call", [ "dot", expr[1], "slice"], args]; 51 | } 52 | if (expr[0] == "dot" && expr[2] == "toString" && args.length == 0) { 53 | // foo.toString() ==> foo+"" 54 | if (expr[1][0] == "string") return expr[1]; 55 | return [ "binary", "+", expr[1], [ "string", "" ]]; 56 | } 57 | if (expr[0] == "name") { 58 | if (expr[1] == "Array" && args.length != 1 && !scope.has("Array")) { 59 | return [ "array", args ]; 60 | } 61 | if (expr[1] == "Object" && !args.length && !scope.has("Object")) { 62 | return [ "object", [] ]; 63 | } 64 | if (expr[1] == "String" && !scope.has("String")) { 65 | return [ "binary", "+", args[0], [ "string", "" ]]; 66 | } 67 | } 68 | } 69 | }, function() { 70 | return walk(pro.ast_add_scope(ast)); 71 | }); 72 | }; 73 | 74 | exports.ast_squeeze_more = ast_squeeze_more; 75 | 76 | // Local variables: 77 | // js-indent-level: 4 78 | // End: 79 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/test/beautify.js: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env node 2 | 3 | global.sys = require("sys"); 4 | var fs = require("fs"); 5 | 6 | var jsp = require("../lib/parse-js"); 7 | var pro = require("../lib/process"); 8 | 9 | var filename = process.argv[2]; 10 | fs.readFile(filename, "utf8", function(err, text){ 11 | try { 12 | var ast = time_it("parse", function(){ return jsp.parse(text); }); 13 | ast = time_it("mangle", function(){ return pro.ast_mangle(ast); }); 14 | ast = time_it("squeeze", function(){ return pro.ast_squeeze(ast); }); 15 | var gen = time_it("generate", function(){ return pro.gen_code(ast, false); }); 16 | sys.puts(gen); 17 | } catch(ex) { 18 | sys.debug(ex.stack); 19 | sys.debug(sys.inspect(ex)); 20 | sys.debug(JSON.stringify(ex)); 21 | } 22 | }); 23 | 24 | function time_it(name, cont) { 25 | var t1 = new Date().getTime(); 26 | try { return cont(); } 27 | finally { sys.debug("// " + name + ": " + ((new Date().getTime() - t1) / 1000).toFixed(3) + " sec."); } 28 | }; 29 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/test/testparser.js: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env node 2 | global.DIGITS_OVERRIDE_FOR_TESTING = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789"; 3 | 4 | var parseJS = require("../lib/parse-js"); 5 | var sys = require("util"); 6 | 7 | // write debug in a very straightforward manner 8 | var debug = function(){ 9 | sys.log(Array.prototype.slice.call(arguments).join(', ')); 10 | }; 11 | 12 | var testsPassed = true; 13 | 14 | ParserTestSuite(function(i, input, desc){ 15 | try { 16 | parseJS.parse(input); 17 | debug("ok " + i + ": " + desc); 18 | } catch(e){ 19 | debug("FAIL " + i + " " + desc + " (" + e + ")"); 20 | testsPassed = false; 21 | } 22 | }); 23 | 24 | process.exit(testsPassed ? 0 : 1); 25 | 26 | function ParserTestSuite(callback){ 27 | var inps = [ 28 | ["var abc;", "Regular variable statement w/o assignment"], 29 | ["var abc = 5;", "Regular variable statement with assignment"], 30 | ["/* */;", "Multiline comment"], 31 | ['/** **/;', 'Double star multiline comment'], 32 | ["var f = function(){;};", "Function expression in var assignment"], 33 | ['hi; // moo\n;', 'single line comment'], 34 | ['var varwithfunction;', 'Dont match keywords as substrings'], // difference between `var withsomevar` and `"str"` (local search and lits) 35 | ['a + b;', 'addition'], 36 | ["'a';", 'single string literal'], 37 | ["'a\\n';", 'single string literal with escaped return'], 38 | ['"a";', 'double string literal'], 39 | ['"a\\n";', 'double string literal with escaped return'], 40 | ['"var";', 'string is a keyword'], 41 | ['"variable";', 'string starts with a keyword'], 42 | ['"somevariable";', 'string contains a keyword'], 43 | ['"somevar";', 'string ends with a keyword'], 44 | ['500;', 'int literal'], 45 | ['500.;', 'float literal w/o decimals'], 46 | ['500.432;', 'float literal with decimals'], 47 | ['.432432;', 'float literal w/o int'], 48 | ['(a,b,c);', 'parens and comma'], 49 | ['[1,2,abc];', 'array literal'], 50 | ['var o = {a:1};', 'object literal unquoted key'], 51 | ['var o = {"b":2};', 'object literal quoted key'], // opening curly may not be at the start of a statement... 52 | ['var o = {c:c};', 'object literal keyname is identifier'], 53 | ['var o = {a:1,"b":2,c:c};', 'object literal combinations'], 54 | ['var x;\nvar y;', 'two lines'], 55 | ['var x;\nfunction n(){; }', 'function def'], 56 | ['var x;\nfunction n(abc){; }', 'function def with arg'], 57 | ['var x;\nfunction n(abc, def){ ;}', 'function def with args'], 58 | ['function n(){ "hello"; }', 'function def with body'], 59 | ['/a/;', 'regex literal'], 60 | ['/a/b;', 'regex literal with flag'], 61 | ['/a/ / /b/;', 'regex div regex'], 62 | ['a/b/c;', 'triple division looks like regex'], 63 | ['+function(){/regex/;};', 'regex at start of function body'], 64 | // http://code.google.com/p/es-lab/source/browse/trunk/tests/parser/parsertests.js?r=86 65 | // http://code.google.com/p/es-lab/source/browse/trunk/tests/parser/parsertests.js?r=430 66 | 67 | // first tests for the lexer, should also parse as program (when you append a semi) 68 | 69 | // comments 70 | ['//foo!@#^&$1234\nbar;', 'single line comment'], 71 | ['/* abcd!@#@$* { } && null*/;', 'single line multi line comment'], 72 | ['/*foo\nbar*/;','multi line comment'], 73 | ['/*x*x*/;','multi line comment with *'], 74 | ['/**/;','empty comment'], 75 | // identifiers 76 | ["x;",'1 identifier'], 77 | ["_x;",'2 identifier'], 78 | ["xyz;",'3 identifier'], 79 | ["$x;",'4 identifier'], 80 | ["x$;",'5 identifier'], 81 | ["_;",'6 identifier'], 82 | ["x5;",'7 identifier'], 83 | ["x_y;",'8 identifier'], 84 | ["x+5;",'9 identifier'], 85 | ["xyz123;",'10 identifier'], 86 | ["x1y1z1;",'11 identifier'], 87 | ["foo\\u00D8bar;",'12 identifier unicode escape'], 88 | //["foo�bar;",'13 identifier unicode embedded (might fail)'], 89 | // numbers 90 | ["5;", '1 number'], 91 | ["5.5;", '2 number'], 92 | ["0;", '3 number'], 93 | ["0.0;", '4 number'], 94 | ["0.001;", '5 number'], 95 | ["1.e2;", '6 number'], 96 | ["1.e-2;", '7 number'], 97 | ["1.E2;", '8 number'], 98 | ["1.E-2;", '9 number'], 99 | [".5;", '10 number'], 100 | [".5e3;", '11 number'], 101 | [".5e-3;", '12 number'], 102 | ["0.5e3;", '13 number'], 103 | ["55;", '14 number'], 104 | ["123;", '15 number'], 105 | ["55.55;", '16 number'], 106 | ["55.55e10;", '17 number'], 107 | ["123.456;", '18 number'], 108 | ["1+e;", '20 number'], 109 | ["0x01;", '22 number'], 110 | ["0XCAFE;", '23 number'], 111 | ["0x12345678;", '24 number'], 112 | ["0x1234ABCD;", '25 number'], 113 | ["0x0001;", '26 number'], 114 | // strings 115 | ["\"foo\";", '1 string'], 116 | ["\'foo\';", '2 string'], 117 | ["\"x\";", '3 string'], 118 | ["\'\';", '4 string'], 119 | ["\"foo\\tbar\";", '5 string'], 120 | ["\"!@#$%^&*()_+{}[]\";", '6 string'], 121 | ["\"/*test*/\";", '7 string'], 122 | ["\"//test\";", '8 string'], 123 | ["\"\\\\\";", '9 string'], 124 | ["\"\\u0001\";", '10 string'], 125 | ["\"\\uFEFF\";", '11 string'], 126 | ["\"\\u10002\";", '12 string'], 127 | ["\"\\x55\";", '13 string'], 128 | ["\"\\x55a\";", '14 string'], 129 | ["\"a\\\\nb\";", '15 string'], 130 | ['";"', '16 string: semi in a string'], 131 | ['"a\\\nb";', '17 string: line terminator escape'], 132 | // literals 133 | ["null;", "null"], 134 | ["true;", "true"], 135 | ["false;", "false"], 136 | // regex 137 | ["/a/;", "1 regex"], 138 | ["/abc/;", "2 regex"], 139 | ["/abc[a-z]*def/g;", "3 regex"], 140 | ["/\\b/;", "4 regex"], 141 | ["/[a-zA-Z]/;", "5 regex"], 142 | 143 | // program tests (for as far as they havent been covered above) 144 | 145 | // regexp 146 | ["/foo(.*)/g;", "another regexp"], 147 | // arrays 148 | ["[];", "1 array"], 149 | ["[ ];", "2 array"], 150 | ["[1];", "3 array"], 151 | ["[1,2];", "4 array"], 152 | ["[1,2,,];", "5 array"], 153 | ["[1,2,3];", "6 array"], 154 | ["[1,2,3,,,];", "7 array"], 155 | // objects 156 | ["{};", "1 object"], 157 | ["({x:5});", "2 object"], 158 | ["({x:5,y:6});", "3 object"], 159 | ["({x:5,});", "4 object"], 160 | ["({if:5});", "5 object"], 161 | ["({ get x() {42;} });", "6 object"], 162 | ["({ set y(a) {1;} });", "7 object"], 163 | // member expression 164 | ["o.m;", "1 member expression"], 165 | ["o['m'];", "2 member expression"], 166 | ["o['n']['m'];", "3 member expression"], 167 | ["o.n.m;", "4 member expression"], 168 | ["o.if;", "5 member expression"], 169 | // call and invoke expressions 170 | ["f();", "1 call/invoke expression"], 171 | ["f(x);", "2 call/invoke expression"], 172 | ["f(x,y);", "3 call/invoke expression"], 173 | ["o.m();", "4 call/invoke expression"], 174 | ["o['m'];", "5 call/invoke expression"], 175 | ["o.m(x);", "6 call/invoke expression"], 176 | ["o['m'](x);", "7 call/invoke expression"], 177 | ["o.m(x,y);", "8 call/invoke expression"], 178 | ["o['m'](x,y);", "9 call/invoke expression"], 179 | ["f(x)(y);", "10 call/invoke expression"], 180 | ["f().x;", "11 call/invoke expression"], 181 | 182 | // eval 183 | ["eval('x');", "1 eval"], 184 | ["(eval)('x');", "2 eval"], 185 | ["(1,eval)('x');", "3 eval"], 186 | ["eval(x,y);", "4 eval"], 187 | // new expression 188 | ["new f();", "1 new expression"], 189 | ["new o;", "2 new expression"], 190 | ["new o.m;", "3 new expression"], 191 | ["new o.m(x);", "4 new expression"], 192 | ["new o.m(x,y);", "5 new expression"], 193 | // prefix/postfix 194 | ["++x;", "1 pre/postfix"], 195 | ["x++;", "2 pre/postfix"], 196 | ["--x;", "3 pre/postfix"], 197 | ["x--;", "4 pre/postfix"], 198 | ["x ++;", "5 pre/postfix"], 199 | ["x /* comment */ ++;", "6 pre/postfix"], 200 | ["++ /* comment */ x;", "7 pre/postfix"], 201 | // unary operators 202 | ["delete x;", "1 unary operator"], 203 | ["void x;", "2 unary operator"], 204 | ["+ x;", "3 unary operator"], 205 | ["-x;", "4 unary operator"], 206 | ["~x;", "5 unary operator"], 207 | ["!x;", "6 unary operator"], 208 | // meh 209 | ["new Date++;", "new date ++"], 210 | ["+x++;", " + x ++"], 211 | // expression expressions 212 | ["1 * 2;", "1 expression expressions"], 213 | ["1 / 2;", "2 expression expressions"], 214 | ["1 % 2;", "3 expression expressions"], 215 | ["1 + 2;", "4 expression expressions"], 216 | ["1 - 2;", "5 expression expressions"], 217 | ["1 << 2;", "6 expression expressions"], 218 | ["1 >>> 2;", "7 expression expressions"], 219 | ["1 >> 2;", "8 expression expressions"], 220 | ["1 * 2 + 3;", "9 expression expressions"], 221 | ["(1+2)*3;", "10 expression expressions"], 222 | ["1*(2+3);", "11 expression expressions"], 223 | ["xy;", "13 expression expressions"], 225 | ["x<=y;", "14 expression expressions"], 226 | ["x>=y;", "15 expression expressions"], 227 | ["x instanceof y;", "16 expression expressions"], 228 | ["x in y;", "17 expression expressions"], 229 | ["x&y;", "18 expression expressions"], 230 | ["x^y;", "19 expression expressions"], 231 | ["x|y;", "20 expression expressions"], 232 | ["x+y>>= y;", "1 assignment"], 245 | ["x <<= y;", "2 assignment"], 246 | ["x = y;", "3 assignment"], 247 | ["x += y;", "4 assignment"], 248 | ["x /= y;", "5 assignment"], 249 | // comma 250 | ["x, y;", "comma"], 251 | // block 252 | ["{};", "1 block"], 253 | ["{x;};", "2 block"], 254 | ["{x;y;};", "3 block"], 255 | // vars 256 | ["var x;", "1 var"], 257 | ["var x,y;", "2 var"], 258 | ["var x=1,y=2;", "3 var"], 259 | ["var x,y=2;", "4 var"], 260 | // empty 261 | [";", "1 empty"], 262 | ["\n;", "2 empty"], 263 | // expression statement 264 | ["x;", "1 expression statement"], 265 | ["5;", "2 expression statement"], 266 | ["1+2;", "3 expression statement"], 267 | // if 268 | ["if (c) x; else y;", "1 if statement"], 269 | ["if (c) x;", "2 if statement"], 270 | ["if (c) {} else {};", "3 if statement"], 271 | ["if (c1) if (c2) s1; else s2;", "4 if statement"], 272 | // while 273 | ["do s; while (e);", "1 while statement"], 274 | ["do { s; } while (e);", "2 while statement"], 275 | ["while (e) s;", "3 while statement"], 276 | ["while (e) { s; };", "4 while statement"], 277 | // for 278 | ["for (;;) ;", "1 for statement"], 279 | ["for (;c;x++) x;", "2 for statement"], 280 | ["for (i;i> 1; 3 | var c = 8 >>> 1; -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/test/unit/compress/test/issue34.js: -------------------------------------------------------------------------------- 1 | var a = {}; 2 | a["this"] = 1; 3 | a["that"] = 2; -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/test/unit/compress/test/issue349.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | var cake 3 | if (noFreeCakes) return /* I would 4 | insert something 5 | there, but I'm sort 6 | of lazy so whatever. 7 | */ cake = new FreeCake() 8 | return cake 9 | })() 10 | 11 | (function () { 12 | var cake 13 | if (noFreeCakes) return /* I would insert something there, */ /* 14 | but I'm sort of lazy so 15 | */ /* whatever. */ cake = new FreeCake() 16 | return cake 17 | })() 18 | 19 | (function () { 20 | var cake 21 | if (noFreeCakes) return // I would insert something there, but I'm sort of lazy so whatever. 22 | cake = new FreeCake() 23 | return cake 24 | })() 25 | 26 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/test/unit/compress/test/issue353.js: -------------------------------------------------------------------------------- 1 | function test() { 2 | debugger; 3 | return; 4 | } 5 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/test/unit/compress/test/issue372.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | "use strict"; 3 | 4 | function a() { 5 | void "a"; 6 | function b() { 7 | "use strict"; 8 | void "b"; 9 | function c() { 10 | "use strict"; 11 | void "c"; 12 | } 13 | function d() { 14 | "salmon"; 15 | void "d"; 16 | } 17 | } 18 | function e() { 19 | "salmon"; 20 | void "e"; 21 | function f() { 22 | "use strict"; 23 | "salmon"; 24 | void "f"; 25 | for (var i = 0; i < 10; i++) var g = function() { 26 | "use strict"; 27 | "salmon"; 28 | void "g"; 29 | }(); 30 | } 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/test/unit/compress/test/issue4.js: -------------------------------------------------------------------------------- 1 | var a = 2e3; 2 | var b = 2e-3; 3 | var c = 2e-5; -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/test/unit/compress/test/issue48.js: -------------------------------------------------------------------------------- 1 | var s, i; s = ''; i = 0; -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/test/unit/compress/test/issue50.js: -------------------------------------------------------------------------------- 1 | function bar(a) { 2 | try { 3 | foo(); 4 | } catch(e) { 5 | alert("Exception caught (foo not defined)"); 6 | } 7 | alert(a); // 10 in FF, "[object Error]" in IE 8 | } 9 | bar(10); 10 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/test/unit/compress/test/issue53.js: -------------------------------------------------------------------------------- 1 | x = (y, z) 2 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/test/unit/compress/test/issue54.1.js: -------------------------------------------------------------------------------- 1 | foo.toString(); 2 | a.toString(16); 3 | b.toString.call(c); 4 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/test/unit/compress/test/issue68.js: -------------------------------------------------------------------------------- 1 | function f() { 2 | if (a) return; 3 | g(); 4 | function g(){} 5 | }; 6 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/test/unit/compress/test/issue69.js: -------------------------------------------------------------------------------- 1 | [(a,b)] 2 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/test/unit/compress/test/issue9.js: -------------------------------------------------------------------------------- 1 | var a = { 2 | a: 1, 3 | b: 2, // <-- trailing comma 4 | }; 5 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/test/unit/compress/test/issues222_324.js: -------------------------------------------------------------------------------- 1 | !function() { 2 | 'use strict'; 3 | 4 | var 七, // issue #222 5 | $1, // issue #222 6 | ლ_ಠ益ಠ_ლ; // issue #324 7 | }; 8 | 9 | !function() { 10 | 'use strict'; 11 | 12 | // test if Unicode canonical equivalence is ignored 13 | var \u006E\u0303, 14 | \u00F1; 15 | }; 16 | 17 | !function() { 18 | 'use strict'; 19 | 20 | var \uFF38, // X Lu (third to last) 21 | \uFF58, // x Ll (third to last) 22 | \u1FBC, // ᾼ Lt (third to last) 23 | \uFF70, // ー Lm (third to last) 24 | \u4DB3, // 䶳 Lo (third to last within a range) 25 | \u97CA, // 韊 Lo (third to last within a range) 26 | \uD7A1, // 힡 Lo (third to last within a range) 27 | \uFFDA, // ᅳ Lo (third to last) 28 | \uA6ED, // ꛭ Nl (third to last) 29 | \u0024, // $ 30 | \u005F, // _ 31 | \u0024\uFF38, // X Lu (third to last) 32 | \u0024\uFF58, // x Ll (third to last) 33 | \u0024\u1FBC, // ᾼ Lt (third to last) 34 | \u0024\uFF70, // ー Lm (third to last) 35 | \u0024\u4DB3, // 䶳 Lo (third to last within a range) 36 | \u0024\u97CA, // 韊 Lo (third to last within a range) 37 | \u0024\uD7A1, // 힡 Lo (third to last within a range) 38 | \u0024\uFFDA, // ᅳ Lo (third to last) 39 | \u0024\uA6ED, // ꛭ Nl (third to last) 40 | \u0024\uFE24, // ︤ Mn (third to last) 41 | \u0024\uABE9, // ꯩ Mc (third to last) 42 | \u0024\uFF17, // 7 Nd (third to last) 43 | \u0024\uFE4E, // ﹎ Pc (third to last) 44 | \u0024\u200C, // ZERO WIDTH NON-JOINER 45 | \u0024\u200D, // ZERO WIDTH JOINER 46 | \u0024\u0024, // $ 47 | \u0024\u005F; // _ 48 | }; 49 | 50 | !function() { 51 | 'use strict'; 52 | 53 | var X, 54 | x, 55 | ᾼ, 56 | ー, 57 | 䶳, 58 | 韊, 59 | 힡, 60 | ᅳ, 61 | ꛭ, 62 | $, 63 | _, 64 | $X, 65 | $x, 66 | $ᾼ, 67 | $ー, 68 | $䶳, 69 | $韊, 70 | $힡, 71 | $ᅳ, 72 | $ꛭ, 73 | $︤, 74 | $ꯩ, 75 | $7, 76 | $﹎, 77 | $‌, 78 | $‍, 79 | $$, 80 | $_; 81 | }; 82 | 83 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/test/unit/compress/test/mangle.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var x = function fun(a, fun, b) { 3 | return fun; 4 | }; 5 | }()); 6 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/test/unit/compress/test/null_string.js: -------------------------------------------------------------------------------- 1 | var nullString = "\0" -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/test/unit/compress/test/strict-equals.js: -------------------------------------------------------------------------------- 1 | typeof a === 'string' 2 | b + "" !== c + "" 3 | d < e === f < g 4 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/test/unit/compress/test/var.js: -------------------------------------------------------------------------------- 1 | // var declarations after each other should be combined 2 | var a = 1; 3 | var b = 2; -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/test/unit/compress/test/whitespace.js: -------------------------------------------------------------------------------- 1 | function id(a) { 2 | // Form-Feed 3 | // Vertical Tab 4 | // No-Break Space 5 | ᠎// Mongolian Vowel Separator 6 |  // En quad 7 |  // Em quad 8 |  // En space 9 |  // Em space 10 |  // Three-Per-Em Space 11 |  // Four-Per-Em Space 12 |  // Six-Per-Em Space 13 |  // Figure Space 14 |  // Punctuation Space 15 |  // Thin Space 16 |  // Hair Space 17 |  // Narrow No-Break Space 18 |  // Medium Mathematical Space 19 |  // Ideographic Space 20 | return a; 21 | } 22 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/test/unit/compress/test/with.js: -------------------------------------------------------------------------------- 1 | with({}) { 2 | }; 3 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/test/unit/scripts.js: -------------------------------------------------------------------------------- 1 | global.DIGITS_OVERRIDE_FOR_TESTING = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789"; 2 | 3 | var fs = require('fs'), 4 | uglify = require('../../uglify-js'), 5 | jsp = uglify.parser, 6 | nodeunit = require('nodeunit'), 7 | path = require('path'), 8 | pro = uglify.uglify; 9 | 10 | var Script = process.binding('evals').Script; 11 | 12 | var scriptsPath = __dirname; 13 | 14 | function compress(code) { 15 | var ast = jsp.parse(code); 16 | ast = pro.ast_mangle(ast, { mangle: true }); 17 | ast = pro.ast_squeeze(ast, { no_warnings: true }); 18 | ast = pro.ast_squeeze_more(ast); 19 | return pro.gen_code(ast); 20 | }; 21 | 22 | var testDir = path.join(scriptsPath, "compress", "test"); 23 | var expectedDir = path.join(scriptsPath, "compress", "expected"); 24 | 25 | function getTester(script) { 26 | return function(test) { 27 | var testPath = path.join(testDir, script); 28 | var expectedPath = path.join(expectedDir, script); 29 | var content = fs.readFileSync(testPath, 'utf-8'); 30 | var outputCompress = compress(content); 31 | 32 | // Check if the noncompressdata is larger or same size as the compressed data 33 | test.ok(content.length >= outputCompress.length); 34 | 35 | // Check that a recompress gives the same result 36 | var outputReCompress = compress(content); 37 | test.equal(outputCompress, outputReCompress); 38 | 39 | // Check if the compressed output is what is expected 40 | var expected = fs.readFileSync(expectedPath, 'utf-8'); 41 | test.equal(outputCompress, expected.replace(/(\r?\n)+$/, "")); 42 | 43 | test.done(); 44 | }; 45 | }; 46 | 47 | var tests = {}; 48 | 49 | var scripts = fs.readdirSync(testDir); 50 | for (var i in scripts) { 51 | var script = scripts[i]; 52 | if (/\.js$/.test(script)) { 53 | tests[script] = getTester(script); 54 | } 55 | } 56 | 57 | module.exports = nodeunit.testCase(tests); 58 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/tmp/hoist.js: -------------------------------------------------------------------------------- 1 | function foo(arg1, arg2, arg3, arg4, arg5, arg6) { 2 | var a = 5; 3 | { 4 | var d = 10, mak = 20, buz = 30; 5 | var q = buz * 2; 6 | } 7 | if (moo) { 8 | var a, b, c; 9 | } 10 | for (var arg1 = 0, d = 20; arg1 < 10; ++arg1) 11 | console.log(arg3); 12 | for (var i in mak) {} 13 | for (j in d) {} 14 | var d; 15 | 16 | function test() { 17 | 18 | }; 19 | 20 | //test(); 21 | 22 | (function moo(first, second){ 23 | console.log(first); 24 | })(1); 25 | 26 | (function moo(first, second){ 27 | console.log(moo()); 28 | })(1); 29 | } 30 | 31 | 32 | var foo; 33 | var bar; 34 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/tmp/instrument.js: -------------------------------------------------------------------------------- 1 | // sample on how to use the parser and walker API to instrument some code 2 | 3 | var jsp = require("uglify-js").parser; 4 | var pro = require("uglify-js").uglify; 5 | 6 | function instrument(code) { 7 | var ast = jsp.parse(code, false, true); // true for the third arg specifies that we want 8 | // to have start/end tokens embedded in the 9 | // statements 10 | var w = pro.ast_walker(); 11 | 12 | // we're gonna need this to push elements that we're currently looking at, to avoid 13 | // endless recursion. 14 | var analyzing = []; 15 | function do_stat() { 16 | var ret; 17 | if (this[0].start && analyzing.indexOf(this) < 0) { 18 | // without the `analyzing' hack, w.walk(this) would re-enter here leading 19 | // to infinite recursion 20 | analyzing.push(this); 21 | ret = [ "splice", // XXX: "block" is safer 22 | [ [ "stat", 23 | [ "call", [ "name", "trace" ], 24 | [ [ "string", this[0].toString() ], 25 | [ "num", this[0].start.line ], 26 | [ "num", this[0].start.col ], 27 | [ "num", this[0].end.line ], 28 | [ "num", this[0].end.col ]]]], 29 | w.walk(this) ]]; 30 | analyzing.pop(this); 31 | } 32 | return ret; 33 | }; 34 | var new_ast = w.with_walkers({ 35 | "stat" : do_stat, 36 | "label" : do_stat, 37 | "break" : do_stat, 38 | "continue" : do_stat, 39 | "debugger" : do_stat, 40 | "var" : do_stat, 41 | "const" : do_stat, 42 | "return" : do_stat, 43 | "throw" : do_stat, 44 | "try" : do_stat, 45 | "defun" : do_stat, 46 | "if" : do_stat, 47 | "while" : do_stat, 48 | "do" : do_stat, 49 | "for" : do_stat, 50 | "for-in" : do_stat, 51 | "switch" : do_stat, 52 | "with" : do_stat 53 | }, function(){ 54 | return w.walk(ast); 55 | }); 56 | return pro.gen_code(new_ast, { beautify: true }); 57 | } 58 | 59 | 60 | 61 | 62 | ////// test code follows. 63 | 64 | var code = instrument(test.toString()); 65 | console.log(code); 66 | 67 | function test() { 68 | // simple stats 69 | a = 5; 70 | c += a + b; 71 | "foo"; 72 | 73 | // var 74 | var foo = 5; 75 | const bar = 6, baz = 7; 76 | 77 | // switch block. note we can't track case lines the same way. 78 | switch ("foo") { 79 | case "foo": 80 | return 1; 81 | case "bar": 82 | return 2; 83 | } 84 | 85 | // for/for in 86 | for (var i = 0; i < 5; ++i) { 87 | console.log("Hello " + i); 88 | } 89 | for (var i in [ 1, 2, 3]) { 90 | console.log(i); 91 | } 92 | 93 | // note however that the following is broken. I guess we 94 | // should add the block brackets in this case... 95 | for (var i = 0; i < 5; ++i) 96 | console.log("foo"); 97 | } 98 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/tmp/test.js: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env node 2 | 3 | global.sys = require(/^v0\.[012]/.test(process.version) ? "sys" : "util"); 4 | var fs = require("fs"); 5 | var uglify = require("uglify-js"), // symlink ~/.node_libraries/uglify-js.js to ../uglify-js.js 6 | jsp = uglify.parser, 7 | pro = uglify.uglify; 8 | 9 | var code = fs.readFileSync("hoist.js", "utf8"); 10 | var ast = jsp.parse(code); 11 | 12 | ast = pro.ast_lift_variables(ast); 13 | 14 | var w = pro.ast_walker(); 15 | ast = w.with_walkers({ 16 | "function": function() { 17 | var node = w.dive(this); // walk depth first 18 | console.log(pro.gen_code(node, { beautify: true })); 19 | return node; 20 | }, 21 | "name": function(name) { 22 | return [ this[0], "X" ]; 23 | } 24 | }, function(){ 25 | return w.walk(ast); 26 | }); 27 | 28 | console.log(pro.gen_code(ast, { 29 | beautify: true 30 | })); 31 | -------------------------------------------------------------------------------- /2.0/node_modules/uglify-js/uglify-js.js: -------------------------------------------------------------------------------- 1 | //convienence function(src, [options]); 2 | function uglify(orig_code, options){ 3 | options || (options = {}); 4 | var jsp = uglify.parser; 5 | var pro = uglify.uglify; 6 | 7 | var ast = jsp.parse(orig_code, options.strict_semicolons); // parse code and get the initial AST 8 | ast = pro.ast_mangle(ast, options.mangle_options); // get a new AST with mangled names 9 | ast = pro.ast_squeeze(ast, options.squeeze_options); // get an AST with compression optimizations 10 | var final_code = pro.gen_code(ast, options.gen_options); // compressed code here 11 | return final_code; 12 | }; 13 | 14 | uglify.parser = require("./lib/parse-js"); 15 | uglify.uglify = require("./lib/process"); 16 | uglify.consolidator = require("./lib/consolidator"); 17 | 18 | module.exports = uglify 19 | -------------------------------------------------------------------------------- /2.0/sohu.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2.0/source/163open.js: -------------------------------------------------------------------------------- 1 | '网易公开课' && youkuhtml5playerbookmark2.add(function(core, canPlayM3U8){ 2 | var m3u8 = function(callback){ 3 | callback({ 4 | '高清': window.openCourse.getCurrentMovie().appsrc 5 | }); 6 | }; 7 | return{ 8 | reg: /v\.163\.com/.test(window.location.host) && window.openCourse && canPlayM3U8, 9 | call: function(callback){ 10 | return m3u8(function(urls){ 11 | return callback({ urls: urls, flashElementId: 'FPlayer' }); 12 | }); 13 | } 14 | } 15 | }); -------------------------------------------------------------------------------- /2.0/source/56.js: -------------------------------------------------------------------------------- 1 | '56' && youkuhtml5playerbookmark2.add(function(core, canPlayM3U8){ 2 | var page = window._page_; 3 | var mp4 = function(callback){ 4 | if(page.channel == 'view'){ 5 | var vid = location.href.match(/v\_([0-9a-zA-Z]+)\.html/); 6 | if(vid){ 7 | vid = vid[1]; 8 | callback({'高清': 'http://vxml.56.com/m3u8/'+vid+'/'}); 9 | } 10 | }else{ 11 | var back = 'jsonp_dfInfo'; 12 | var backup = window[back]; 13 | core.jsonp( 14 | 'http://vxml.56.com/ipad/'+(window.oFlv.o.id || window._oFlv_c.id)+'/?src=site&callback=', 15 | function(param){ 16 | urlList = param.df; 17 | var urls = {}; 18 | for(var i=param.df.length-1;i>=0;i--){ 19 | urls[param.df[i]['type']] = param.df[i]['url']; 20 | } 21 | callback(urls); 22 | window[back] = backup; 23 | }, 24 | back 25 | ) 26 | } 27 | }; 28 | return{ 29 | reg: /56\.com/.test(window.location.host) && page, 30 | call: function(callback){ 31 | return mp4(function(urls){ 32 | return callback({ urls: urls, flashElementId: 'mod_player' }); 33 | }); 34 | } 35 | } 36 | }); 37 | -------------------------------------------------------------------------------- /2.0/source/acfun.js: -------------------------------------------------------------------------------- 1 | 'acfun' && youkuhtml5playerbookmark2.add(function(core, canPlayM3U8){ 2 | var sina = function(vid, callback, commentInfo){ 3 | callback({ 'sina': 'http://edge.v.iask.com.sinastorage.com/'+vid+'.mp4'}, commentInfo); 4 | }; 5 | var youku = function(vid, callback, commentInfo){ 6 | if(false && canPlayM3U8){ 7 | callback({ 8 | '标清': 'http://v.youku.com/player/getM3U8/vid/'+vid+'/type/flv/ts/'+(new Date()).getTime().toString().substring(0,10)+'/sc/2/useKeyframe/0/v.m3u8', 9 | '原画': 'http://v.youku.com/player/getM3U8/vid/'+vid+'/type/hd2/ts/'+(new Date()).getTime().toString().substring(0,10)+'/sc/2/useKeyframe/0/v.m3u8' 10 | }, commentInfo); 11 | }else{ 12 | core.jsonp( 13 | 'http://zythum.sinaapp.com/youkuhtml5playerbookmark/getyoukuid.php?id='+vid+'&callback=', 14 | function(param){ 15 | function getFileIDMixString(seed){ 16 | var source = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/\\:._-1234567890".split(''), 17 | mixed = [],index; 18 | for (var i=0, len = source.length; i< len;i++){ 19 | seed = (seed * 211 + 30031) % 65536; 20 | index = Math.floor(seed/65536 * source.length); 21 | mixed.push(source[index]); 22 | source.splice(index,1); 23 | } 24 | return mixed.join(''); 25 | }; 26 | function getFileID(fileid, seed){ 27 | var mixed = getFileIDMixString(seed), ids= fileid.split("*"), realId = [], idx; 28 | for (var i=0; i< ids.length; i++){ 29 | idx = parseInt(ids[i],10); 30 | realId.push(mixed.charAt(idx)); 31 | } 32 | return realId.join(''); 33 | }; 34 | var d = new Date(), 35 | fileid = getFileID(param.data[0]['streamfileids']['3gphd'], param.data[0]['seed']), 36 | sid = d.getTime() + "" + (1E3 + d.getMilliseconds()) + "" + (parseInt(Math.random() * 9E3)), 37 | k = param.data[0]['segs']['3gphd'][0]['k'], 38 | st = param.data[0]['segs']['3gphd'][0]['seconds']; 39 | core.jsonp( 40 | 'http://f.youku.com/player/getFlvPath/sid/'+sid+'_00/st/mp4/fileid/'+fileid+'?K='+k+'&hd=1&myp=0&ts=1156&ypp=0&ymovie=1&callback=', 41 | function(param){ 42 | callback( { '高清': param[0]['server'] }, commentInfo); 43 | } 44 | ); 45 | } 46 | ); 47 | } 48 | }; 49 | var qq = function(vid, callback, commentInfo){ 50 | core.jsonp( 51 | 'http://vv.video.qq.com/geturl?otype=json&vid='+vid+'&charge=0&callback=', 52 | function(param){ 53 | callback({ '高清': param.vd.vi[0].url }, commentInfo); 54 | } 55 | ); 56 | }; 57 | var tudou = function(vid, callback, commentInfo){ 58 | if(canPlayM3U8){ 59 | callback({ 60 | '标清': 'http://vr.tudou.com/v2proxy/v2.m3u8?it='+vid+'&st=2', 61 | '原画': 'http://vr.tudou.com/v2proxy/v2.m3u8?it='+vid+'&st=5' 62 | }, commentInfo); 63 | }else{ 64 | core.jsonp( 65 | 'http://vr.tudou.com/v2proxy/v2.js?it=' + vid + '&st=52%2C53%2C54&pw=&jsonp=', 66 | function(param){ 67 | if(param.code == -1) return; 68 | for(var urls={},i=0,len=param.urls.length; i= 0 ? sina(src, callback, commentInfo) : 82 | src.indexOf('v.youku.com') >= 0 ? youku(src, callback, commentInfo) : 83 | src.indexOf('qq.com') >=0 ? qq(src, callback, commentInfo) : bili(src, callback, commentInfo); 84 | } 85 | ); 86 | }; 87 | return{ 88 | reg: /bilibili\.tv/.test(window.location.host) && window.aid, 89 | call: function(callback){ 90 | return init(function(urls, commentInfo){ 91 | return callback({ urls: urls, flashElementId: 'bofqi', comment: commentInfo }); 92 | }); 93 | } 94 | }; 95 | }); 96 | -------------------------------------------------------------------------------- /2.0/source/header.js: -------------------------------------------------------------------------------- 1 | if(window.isHTML5PlayerBookMarkCodeByZythum) return; 2 | window.isHTML5PlayerBookMarkCodeByZythum = true; -------------------------------------------------------------------------------- /2.0/source/iqiyi.js: -------------------------------------------------------------------------------- 1 | '爱奇异' && youkuhtml5playerbookmark2.add(function(core, canPlayM3U8){ 2 | var init = function(callback){ 3 | var timer; 4 | if(window.info){ 5 | var scr = document.createElement('script'); 6 | scr.src = 'http://cache.video.qiyi.com/m/201971/'+window.info.videoId+'/'; 7 | document.body.appendChild(scr); 8 | timer = setInterval(function(){ 9 | if(window.ipadUrl){ 10 | clearInterval(timer); 11 | if(canPlayM3U8){ 12 | //safari下使用m3u8 13 | callback({ 14 | '高清': ipadUrl.data.url 15 | }); 16 | }else{ 17 | //chrome使用mp4 18 | var mp4Url = ipadUrl.data.mp4Url; 19 | var scr = document.createElement('script'); 20 | scr.src = mp4Url; 21 | document.body.appendChild(scr); 22 | clearInterval(timer); 23 | timer = setInterval(function(){ 24 | if(window.videoUrl){ 25 | clearInterval(timer); 26 | callback({ 27 | '高清': videoUrl.data.l 28 | }); 29 | } 30 | },100); 31 | } 32 | } 33 | },100); 34 | }else{ 35 | var box = document.getElementById('flashbox'); 36 | var tvid = box.getAttribute('data-player-tvid'); 37 | core.jsonp( 38 | 'http://zythum.sinaapp.com/youkuhtml5playerbookmark/iqiyi.php?tvid='+tvid+'&callback=', 39 | function(data){ 40 | if(canPlayM3U8){ 41 | callback({'高清': data.data.mpl[0].m3u}); 42 | }else{ 43 | var mp4Url = data.data.mpl[0].m4u; 44 | var scr = document.createElement('script'); 45 | scr.src = mp4Url; 46 | document.body.appendChild(scr); 47 | clearInterval(timer); 48 | timer = setInterval(function(){ 49 | if(window.videoUrl){ 50 | clearInterval(timer); 51 | callback({ 52 | '高清': videoUrl.data.l 53 | }); 54 | } 55 | },100); 56 | } 57 | } 58 | ); 59 | } 60 | }; 61 | return{ 62 | reg: /iqiyi\.com/.test(window.location.host), 63 | call: function(callback){ 64 | return init(function(urls){ 65 | return callback({ urls: urls, flashElementId: 'flash' }); 66 | }); 67 | } 68 | } 69 | }); 70 | -------------------------------------------------------------------------------- /2.0/source/letv.js: -------------------------------------------------------------------------------- 1 | '乐视' && youkuhtml5playerbookmark2.add(function(core, canPlayM3U8){ 2 | canPlayM3U8 = false; 3 | var getScript = function(){ 4 | var s = document.getElementsByTagName('script'); 5 | for(var i=0,len=s.length; i
'); 101 | var range_p = core.cTag('div', CSSp+'range' , progress); 102 | var rangeinner_p = core.cTag('div', CSSp+'rangeinner' , range_p); 103 | var rangebtn_p = core.cTag('div', CSSp+'rangebtn' , rangeinner_p); 104 | var range_v = core.cTag('div', CSSp+'range' , volume); 105 | var rangeinner_v = core.cTag('div', CSSp+'rangeinner' , range_v); 106 | var rangebtn_v = core.cTag('div', CSSp+'rangebtn' , rangeinner_v); 107 | var cmtBtn = core.cTag('div', CSSp+'btn '+CSSp+'cmtBtn' , btns); 108 | var allscreen = core.cTag('div', CSSp+'btn '+CSSp+'allscreen' , btns); 109 | var fullscreen = core.cTag('div', CSSp+'btn '+CSSp+'fullscreen', btns); 110 | var comment = core.cTag('div', CSSp+'comment' ); 111 | var commentFloat = core.cTag('div', CSSp+'commentFloat', comment); 112 | var commentBottom = core.cTag('div', CSSp+'commentBottom', comment); 113 | var logArea = core.cTag('div', CSSp+'logArea' ); 114 | cmtBtn.style.display = 'none'; 115 | close.setAttribute( 'data-click', 'close' ); 116 | fullscreen.setAttribute( 'data-click', 'fullscreen'); 117 | allscreen.setAttribute( 'data-click', 'allscreen' ); 118 | center.setAttribute( 'data-click', 'center' ); 119 | video.setAttribute( 'autoplay', 'true' ); 120 | 121 | var timer; 122 | var isAllscreen = false; 123 | var isBlack = false; 124 | var destroy = true; 125 | var currentTime = 0; 126 | var dclick = core.dClick(layer); 127 | var click = dclick.add; 128 | var hdbtns = []; 129 | var flashElement = undefined; 130 | var flashElementPlaceHolder = core.cTag('div'); 131 | var job = { 132 | setUrl: function(obj){ 133 | job.url = []; 134 | var i, btn; 135 | for(i in obj){ 136 | btn = core.cTag('div', CSSp+'btn' , null, i); 137 | btns.insertBefore(btn, btns.children[0]); 138 | btn.setAttribute('data-click','hd'); 139 | btn.setAttribute('data-url',obj[i]); 140 | hdbtns.push(btn); 141 | job.url.push(obj[i]); 142 | } 143 | btn.className = CSSp+'btn '+CSSp+'select'; 144 | video.src = obj[i]; 145 | job.url.pop(); 146 | } 147 | ,addUrl: function(obj){ 148 | var i, btn; 149 | for(i in obj){ 150 | btn = core.cTag('div', CSSp+'btn' , null, i); 151 | btns.insertBefore(btn, btns.children[0]); 152 | btn.setAttribute('data-click','hd'); 153 | btn.setAttribute('data-url',obj[i]); 154 | hdbtns.push(btn); 155 | job.url && job.url.push(obj[i]); 156 | } 157 | } 158 | ,setFlashElement: function(el){ 159 | try{ 160 | flashElement = el; 161 | el.parentNode.insertBefore(flashElementPlaceHolder, flashElement); 162 | el.parentNode.removeChild(flashElement); 163 | }catch(e){} 164 | } 165 | ,formatTime: function(time){ 166 | var hour = parseInt(time/3600); 167 | var min = parseInt((time-hour*3600)/60); 168 | var sec = parseInt((time-hour*3600-min*60)/1); 169 | return hour+':'+min+':'+sec; 170 | } 171 | ,showPlayer: function(){ 172 | document.body.appendChild(cover); 173 | document.body.appendChild(layer); 174 | document.body.appendChild(logArea); 175 | destroy = false; 176 | } 177 | ,initComment: function(){ 178 | cmtBtn.style.display = ''; 179 | cmtBtn.setAttribute('data-click','cmt'); 180 | cmtBtn.setAttribute('data-status','show'); 181 | cmtBtn.className = CSSp+'btn '+CSSp+'select '+CSSp+'cmtBtn'; 182 | click('cmt', function(){ 183 | if(cmtBtn.getAttribute('data-status') =='show'){ 184 | job.hideComment(); 185 | cmtBtn.className = CSSp+'btn '+CSSp+'cmtBtn';; 186 | cmtBtn.setAttribute('data-status', 'hide'); 187 | }else{ 188 | job.showComment(); 189 | cmtBtn.className = CSSp+'btn '+CSSp+'select '+CSSp+'cmtBtn';; 190 | cmtBtn.setAttribute('data-status', 'show'); 191 | } 192 | }); 193 | } 194 | ,cmt: null 195 | ,commentLoop: function(){ 196 | //在下方的showComment 方法会重写这个方法,这个方法会在loop中调用。节省一个轮询时间 197 | } 198 | ,hideComment: function(){ 199 | commentBottom.innerHTML = commentFloat.innerHTML = ''; 200 | job.commentLoop = function(){}; 201 | } 202 | ,showComment: function(cmt){ 203 | if(cmt){ 204 | job.cmt = cmt = cmt.sort(function(a,b){ 205 | return parseFloat(a.p[0]) - parseFloat(b.p[0]); 206 | }); 207 | }else if(job.cmt){ 208 | cmt = job.cmt; 209 | }else{ 210 | return; 211 | } 212 | player.appendChild(comment); 213 | var lastTime = 0; 214 | var lastInde = 0; 215 | job.commentLoop = function(nowTime){ 216 | if(lastTime === nowTime){ 217 | return; 218 | } 219 | if(lastTime > nowTime){ 220 | lastTime = nowTime; 221 | lastInde = 0 222 | } 223 | if(lastTime + 1 < nowTime){ 224 | lastTime = nowTime - 1; 225 | lastInde = 0 226 | } 227 | var aCmt; 228 | var range = [lastTime, nowTime]; 229 | var i = lastInde; 230 | while(aCmt = cmt[i++]){ 231 | var cTime = parseFloat(aCmt.p[0]); 232 | if(cTime < range[0]){ 233 | continue; 234 | }else if(cTime > range[1]){ 235 | break; 236 | }else{ 237 | if(aCmt.p[1] <= 3) job.pushCmt(aCmt.msg, aCmt.p); 238 | if(aCmt.p[1] == 4 || aCmt.p[1] == 5) job.pushCmtBottom(aCmt.msg, aCmt.p); 239 | } 240 | } 241 | lastTime = nowTime; 242 | lastInde = i; 243 | }; 244 | } 245 | ,pushCmtBottom: function(msg, p){ 246 | var showTime = 4; 247 | var aCmt = core.cTag('div', CSSp+'commentBlockBottom'); 248 | aCmt.appendChild(document.createTextNode(msg)); 249 | if(!commentBottom.children[0]){ 250 | commentBottom.appendChild(aCmt); 251 | }else{ 252 | commentBottom.insertBefore(aCmt, commentBottom.children[0]); 253 | } 254 | aCmt.style.cssText += ';color:#'+p[3].toString(16)+';'; 255 | setTimeout(function(){ 256 | aCmt.parentNode.removeChild(aCmt); 257 | },showTime*1000); 258 | } 259 | ,line: [] 260 | ,pushCmt: function(msg, p){ 261 | var showTime = 8; 262 | var aCmtWidth = 0; 263 | var aCmtHeight = 0; 264 | var allWidth = player.offsetWidth; 265 | var aCmt = core.cTag('div', CSSp+'commentBlock'); 266 | aCmt.appendChild(document.createTextNode(msg)); 267 | commentFloat.appendChild(aCmt); 268 | aCmtWidth = aCmt.offsetWidth + 10; 269 | aCmtHeight = 25; 270 | allWidth = allWidth + aCmtWidth; 271 | removeTime = showTime / player.offsetWidth * allWidth; 272 | isShowdTime = showTime / player.offsetWidth * aCmtWidth; 273 | var lineNum = 0; 274 | while(job.line[lineNum]){ lineNum++; } 275 | job.line[lineNum] = aCmt; 276 | aCmt.style.cssText += ';-webkit-transform: translate3d('+allWidth+'px, 0, 0);top:'+lineNum*aCmtHeight+'px;left:0px;color:#'+parseInt(p[3]).toString(16)+';'; 277 | setTimeout(function(){ 278 | aCmt.style.cssText += ';-webkit-transform: translate3d(-'+aCmtWidth+'px, 0, 0);-webkit-transition:-webkit-transform '+showTime+'s linear;'; 279 | },0); 280 | setTimeout(function(){ 281 | job.line[lineNum] = undefined; 282 | },isShowdTime*1000); 283 | setTimeout(function(){ 284 | aCmt.parentNode.removeChild(aCmt); 285 | },removeTime*1000); 286 | } 287 | ,videoLayout: { 288 | width: 800, 289 | height: 450 290 | } 291 | ,setVideoLayout: function(width, height){ 292 | if(isAllscreen || document.webkitIsFullScreen) return; 293 | var _width = 800; 294 | var _height = _width / width * height || 450; 295 | if(_height > window.innerHeight - 80){ 296 | _height = window.innerHeight - 80 297 | _width = _height / height * width; 298 | _width = _width < 500 ? 500 : _width; 299 | } 300 | job.videoLayout.height = _height; 301 | job.videoLayout.width = _width; 302 | job.fixVideoLayout(); 303 | } 304 | ,fixVideoLayout: function(){ 305 | if(isAllscreen || document.webkitIsFullScreen){ 306 | layer.style.width = ''; 307 | layer.style.marginLeft = ''; 308 | layer.style.height = ''; 309 | layer.style.marginTop = ''; 310 | }else{ 311 | layer.style.width = job.videoLayout.width + 'px'; 312 | layer.style.marginLeft = '-' + job.videoLayout.width/2 + 'px'; 313 | layer.style.height = job.videoLayout.height + 'px'; 314 | layer.style.marginTop = '-' + job.videoLayout.height/2 + 'px'; 315 | } 316 | } 317 | ,log: function(log){ 318 | window.console && window.console.log(log); 319 | var l = core.cTag('div', CSSp+'log', logArea, log); 320 | setTimeout(function(){ 321 | core.rNode(l); 322 | },1000); 323 | } 324 | } 325 | //切换清晰度 326 | var setCurrentTimer; 327 | click('hd', function(btn){ 328 | var currentTime = video.currentTime; 329 | if(btn.className == CSSp+'btn '+CSSp+'select'){ 330 | return; 331 | } 332 | var i=0,len=hdbtns.length; 333 | for(;i 20 ? (video.currentTime = video.currentTime - 20): '';e.preventDefault();e.preventDefault();break; //left 445 | case 39: video.currentTime < video.duration - 20 ? (video.currentTime = video.currentTime + 20): '';e.preventDefault();e.preventDefault();break; //right 446 | case 40: video.volume > 0.1 ? (video.volume = video.volume - 0.1): '';e.preventDefault();e.preventDefault();break; //down 447 | case 38: video.volume < 0.9 ? (video.volume = video.volume + 0.1): '';e.preventDefault();e.preventDefault();break; //up 448 | case 32: video[video.paused?'play':'pause']();e.preventDefault();break; //space 449 | } 450 | } 451 | document.body.addEventListener('keydown', docKeydownHandler, false); 452 | //全屏事件触发回调 453 | var playerWebkitfullscreenchangeHandler = function(){ 454 | if(destroy) return; 455 | job.fixVideoLayout(); 456 | if(document.webkitIsFullScreen){ 457 | layer.className = CSSp+'layer '+CSSp+'full'; 458 | fullscreen.className = CSSp+'btn '+CSSp+'select '+CSSp+'fullscreen'; 459 | allscreen.style.display = 'none'; 460 | }else{ 461 | layer.className = isAllscreen ? CSSp+'layer '+CSSp+'full' : CSSp+'layer'; 462 | fullscreen.className = CSSp+'btn '+CSSp+'fullscreen'; 463 | allscreen.style.display = ''; 464 | } 465 | } 466 | player.addEventListener('webkitfullscreenchange', playerWebkitfullscreenchangeHandler, false) 467 | 468 | //can play 回调 469 | var videoCanplayHandler = function(){ 470 | if(destroy) return; 471 | video.play(); 472 | job.setVideoLayout(video.videoWidth, video.videoHeight); 473 | } 474 | video.addEventListener('canplay', videoCanplayHandler, false); 475 | //进度条拖动 476 | var FlagByRange_p = false; 477 | var FlagByRange_v = false; 478 | var range_pMousedownHandler = function(){ 479 | if(destroy) return; 480 | FlagByRange_p = true; 481 | } 482 | range_p.addEventListener('mousedown', range_pMousedownHandler, false); 483 | var range_vMousedownHandler = function(){ 484 | if(destroy) return; 485 | FlagByRange_v = true; 486 | } 487 | range_v.addEventListener('mousedown', range_vMousedownHandler, false); 488 | var docMouseupHandler = function(e){ 489 | if(destroy) return; 490 | var length = 0; 491 | var pst = 0; 492 | if(FlagByRange_p){ 493 | length = e.clientX - core.getLeft(rangeinner_p); 494 | pst = length/rangeinner_p.offsetWidth; 495 | pst = pst>1?1:pst; 496 | pst = pst<0?0:pst; 497 | video.currentTime = video.duration*pst; 498 | rangebtn_p.style.width = (pst*100)+'%'; 499 | } 500 | if(FlagByRange_v){ 501 | length = e.clientX - core.getLeft(rangeinner_v); 502 | pst = length/rangeinner_v.offsetWidth; 503 | pst = pst>1?1:pst; 504 | pst = pst<0?0:pst; 505 | video.volume = pst; 506 | rangebtn_v.style.width = (pst*100)+'%'; 507 | } 508 | FlagByRange_p = false; 509 | FlagByRange_v = false; 510 | } 511 | document.addEventListener('mouseup', docMouseupHandler, false); 512 | var docMousemoveHandler = function(e){ 513 | if(destroy) return; 514 | var length = 0; 515 | var pst = 0; 516 | if(FlagByRange_p){ 517 | length = e.clientX - core.getLeft(rangeinner_p); 518 | pst = length/rangeinner_p.offsetWidth; 519 | pst = pst>1?1:pst; 520 | pst = pst<0?0:pst; 521 | video.currentTime = video.duration*pst; 522 | rangebtn_p.style.width = (pst*100)+'%'; 523 | } 524 | if(FlagByRange_v){ 525 | length = e.clientX - core.getLeft(rangeinner_v); 526 | pst = length/rangeinner_v.offsetWidth; 527 | pst = pst>1?1:pst; 528 | pst = pst<0?0:pst; 529 | video.volume = pst; 530 | rangebtn_v.style.width = (pst*100)+'%'; 531 | } 532 | } 533 | document.addEventListener('mousemove', docMousemoveHandler, false); 534 | var ctrlbarIsShow = true; 535 | var ctrlbarTimer = setTimeout(function(){ 536 | ctrlbar.className = CSSp+'ctrlbar'; 537 | },3000); 538 | //鼠标移动显示工具 539 | playerMousemoveHandler = function(){ 540 | clearTimeout(ctrlbarTimer); 541 | if(ctrlbar.className != CSSp+'ctrlbar '+CSSp+'ctrlbarhover'){ 542 | ctrlbar.className = CSSp+'ctrlbar '+CSSp+'ctrlbarhover'; 543 | } 544 | ctrlbarTimer = setTimeout(function(){ 545 | ctrlbar.className = CSSp+'ctrlbar'; 546 | },3000); 547 | } 548 | player.addEventListener('mousemove', playerMousemoveHandler, false); 549 | //循环获取播放信息 550 | var lastTime = -1; 551 | var num = 0; 552 | var isLoading = false; 553 | var loop = function(){ 554 | if(isError) return; 555 | if(!FlagByRange_p){ 556 | rangebtn_p.style.width != (video.currentTime/video.duration*100)+'%' && 557 | (rangebtn_p.style.width = (video.currentTime/video.duration*100)+'%'); 558 | } 559 | if(!FlagByRange_v){ 560 | rangebtn_v.style.width != (video.volume*100)+'%' && 561 | (rangebtn_v.style.width = (video.volume*100)+'%'); 562 | } 563 | progressNum.innerHTML = job.formatTime(video.currentTime) + ' / ' + job.formatTime(video.duration); 564 | if(video.duration == 10 && job.url.length){ 565 | //如果第一个视频没有解码好。用次之的 566 | video.src = job.url[0]; 567 | } 568 | if(video.paused){ 569 | center.className != CSSp+'center '+CSSp+'pause' && 570 | (center.className = CSSp+'center '+CSSp+'pause'); 571 | }else{ 572 | center.className != CSSp+'center' && 573 | (center.className = CSSp+'center'); 574 | } 575 | if(lastTime != video.currentTime || video.ended || video.readyState == 3 || video.readyState == 4 || video.readyState == 5){ 576 | if(!isLoading){ 577 | title.innerHTML = '妈妈再也不用担心我的macbook发烫了计划'; 578 | isLoading = true; 579 | } 580 | }else{ 581 | if(isLoading){ 582 | title.innerHTML = '勇敢的少年请耐心,少女努力祈祷中...'; 583 | isLoading = false; 584 | } 585 | center.className != CSSp+'center '+CSSp+'loading' && 586 | (center.className = CSSp+'center '+CSSp+'loading'); 587 | } 588 | //弹幕的loop 589 | if(job.commentLoop){ 590 | if(num%2 == 0){ job.commentLoop(lastTime = video.currentTime); } 591 | if(++num > 10){ num = 0; } 592 | } 593 | timer = setTimeout(loop, 500); 594 | }; 595 | loop(); 596 | var site = []; 597 | return { 598 | add: function(callback){ 599 | // callback return {reg, call, flashElement, comment} 600 | try{ callback && site.push( callback(core, canPlayM3U8) ) }catch(e){}; 601 | }, 602 | init: function(){ 603 | for(var i=0,len=site.length; i< len; i++){ 604 | if(site[i] && site[i].reg && site[i].call){ 605 | job.showPlayer(); 606 | job.log('播放器初始化'); 607 | try{ 608 | site[i].call(function(_){ 609 | job.setUrl(_.urls); 610 | job.log('获取播放源地址'); 611 | job.setFlashElement( core.byId(_.flashElementId) ); 612 | if(_.comment){ 613 | job.initComment(); 614 | job.log('初始化弹幕'); 615 | setTimeout(function(){ 616 | job.showComment(_.comment); 617 | job.log('生成弹幕'); 618 | },100); 619 | } 620 | }); 621 | }catch(e){ 622 | isError = true; 623 | title.innerHTML = MSG_ERROR; 624 | job.log('播放失败。请把url地址赋值。上微博@zythum_朱一童鞋'); 625 | } 626 | job.log('准备完毕'); 627 | break; 628 | } 629 | } 630 | } 631 | } 632 | })(); -------------------------------------------------------------------------------- /2.0/source/playerlite.js: -------------------------------------------------------------------------------- 1 | var youkuhtml5playerbookmark2 = (function(){ 2 | var canPlayM3U8 = !!document.createElement('video').canPlayType('application/x-mpegURL') ? true : false; 3 | var core = { 4 | //获取元素的纵坐标 5 | getTop: function(e){ 6 | var offset=e.offsetTop; 7 | if(e.offsetParent!=null) offset+=core.getTop(e.offsetParent); 8 | return offset; 9 | } 10 | //获取元素的横坐标 11 | ,getLeft: function(e){ 12 | var offset=e.offsetLeft; 13 | if(e.offsetParent!=null) offset+=core.getLeft(e.offsetParent); 14 | return offset; 15 | } 16 | ,byId: function(id){ 17 | return document.getElementById(id); 18 | } 19 | ,cTag: function(tagName, className, out, html){ 20 | var t = document.createElement(tagName) 21 | if(className){ 22 | t.className = className; 23 | } 24 | if(out){ 25 | out.appendChild(t) 26 | } 27 | if(html){ 28 | t.innerHTML = html 29 | } 30 | return t 31 | } 32 | ,rNode: function(node){ 33 | try{ 34 | node.parentNode.removeChild(node) 35 | }catch(e){} 36 | } 37 | ,dClick: function(out){ 38 | var fnList = {} 39 | ,flag = 'd_click' 40 | ,handler = function(el){ 41 | if(!el || el == out || !el.getAttribute || !el.tagName){ 42 | return; 43 | } 44 | var flag = el.getAttribute('data-click') 45 | ,i 46 | if(flag && fnList[flag]){ 47 | for(i=0;i
'),y=t.cTag("div",i+"range",p),b=t.cTag("div",i+"rangeinner",y),w=t.cTag("div",i+"rangebtn",b),E=t.cTag("div",i+"range",d),S=t.cTag("div",i+"rangeinner",E),x=t.cTag("div",i+"rangebtn",S),T=t.cTag("div",i+"btn "+i+"cmtBtn",v),N=t.cTag("div",i+"btn "+i+"allscreen",v),C=t.cTag("div",i+"btn "+i+"fullscreen",v),k=t.cTag("div",i+"comment"),L=t.cTag("div",i+"commentFloat",k),A=t.cTag("div",i+"commentBottom",k),O=t.cTag("div",i+"logArea");T.style.display="none",m.setAttribute("data-click","close"),C.setAttribute("data-click","fullscreen"),N.setAttribute("data-click","allscreen"),g.setAttribute("data-click","center"),f.setAttribute("autoplay","true");var M,_=!1,D=!1,P=!0,H=0,B=t.dClick(o),j=B.add,F=[],I=undefined,q=t.cTag("div"),R={setUrl:function(e){R.url=[];var n,r;for(n in e)r=t.cTag("div",i+"btn",null,n),v.insertBefore(r,v.children[0]),r.setAttribute("data-click","hd"),r.setAttribute("data-url",e[n]),F.push(r),R.url.push(e[n]);r.className=i+"btn "+i+"select",f.src=e[n],R.url.pop()},addUrl:function(e){var n,r;for(n in e)r=t.cTag("div",i+"btn",null,n),v.insertBefore(r,v.children[0]),r.setAttribute("data-click","hd"),r.setAttribute("data-url",e[n]),F.push(r),R.url&&R.url.push(e[n])},setFlashElement:function(e){try{I=e,e.parentNode.insertBefore(q,I),e.parentNode.removeChild(I)}catch(t){}},formatTime:function(e){var t=parseInt(e/3600),n=parseInt((e-t*3600)/60),r=parseInt((e-t*3600-n*60)/1);return t+":"+n+":"+r},showPlayer:function(){document.body.appendChild(s),document.body.appendChild(o),document.body.appendChild(O),P=!1},initComment:function(){T.style.display="",T.setAttribute("data-click","cmt"),T.setAttribute("data-status","show"),T.className=i+"btn "+i+"select "+i+"cmtBtn",j("cmt",function(){T.getAttribute("data-status")=="show"?(R.hideComment(),T.className=i+"btn "+i+"cmtBtn",T.setAttribute("data-status","hide")):(R.showComment(),T.className=i+"btn "+i+"select "+i+"cmtBtn",T.setAttribute("data-status","show"))})},cmt:null,commentLoop:function(){},hideComment:function(){A.innerHTML=L.innerHTML="",R.commentLoop=function(){}},showComment:function(e){if(e)R.cmt=e=e.sort(function(e,t){return parseFloat(e.p[0])-parseFloat(t.p[0])});else{if(!R.cmt)return;e=R.cmt}a.appendChild(k);var t=0,n=0;R.commentLoop=function(r){if(t===r)return;t>r&&(t=r,n=0),t+1s[1])break;i.p[1]<=3&&R.pushCmt(i.msg,i.p),(i.p[1]==4||i.p[1]==5)&&R.pushCmtBottom(i.msg,i.p)}t=r,n=o}},pushCmtBottom:function(e,n){var r=4,s=t.cTag("div",i+"commentBlockBottom");s.appendChild(document.createTextNode(e)),A.children[0]?A.insertBefore(s,A.children[0]):A.appendChild(s),s.style.cssText+=";color:#"+n[3].toString(16)+";",setTimeout(function(){s.parentNode.removeChild(s)},r*1e3)},line:[],pushCmt:function(e,n){var r=8,s=0,o=0,u=a.offsetWidth,f=t.cTag("div",i+"commentBlock");f.appendChild(document.createTextNode(e)),L.appendChild(f),s=f.offsetWidth+10,o=25,u+=s,removeTime=r/a.offsetWidth*u,isShowdTime=r/a.offsetWidth*s;var l=0;while(R.line[l])l++;R.line[l]=f,f.style.cssText+=";-webkit-transform: translate3d("+u+"px, 0, 0);top:"+l*o+"px;left:0px;color:#"+parseInt(n[3]).toString(16)+";",setTimeout(function(){f.style.cssText+=";-webkit-transform: translate3d(-"+s+"px, 0, 0);-webkit-transition:-webkit-transform "+r+"s linear;"},0),setTimeout(function(){R.line[l]=undefined},isShowdTime*1e3),setTimeout(function(){f.parentNode.removeChild(f)},removeTime*1e3)},videoLayout:{width:800,height:450},setVideoLayout:function(e,t){if(_||document.webkitIsFullScreen)return;var n=800,r=n/e*t||450;r>window.innerHeight-80&&(r=window.innerHeight-80,n=r/t*e,n=n<500?500:n),R.videoLayout.height=r,R.videoLayout.width=n,R.fixVideoLayout()},fixVideoLayout:function(){_||document.webkitIsFullScreen?(o.style.width="",o.style.marginLeft="",o.style.height="",o.style.marginTop=""):(o.style.width=R.videoLayout.width+"px",o.style.marginLeft="-"+R.videoLayout.width/2+"px",o.style.height=R.videoLayout.height+"px",o.style.marginTop="-"+R.videoLayout.height/2+"px")},log:function(e){window.console&&window.console.log(e);var n=t.cTag("div",i+"log",O,e);setTimeout(function(){t.rNode(n)},1e3)}},U;j("hd",function(e){var t=f.currentTime;if(e.className==i+"btn "+i+"select")return;var n=0,r=F.length;for(;n20?f.currentTime=f.currentTime-20:"",e.preventDefault(),e.preventDefault();break;case 39:f.currentTime.1?f.volume=f.volume-.1:"",e.preventDefault(),e.preventDefault();break;case 38:f.volume<.9?f.volume=f.volume+.1:"",e.preventDefault(),e.preventDefault();break;case 32:f[f.paused?"play":"pause"](),e.preventDefault()}};document.body.addEventListener("keydown",$,!1);var J=function(){if(P)return;R.fixVideoLayout(),document.webkitIsFullScreen?(o.className=i+"layer "+i+"full",C.className=i+"btn "+i+"select "+i+"fullscreen",N.style.display="none"):(o.className=_?i+"layer "+i+"full":i+"layer",C.className=i+"btn "+i+"fullscreen",N.style.display="")};a.addEventListener("webkitfullscreenchange",J,!1);var K=function(){if(P)return;f.play(),R.setVideoLayout(f.videoWidth,f.videoHeight)};f.addEventListener("canplay",K,!1);var Q=!1,G=!1,Y=function(){if(P)return;Q=!0};y.addEventListener("mousedown",Y,!1);var Z=function(){if(P)return;G=!0};E.addEventListener("mousedown",Z,!1);var et=function(e){if(P)return;var n=0,r=0;Q&&(n=e.clientX-t.getLeft(b),r=n/b.offsetWidth,r=r>1?1:r,r=r<0?0:r,f.currentTime=f.duration*r,w.style.width=r*100+"%"),G&&(n=e.clientX-t.getLeft(S),r=n/S.offsetWidth,r=r>1?1:r,r=r<0?0:r,f.volume=r,x.style.width=r*100+"%"),Q=!1,G=!1};document.addEventListener("mouseup",et,!1);var tt=function(e){if(P)return;var n=0,r=0;Q&&(n=e.clientX-t.getLeft(b),r=n/b.offsetWidth,r=r>1?1:r,r=r<0?0:r,f.currentTime=f.duration*r,w.style.width=r*100+"%"),G&&(n=e.clientX-t.getLeft(S),r=n/S.offsetWidth,r=r>1?1:r,r=r<0?0:r,f.volume=r,x.style.width=r*100+"%")};document.addEventListener("mousemove",tt,!1);var nt=!0,rt=setTimeout(function(){l.className=i+"ctrlbar"},3e3);playerMousemoveHandler=function(){clearTimeout(rt),l.className!=i+"ctrlbar "+i+"ctrlbarhover"&&(l.className=i+"ctrlbar "+i+"ctrlbarhover"),rt=setTimeout(function(){l.className=i+"ctrlbar"},3e3)},a.addEventListener("mousemove",playerMousemoveHandler,!1);var it=-1,st=0,ot=!1,ut=function(){if(n)return;Q||w.style.width!=f.currentTime/f.duration*100+"%"&&(w.style.width=f.currentTime/f.duration*100+"%"),G||x.style.width!=f.volume*100+"%"&&(x.style.width=f.volume*100+"%"),h.innerHTML=R.formatTime(f.currentTime)+" / "+R.formatTime(f.duration),f.duration==10&&R.url.length&&(f.src=R.url[0]),f.paused?g.className!=i+"center "+i+"pause"&&(g.className=i+"center "+i+"pause"):g.className!=i+"center"&&(g.className=i+"center"),it!=f.currentTime||f.ended||f.readyState==3||f.readyState==4||f.readyState==5?ot||(u.innerHTML="妈妈再也不用担心我的macbook发烫了计划",ot=!0):(ot&&(u.innerHTML="勇敢的少年请耐心,少女努力祈祷中...",ot=!1),g.className!=i+"center "+i+"loading"&&(g.className=i+"center "+i+"loading")),R.commentLoop&&(st%2==0&&R.commentLoop(it=f.currentTime),++st>10&&(st=0)),M=setTimeout(ut,500)};ut();var at=[];return{add:function(n){try{n&&at.push(n(t,e))}catch(r){}},init:function(){for(var e=0,i=at.length;e=0;r--)n[e.df[r].type]=e.df[r].url;t(n),window[i]=s},i)}};return{reg:/56\.com/.test(window.location.host)&&n,call:function(e){return r(function(t){return e({urls:t,flashElementId:"mod_player"})})}}}),youkuhtml5playerbookmark2.add(function(e,t){var n=function(n){var r;if(window.info){var i=document.createElement("script");i.src="http://cache.video.qiyi.com/m/201971/"+window.info.videoId+"/",document.body.appendChild(i),r=setInterval(function(){if(window.ipadUrl){clearInterval(r);if(t)n({"高清":ipadUrl.data.url});else{var e=ipadUrl.data.mp4Url,i=document.createElement("script");i.src=e,document.body.appendChild(i),clearInterval(r),r=setInterval(function(){window.videoUrl&&(clearInterval(r),n({"高清":videoUrl.data.l}))},100)}}},100)}else{var s=document.getElementById("flashbox"),o=s.getAttribute("data-player-tvid");e.jsonp("http://zythum.sinaapp.com/youkuhtml5playerbookmark/iqiyi.php?tvid="+o+"&callback=",function(e){if(t)n({"高清":e.data.mpl[0].m3u});else{var i=e.data.mpl[0].m4u,s=document.createElement("script");s.src=i,document.body.appendChild(s),clearInterval(r),r=setInterval(function(){window.videoUrl&&(clearInterval(r),n({"高清":videoUrl.data.l}))},100)}})}};return{reg:/iqiyi\.com/.test(window.location.host),call:function(e){return n(function(t){return e({urls:t,flashElementId:"flash"})})}}}),youkuhtml5playerbookmark2.add(function(core,canPlayM3U8){canPlayM3U8=!1;var getScript=function(){var e=document.getElementsByTagName("script");for(var t=0,n=e.length;t=0?i(a,t,r):a.indexOf("v.youku.com")>=0?s(a,t,r):a.indexOf("qq.com")>=0?o(a,t,r):u(a,t,r)})};return{reg:/bilibili\.tv/.test(window.location.host)&&window.aid,call:function(e){return a(function(t,n){return e({urls:t,flashElementId:"bofqi",comment:n})})}}}),youkuhtml5playerbookmark2.add(function(e,t){var n=function(e){var t=document.cookie.split("; "),n=0,r=t.length,i,s;for(;n=0;r--)n[e.df[r].type]=e.df[r].url;t(n),window[i]=s},i)}};return{reg:/56\.com/.test(window.location.host)&&n,call:function(e){return r(function(t){return e({urls:t,flashElementId:"mod_player"})})}}}),youkuhtml5playerbookmark2.add(function(e,t){var n=function(e){var n=document.createElement("script");n.src="http://cache.video.qiyi.com/m/201971/"+window.info.videoId+"/",document.body.appendChild(n);var r;r=setInterval(function(){if(window.ipadUrl){clearInterval(r);if(t)e({"高清":ipadUrl.data.url});else{var n=ipadUrl.data.mp4Url,i=document.createElement("script");i.src=n,document.body.appendChild(i),clearInterval(r),r=setInterval(function(){window.videoUrl&&(clearInterval(r),e({"高清":videoUrl.data.l}))},100)}}},100)};return{reg:/iqiyi\.com/.test(window.location.host)&&window.info&&window.info.videoId,call:function(e){return n(function(t){return e({urls:t,flashElementId:"flash"})})}}}),youkuhtml5playerbookmark2.add(function(core,canPlayM3U8){canPlayM3U8=!1;var getScript=function(){var e=document.getElementsByTagName("script");for(var t=0,n=e.length;t=0?i(a,t,r):a.indexOf("v.youku.com")>=0?s(a,t,r):a.indexOf("qq.com")>=0?o(a,t,r):u(a,t,r)})};return{reg:/bilibili\.tv/.test(window.location.host)&&window.aid,call:function(e){return a(function(t,n){return e({urls:t,flashElementId:"bofqi",comment:n})})}}}),youkuhtml5playerbookmark2.add(function(e,t){var n=function(e){var t=document.cookie.split("; "),n=0,r=t.length,i,s;for(;n [MAMA2](http://zythum.github.io/mama2/) -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | YouKu HTML5 Player BookMark 6 | 70 | 71 | 72 | 75 |
76 |

这个东西用于在YOUKU.com上使用html5的形式播放,而不是flash。

77 |

在视频播放页点击这个收藏的bookmark便可。

78 |

拖拽右面那个东西到收藏栏 =》 79 | YouKu HTML5 Player

80 | 81 |

今天上班的时候偷偷做的。话说每天看优酷的时候风扇都哗哗的,实在受不了了就做了这个。来解决flash发热大的问题。 82 | 目前貌似播放只支持safari同学。因为视频格式使用的m3u8,所以貌似chrome没法播放。 83 | 用chrome的童鞋也不要哭,不要闹。朱一也把mp4的地址也解析出来了。在下来做了个连接。童鞋们点击进去就好了。 84 | 其实本来像把chrome的地址也判断写ua放进去的。发现优酷不乖得弟子做了3次重定向。天。还是点链接把。

85 |
86 |
87 |

----------------下面是实物截图----------------

88 | 有图有真像 89 |
90 |
91 | Code by zythum_朱一 92 | http://zythum.diandian.com 93 | | 94 | http://zyiangel.blogbus.com 95 |
96 | 97 | -------------------------------------------------------------------------------- /iqiyihtml5playerbookmark.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zythum/youkuhtml5playerbookmark/d4b7ea9467c8e3cddd9ef0ab51f149098ea19601/iqiyihtml5playerbookmark.js -------------------------------------------------------------------------------- /sohuhtml5playerbookmark.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | if(!window.vid){ 3 | return false; 4 | } 5 | var coverCss = [ 6 | '', 7 | 'position:fixed', 8 | 'top:0', 9 | 'left:0', 10 | 'bottom:0', 11 | 'right:0', 12 | 'background-color:rgba(255,255,255,0)', 13 | 'z-index:999999999999', 14 | '-webkit-transition:background-color 0.2s ease;', 15 | '-moz-transition:background-color 0.2s ease;', 16 | '-o-transition:background-color 0.2s ease;', 17 | 'transition:background-color 0.2s ease;', 18 | 'pointer-events:none', 19 | '' 20 | ]; 21 | var videoCss = [ 22 | '', 23 | 'position:absolute', 24 | 'width:610px', 25 | 'height:458px', 26 | 'top:-500px', 27 | 'left:50%', 28 | 'margin-left:-306px', 29 | 'z-index:1000000000000', 30 | 'background:#000', 31 | 'box-shadow:0 0 5px #333', 32 | '-webkit-transition:top 1s ease;', 33 | '-moz-transition:top 1s ease;', 34 | '-o-transition:top 1s ease;', 35 | 'transition:top 1s ease;', 36 | '' 37 | ]; 38 | var aCss = [ 39 | '', 40 | 'position:absolute', 41 | 'bottom:0', 42 | 'left:0', 43 | 'right:0', 44 | 'height:30px;', 45 | 'text-align:center', 46 | 'font-size:14px', 47 | 'pointer-events:auto', 48 | '' 49 | ]; 50 | 51 | var btnCss = [ 52 | '', 53 | 'position:absolute', 54 | 'top:0', 55 | 'height:30px;', 56 | 'line-height:30px', 57 | 'width:60px', 58 | 'text-align:center', 59 | 'font-size:14px', 60 | 'letter-spacing:-1px', 61 | 'color:#014CCC', 62 | 'cursor:pointer', 63 | 'pointer-events:auto', 64 | '' 65 | ]; 66 | 67 | var changeBtnCss = [ 68 | '', 69 | 'position:absolute', 70 | 'width:500px', 71 | 'height:40px', 72 | 'top:470px', 73 | 'left:50%', 74 | 'margin-left:-250px', 75 | 'z-index:1000000000000', 76 | 'background:#000', 77 | 'box-shadow:0 0 5px #333', 78 | 'text-align:center', 79 | 'color:#eee', 80 | 'border-radius:150px', 81 | 'overflow:hidden', 82 | '' 83 | ]; 84 | 85 | var changeBtnItemCss = [ 86 | '', 87 | 'display:inline-block', 88 | 'width:150px', 89 | 'height:40px', 90 | 'line-height:40px', 91 | 'font-size:20px', 92 | 'cursor:pointer', 93 | '' 94 | ]; 95 | 96 | var pad = function(num, n) { 97 | return (new Array(n >(''+num).length ? (n - (''+num).length+1) : 0).join('0') + num); 98 | } 99 | 100 | var HTML5Player = function(){ 101 | 102 | var m3u8 = vid || ''; 103 | m3u8 = m3u8 ? 'http://hot.vrs.sohu.com/ipad'+m3u8+'.m3u8' : 0; 104 | var cover = document.createElement('div'); 105 | cover.style.cssText += coverCss.join(';'); 106 | 107 | var v = document.createElement('video'); 108 | v.setAttribute('height','458'); 109 | v.setAttribute('width','610'); 110 | v.setAttribute('controls','true'); 111 | v.setAttribute('autoplay','true'); 112 | v.style.cssText += videoCss.join(';'); 113 | v.src = m3u8; 114 | 115 | 116 | var a = document.createElement('span'); 117 | a.innerHTML = '目前只有m3u8格式的支持,貌似只有safair才能播放。'; 118 | a.style.cssText += aCss.join(';'); 119 | cover.appendChild(a); 120 | 121 | var off = document.createElement('div'); 122 | off.innerHTML = '退出'; 123 | off.style.cssText += btnCss.join(';')+';right:0;'; 124 | cover.appendChild(off); 125 | var nocover = document.createElement('div'); 126 | nocover.innerHTML = '打开迷雾'; 127 | nocover.style.cssText += btnCss.join(';')+';right:60px;'; 128 | cover.appendChild(nocover); 129 | 130 | off.addEventListener('click',function(){ 131 | y.HTML5.remove(); 132 | y.flash.add(); 133 | y.flag = false; 134 | },false); 135 | 136 | nocover.addEventListener('click',function(){ 137 | cover.style.backgroundColor = 'rgba(255,255,255,0)'; 138 | },false); 139 | 140 | var changeBtn = document.createElement('div'); 141 | changeBtn.style.cssText += changeBtnCss.join(';'); 142 | 143 | // var t_yuanhua = document.createElement('div'); 144 | // t_yuanhua.style.cssText += changeBtnItemCss.join(';'); 145 | // t_yuanhua.style.backgroundColor = '#666'; 146 | // t_yuanhua.style.boxShadow = '0 0 3px #000 inset'; 147 | // t_yuanhua.innerHTML = '原画'; 148 | // changeBtn.appendChild(t_yuanhua); 149 | 150 | // var t_360 = document.createElement('div'); 151 | // t_360.style.cssText += changeBtnItemCss.join(';'); 152 | // t_360.innerHTML = '360P'; 153 | // changeBtn.appendChild(t_360); 154 | 155 | // var t_256 = document.createElement('div'); 156 | // t_256.style.cssText += changeBtnItemCss.join(';'); 157 | // t_256.innerHTML = '256P'; 158 | // changeBtn.appendChild(t_256); 159 | 160 | // t_yuanhua.addEventListener('click',function(){ 161 | // v.src = t_yuanhuaSrc; 162 | // t_yuanhua.style.backgroundColor = '#666'; 163 | // t_360.style.backgroundColor = 'transparent'; 164 | // t_256.style.backgroundColor = 'transparent'; 165 | // t_yuanhua.style.boxShadow = '0 0 3px #000 inset'; 166 | // t_360.style.boxShadow = 'none'; 167 | // t_256.style.boxShadow = 'none'; 168 | // },false); 169 | 170 | // t_360.addEventListener('click',function(){ 171 | // v.src = t_360Src; 172 | // t_360.style.backgroundColor = '#666'; 173 | // t_yuanhua.style.backgroundColor = 'transparent'; 174 | // t_256.style.backgroundColor = 'transparent'; 175 | // t_360.style.boxShadow = '0 0 3px #000 inset'; 176 | // t_yuanhua.style.boxShadow = 'none'; 177 | // t_256.style.boxShadow = 'none'; 178 | // },false); 179 | 180 | // t_256.addEventListener('click',function(){ 181 | // v.src = t_360Src; 182 | // t_256.style.backgroundColor = '#666'; 183 | // t_yuanhua.style.backgroundColor = 'transparent'; 184 | // t_360.style.backgroundColor = 'transparent'; 185 | // t_256.style.boxShadow = '0 0 3px #000 inset'; 186 | // t_yuanhua.style.boxShadow = 'none'; 187 | // t_360.style.boxShadow = 'none'; 188 | // },false); 189 | 190 | 191 | 192 | return { 193 | add : function(){ 194 | document.body.appendChild(cover); 195 | // document.body.appendChild(changeBtn); 196 | document.body.appendChild(v); 197 | 198 | v.addEventListener('canplay',v.play); 199 | setTimeout(function(){ 200 | cover.style.backgroundColor = 'rgba(255,255,255,0.6)'; 201 | v.style.top = '-1px'; 202 | },100); 203 | }, 204 | remove : function(){ 205 | v.pause(); 206 | cover.style.backgroundColor = 'rgba(255,255,255,0)'; 207 | v.style.top = '-500px'; 208 | setTimeout(function(){ 209 | cover.parentNode && document.body.removeChild(cover); 210 | v.parentNode && document.body.removeChild(v); 211 | changeBtn.parentNode && document.body.removeChild(changeBtn); 212 | },1100); 213 | } 214 | } 215 | } 216 | 217 | var flashPlayer = function(){ 218 | var flashOut = document.getElementById('sohuplayer'); 219 | var flash = document.getElementById('player'); 220 | return { 221 | add : function(){ 222 | flashOut.appendChild(flash); 223 | }, 224 | remove : function(){ 225 | flashOut.parentNode && flashOut.removeChild(flash); 226 | } 227 | } 228 | } 229 | 230 | window.isSohuHTML5PlayerBookMarkCodeByZythum = window.isSohuHTML5PlayerBookMarkCodeByZythum || {}; 231 | var y = window.isSohuHTML5PlayerBookMarkCodeByZythum; 232 | y.HTML5 = y.HTML5 || HTML5Player(); 233 | y.flash = y.flash || flashPlayer(); 234 | y.flag = y.flag || false; 235 | if(y.flag === false){ 236 | y.HTML5.add(); 237 | y.flash.remove(); 238 | y.flag = true; 239 | }else if(y.flag === true){ 240 | y.HTML5.remove(); 241 | y.flash.add(); 242 | y.flag = false; 243 | } 244 | 245 | })(); 246 | -------------------------------------------------------------------------------- /tudouhtml5playerbookmark.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | if(!window.iid){ 3 | return false; 4 | } 5 | var coverCss = [ 6 | '', 7 | 'position:fixed', 8 | 'top:0', 9 | 'left:0', 10 | 'bottom:0', 11 | 'right:0', 12 | 'background-color:rgba(255,255,255,0)', 13 | 'z-index:999999999999', 14 | '-webkit-transition:background-color 0.2s ease;', 15 | '-moz-transition:background-color 0.2s ease;', 16 | '-o-transition:background-color 0.2s ease;', 17 | 'transition:background-color 0.2s ease;', 18 | 'pointer-events:none', 19 | '' 20 | ]; 21 | var videoCss = [ 22 | '', 23 | 'position:absolute', 24 | 'width:610px', 25 | 'height:458px', 26 | 'top:-500px', 27 | 'left:50%', 28 | 'margin-left:-306px', 29 | 'z-index:1000000000000', 30 | 'background:#000', 31 | 'box-shadow:0 0 5px #333', 32 | '-webkit-transition:top 1s ease;', 33 | '-moz-transition:top 1s ease;', 34 | '-o-transition:top 1s ease;', 35 | 'transition:top 1s ease;', 36 | '' 37 | ]; 38 | var aCss = [ 39 | '', 40 | 'position:absolute', 41 | 'bottom:0', 42 | 'left:0', 43 | 'right:0', 44 | 'height:30px;', 45 | 'text-align:center', 46 | 'font-size:14px', 47 | 'pointer-events:auto', 48 | '' 49 | ]; 50 | 51 | var btnCss = [ 52 | '', 53 | 'position:absolute', 54 | 'top:0', 55 | 'height:30px;', 56 | 'line-height:30px', 57 | 'width:60px', 58 | 'text-align:center', 59 | 'font-size:14px', 60 | 'letter-spacing:-1px', 61 | 'color:#014CCC', 62 | 'cursor:pointer', 63 | 'pointer-events:auto', 64 | '' 65 | ]; 66 | 67 | var changeBtnCss = [ 68 | '', 69 | 'position:absolute', 70 | 'width:500px', 71 | 'height:40px', 72 | 'top:470px', 73 | 'left:50%', 74 | 'margin-left:-250px', 75 | 'z-index:1000000000000', 76 | 'background:#000', 77 | 'box-shadow:0 0 5px #333', 78 | 'text-align:center', 79 | 'color:#eee', 80 | 'border-radius:150px', 81 | 'overflow:hidden', 82 | '' 83 | ]; 84 | 85 | var changeBtnItemCss = [ 86 | '', 87 | 'display:inline-block', 88 | 'width:150px', 89 | 'height:40px', 90 | 'line-height:40px', 91 | 'font-size:20px', 92 | 'cursor:pointer', 93 | '' 94 | ]; 95 | 96 | var pad = function(num, n) { 97 | return (new Array(n >(''+num).length ? (n - (''+num).length+1) : 0).join('0') + num); 98 | } 99 | 100 | var HTML5Player = function(){ 101 | //123/554/149/3 102 | //iidStr = iid.toString().match(/(\d{3})(\d{3})(\d{3})/); 103 | iidStr = pad(iid,9).match(/(\d{3})(\d{3})(\d{3})/); 104 | var idEncodeed = iidStr[1] + '/' + iidStr[2] + '/' + iidStr[3]; 105 | 106 | var t_yuanhuaSrc = 'http://m3u8.tdimg.com/'+idEncodeed+'/'+'99.m3u8'; 107 | var t_360Src = 'http://m3u8.tdimg.com/'+idEncodeed+'/'+'3.m3u8'; 108 | var t_256Src = 'http://m3u8.tdimg.com/'+idEncodeed+'/'+'2.m3u8'; 109 | 110 | var cover = document.createElement('div'); 111 | cover.style.cssText += coverCss.join(';'); 112 | 113 | var v = document.createElement('video'); 114 | v.setAttribute('height','458'); 115 | v.setAttribute('width','610'); 116 | v.setAttribute('controls','true'); 117 | v.setAttribute('autoplay','true'); 118 | v.style.cssText += videoCss.join(';'); 119 | v.src = t_yuanhuaSrc; 120 | 121 | 122 | var a = document.createElement('span'); 123 | a.innerHTML = '目前只有m3u8格式的支持,貌似只有safair才能播放。'; 124 | a.style.cssText += aCss.join(';'); 125 | cover.appendChild(a); 126 | 127 | var off = document.createElement('div'); 128 | off.innerHTML = '退出'; 129 | off.style.cssText += btnCss.join(';')+';right:0;'; 130 | cover.appendChild(off); 131 | var nocover = document.createElement('div'); 132 | nocover.innerHTML = '打开迷雾'; 133 | nocover.style.cssText += btnCss.join(';')+';right:60px;'; 134 | cover.appendChild(nocover); 135 | 136 | off.addEventListener('click',function(){ 137 | y.HTML5.remove(); 138 | y.flash.add(); 139 | y.flag = false; 140 | },false); 141 | 142 | nocover.addEventListener('click',function(){ 143 | cover.style.backgroundColor = 'rgba(255,255,255,0)'; 144 | },false); 145 | 146 | var changeBtn = document.createElement('div'); 147 | changeBtn.style.cssText += changeBtnCss.join(';'); 148 | 149 | var t_yuanhua = document.createElement('div'); 150 | t_yuanhua.style.cssText += changeBtnItemCss.join(';'); 151 | t_yuanhua.style.backgroundColor = '#666'; 152 | t_yuanhua.style.boxShadow = '0 0 3px #000 inset'; 153 | t_yuanhua.innerHTML = '原画'; 154 | changeBtn.appendChild(t_yuanhua); 155 | 156 | var t_360 = document.createElement('div'); 157 | t_360.style.cssText += changeBtnItemCss.join(';'); 158 | t_360.innerHTML = '360P'; 159 | changeBtn.appendChild(t_360); 160 | 161 | var t_256 = document.createElement('div'); 162 | t_256.style.cssText += changeBtnItemCss.join(';'); 163 | t_256.innerHTML = '256P'; 164 | changeBtn.appendChild(t_256); 165 | 166 | t_yuanhua.addEventListener('click',function(){ 167 | v.src = t_yuanhuaSrc; 168 | t_yuanhua.style.backgroundColor = '#666'; 169 | t_360.style.backgroundColor = 'transparent'; 170 | t_256.style.backgroundColor = 'transparent'; 171 | t_yuanhua.style.boxShadow = '0 0 3px #000 inset'; 172 | t_360.style.boxShadow = 'none'; 173 | t_256.style.boxShadow = 'none'; 174 | },false); 175 | 176 | t_360.addEventListener('click',function(){ 177 | v.src = t_360Src; 178 | t_360.style.backgroundColor = '#666'; 179 | t_yuanhua.style.backgroundColor = 'transparent'; 180 | t_256.style.backgroundColor = 'transparent'; 181 | t_360.style.boxShadow = '0 0 3px #000 inset'; 182 | t_yuanhua.style.boxShadow = 'none'; 183 | t_256.style.boxShadow = 'none'; 184 | },false); 185 | 186 | t_256.addEventListener('click',function(){ 187 | v.src = t_360Src; 188 | t_256.style.backgroundColor = '#666'; 189 | t_yuanhua.style.backgroundColor = 'transparent'; 190 | t_360.style.backgroundColor = 'transparent'; 191 | t_256.style.boxShadow = '0 0 3px #000 inset'; 192 | t_yuanhua.style.boxShadow = 'none'; 193 | t_360.style.boxShadow = 'none'; 194 | },false); 195 | 196 | 197 | 198 | return { 199 | add : function(){ 200 | document.body.appendChild(cover); 201 | document.body.appendChild(changeBtn); 202 | document.body.appendChild(v); 203 | 204 | v.addEventListener('canplay',v.play); 205 | setTimeout(function(){ 206 | cover.style.backgroundColor = 'rgba(255,255,255,0.6)'; 207 | v.style.top = '-1px'; 208 | },100); 209 | }, 210 | remove : function(){ 211 | v.pause(); 212 | cover.style.backgroundColor = 'rgba(255,255,255,0)'; 213 | v.style.top = '-500px'; 214 | setTimeout(function(){ 215 | cover.parentNode && document.body.removeChild(cover); 216 | v.parentNode && document.body.removeChild(v); 217 | changeBtn.parentNode && document.body.removeChild(changeBtn); 218 | },1100); 219 | } 220 | } 221 | } 222 | 223 | var flashPlayer = function(){ 224 | var flashOut = document.getElementById('player'); 225 | var flash = document.getElementById('playerObject'); 226 | return { 227 | add : function(){ 228 | flashOut.appendChild(flash); 229 | }, 230 | remove : function(){ 231 | flashOut.parentNode && flashOut.removeChild(flash); 232 | } 233 | } 234 | } 235 | 236 | window.isTudouHTML5PlayerBookMarkCodeByZythum = window.isTudouHTML5PlayerBookMarkCodeByZythum || {}; 237 | var y = window.isTudouHTML5PlayerBookMarkCodeByZythum; 238 | y.HTML5 = y.HTML5 || HTML5Player(); 239 | y.flash = y.flash || flashPlayer(); 240 | y.flag = y.flag || false; 241 | if(y.flag === false){ 242 | y.HTML5.add(); 243 | y.flash.remove(); 244 | y.flag = true; 245 | }else if(y.flag === true){ 246 | y.HTML5.remove(); 247 | y.flash.add(); 248 | y.flag = false; 249 | } 250 | 251 | })(); 252 | -------------------------------------------------------------------------------- /youkuhtml5playerbookmark.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | if(!window.videoId){ 3 | return false; 4 | } 5 | var coverCss = [ 6 | '', 7 | 'position:fixed', 8 | 'top:0', 9 | 'left:0', 10 | 'bottom:0', 11 | 'right:0', 12 | 'background-color:rgba(255,255,255,0)', 13 | 'z-index:999999999999', 14 | '-webkit-transition:background-color 0.2s ease;', 15 | '-moz-transition:background-color 0.2s ease;', 16 | '-o-transition:background-color 0.2s ease;', 17 | 'transition:background-color 0.2s ease;', 18 | 'pointer-events:none', 19 | '' 20 | ]; 21 | var videoCss = [ 22 | '', 23 | 'position:absolute', 24 | 'width:610px', 25 | 'height:458px', 26 | 'top:-500px', 27 | 'left:50%', 28 | 'margin-left:-306px', 29 | 'z-index:1000000000000', 30 | 'background:#000', 31 | 'box-shadow:0 0 5px #333', 32 | '-webkit-transition:top 1s ease;', 33 | '-moz-transition:top 1s ease;', 34 | '-o-transition:top 1s ease;', 35 | 'transition:top 1s ease;', 36 | '' 37 | ]; 38 | var aCss = [ 39 | '', 40 | 'position:absolute', 41 | 'bottom:0', 42 | 'left:0', 43 | 'right:0', 44 | 'height:30px;', 45 | 'text-align:center', 46 | 'font-size:14px', 47 | 'pointer-events:auto', 48 | '' 49 | ]; 50 | 51 | var btnCss = [ 52 | '', 53 | 'position:absolute', 54 | 'top:0', 55 | 'height:30px;', 56 | 'line-height:30px', 57 | 'width:60px', 58 | 'text-align:center', 59 | 'font-size:14px', 60 | 'letter-spacing:-1px', 61 | 'color:#014CCC', 62 | 'cursor:pointer', 63 | 'pointer-events:auto', 64 | '' 65 | ]; 66 | 67 | var changeBtnCss = [ 68 | '', 69 | 'position:absolute', 70 | 'width:500px', 71 | 'height:40px', 72 | 'top:470px', 73 | 'left:50%', 74 | 'margin-left:-250px', 75 | 'z-index:1000000000000', 76 | 'background:#000', 77 | 'background-image: -webkit-linear-gradient(top,#333,#000)', 78 | 'background-image: -moz-linear-gradient(top,#333,#000)', 79 | 'background-image: -ms-linear-gradient(top,#333,#000)', 80 | 'background-image: -o-linear-gradient(top,#333,#000)', 81 | 'background-image: linear-gradient(top,#333,#000)', 82 | 'box-shadow:0 0 5px #333', 83 | 'text-align:center', 84 | 'color:#eee', 85 | 'border-radius:150px', 86 | 'overflow:hidden', 87 | '' 88 | ]; 89 | 90 | var changeBtnItemCss = [ 91 | '', 92 | 'display:inline-block', 93 | 'width:90px', 94 | 'height:40px', 95 | 'line-height:40px', 96 | 'font-size:20px', 97 | 'cursor:pointer', 98 | '' 99 | ]; 100 | 101 | 102 | var HTML5Player = function(){ 103 | 104 | var hd2Src= '/player/getM3U8/vid/'+videoId+'/type/hd2/ts/'+(((new Date()).getTime()/1000).toString()|0)+'/v.m3u8'; 105 | var mp4Src= '/player/getM3U8/vid/'+videoId+'/type/mp4/ts/'+(((new Date()).getTime()/1000).toString()|0)+'/v.m3u8'; 106 | var flvSrc= '/player/getM3U8/vid/'+videoId+'/type/flv/ts/'+(((new Date()).getTime()/1000).toString()|0)+'/v.m3u8'; 107 | var mp4Src2 = 'http://3g.youku.com/pvs?id='+videoId2+'&format=3gphd'; 108 | //var m3u8Src= '/player/getM3U8/vid/'+videoId+'/type/mp4/flv/ts/'+(new Date()).getTime()+'/v.m3u8'; 109 | var cover = document.createElement('div'); 110 | cover.style.cssText += coverCss.join(';'); 111 | 112 | var v = document.createElement('video'); 113 | v.setAttribute('height','458'); 114 | v.setAttribute('width','610'); 115 | v.setAttribute('controls','true'); 116 | v.setAttribute('autoplay','true'); 117 | v.style.cssText += videoCss.join(';'); 118 | v.src = hd2Src; 119 | 120 | 121 | var a = document.createElement('a'); 122 | a.setAttribute('href',mp4Src); 123 | a.innerHTML = '不能直接观看,点击这里:'+mp4Src; 124 | a.style.cssText += aCss.join(';'); 125 | cover.appendChild(a); 126 | 127 | var off = document.createElement('div'); 128 | off.innerHTML = '退出'; 129 | off.style.cssText += btnCss.join(';')+';right:0;'; 130 | cover.appendChild(off); 131 | var nocover = document.createElement('div'); 132 | nocover.innerHTML = '打开迷雾'; 133 | nocover.style.cssText += btnCss.join(';')+';right:60px;';; 134 | cover.appendChild(nocover); 135 | 136 | off.addEventListener('click',function(){ 137 | y.HTML5.remove(); 138 | y.flash.add(); 139 | y.flag = false; 140 | },false); 141 | 142 | nocover.addEventListener('click',function(){ 143 | cover.style.backgroundColor = 'rgba(255,255,255,0)'; 144 | },false); 145 | 146 | var changeBtn = document.createElement('div'); 147 | changeBtn.style.cssText += changeBtnCss.join(';'); 148 | 149 | 150 | var hd2btn = document.createElement('div'); 151 | hd2btn.style.cssText += changeBtnItemCss.join(';'); 152 | hd2btn.style.backgroundColor = '#666'; 153 | hd2btn.style.boxShadow = '0 0 3px #000 inset'; 154 | hd2btn.innerHTML = '超清'; 155 | changeBtn.appendChild(hd2btn); 156 | 157 | var mp4btn = document.createElement('div'); 158 | mp4btn.style.cssText += changeBtnItemCss.join(';'); 159 | mp4btn.innerHTML = '高清'; 160 | changeBtn.appendChild(mp4btn); 161 | 162 | var flvbtn = document.createElement('div'); 163 | flvbtn.style.cssText += changeBtnItemCss.join(';'); 164 | flvbtn.innerHTML = '标清'; 165 | changeBtn.appendChild(flvbtn); 166 | 167 | var mp4btn2 = document.createElement('div'); 168 | mp4btn2.style.cssText += changeBtnItemCss.join(';'); 169 | mp4btn2.innerHTML = 'mp4'; 170 | changeBtn.appendChild(mp4btn2); 171 | 172 | hd2btn.addEventListener('click',function(){ 173 | v.src = hd2Src; 174 | hd2btn.style.backgroundColor = '#666'; 175 | hd2btn.style.boxShadow = '0 0 3px #000 inset'; 176 | mp4btn.style.backgroundColor = 'transparent'; 177 | mp4btn.style.boxShadow = 'none'; 178 | flvbtn.style.backgroundColor = 'transparent'; 179 | flvbtn.style.boxShadow = 'none'; 180 | mp4btn2.style.backgroundColor = 'transparent'; 181 | mp4btn2.style.boxShadow = 'none'; 182 | },false); 183 | 184 | mp4btn.addEventListener('click',function(){ 185 | v.src = mp4Src; 186 | mp4btn.style.backgroundColor = '#666'; 187 | mp4btn.style.boxShadow = '0 0 3px #000 inset'; 188 | hd2btn.style.backgroundColor = 'transparent'; 189 | hd2btn.style.boxShadow = 'none'; 190 | flvbtn.style.backgroundColor = 'transparent'; 191 | flvbtn.style.boxShadow = 'none'; 192 | mp4btn2.style.backgroundColor = 'transparent'; 193 | mp4btn2.style.boxShadow = 'none'; 194 | },false); 195 | 196 | flvbtn.addEventListener('click',function(){ 197 | v.src = flvSrc; 198 | flvbtn.style.backgroundColor = '#666'; 199 | flvbtn.style.boxShadow = '0 0 3px #000 inset'; 200 | hd2btn.style.backgroundColor = 'transparent'; 201 | hd2btn.style.boxShadow = 'none'; 202 | mp4btn.style.backgroundColor = 'transparent'; 203 | mp4btn.style.boxShadow = 'none'; 204 | mp4btn2.style.backgroundColor = 'transparent'; 205 | mp4btn2.style.boxShadow = 'none'; 206 | },false); 207 | 208 | mp4btn2.addEventListener('click',function(){ 209 | v.src = mp4Src2; 210 | mp4btn2.style.backgroundColor = '#666'; 211 | mp4btn2.style.boxShadow = '0 0 3px #000 inset'; 212 | hd2btn.style.backgroundColor = 'transparent'; 213 | hd2btn.style.boxShadow = 'none'; 214 | flvbtn.style.backgroundColor = 'transparent'; 215 | flvbtn.style.boxShadow = 'none'; 216 | mp4btn.style.backgroundColor = 'transparent'; 217 | mp4btn.style.boxShadow = 'none'; 218 | },false); 219 | 220 | return { 221 | add : function(){ 222 | document.body.appendChild(cover); 223 | document.body.appendChild(changeBtn); 224 | document.body.appendChild(v); 225 | 226 | v.addEventListener('canplay',v.play); 227 | setTimeout(function(){ 228 | cover.style.backgroundColor = 'rgba(255,255,255,0.6)'; 229 | v.style.top = '-1px'; 230 | },100); 231 | }, 232 | remove : function(){ 233 | v.pause(); 234 | cover.style.backgroundColor = 'rgba(255,255,255,0)'; 235 | v.style.top = '-500px'; 236 | setTimeout(function(){ 237 | cover.parentNode && document.body.removeChild(cover); 238 | v.parentNode && document.body.removeChild(v); 239 | changeBtn.parentNode && document.body.removeChild(changeBtn); 240 | },1100); 241 | } 242 | } 243 | } 244 | 245 | var flashPlayer = function(){ 246 | var flash = document.getElementById('movie_player'); 247 | var flashOut = flash.parentNode; 248 | return { 249 | add : function(){ 250 | flashOut.appendChild(flash); 251 | }, 252 | remove : function(){ 253 | flashOut.parentNode && flashOut.removeChild(flash); 254 | } 255 | } 256 | } 257 | 258 | window.isYoukuHTML5PlayerBookMarkCodeByZythum = window.isYoukuHTML5PlayerBookMarkCodeByZythum || {}; 259 | var y = window.isYoukuHTML5PlayerBookMarkCodeByZythum; 260 | y.HTML5 = y.HTML5 || HTML5Player(); 261 | y.flash = y.flash || flashPlayer(); 262 | y.flag = y.flag || false; 263 | if(y.flag === false){ 264 | y.HTML5.add(); 265 | y.flash.remove(); 266 | y.flag = true; 267 | }else if(y.flag === true){ 268 | y.HTML5.remove(); 269 | y.flash.add(); 270 | y.flag = false; 271 | } 272 | 273 | })(); --------------------------------------------------------------------------------