Greasemonkey Manual
// ==UserScript== // @name CloudTube // @namespace http://tubewall.isgreat.org/ // @description 云~电视 // @include * // ==/UserScript==
/**
* 从这个版本开始,TubeWall-2 脚本使用TubeWall自动生成的脚本代码。 * 因此,代码看着比较乱,有兴趣你可以下载TubeWall源码来看。 * * TubeWall源码地址: * http://code.google.com/p/tubewall * */
(function(){ var d=document;
var h=d.getElementsByTagName('head')[0];
if(!d.getElementById('cloud_tube')){
var script=d.createElement('script');
script.appendChild(d.createTextNode("\n(function(){\n\n\tfunction addEvent(obj, type, fn){\n\t\tif(obj.attachEvent){\n\t\t\tobj['e'+type+fn] = fn;\n\t\t\tobj[type+fn] = function(){obj['e'+type+fn](window.event);}\n\t\t\tobj.attachEvent('on'+type, obj[type+fn]);\n\t\t}else\n\t\t\tobj.addEventListener( type, fn, false );\n\t}\n\n\tfunction removeEvent(obj, type, fn){\n\t\tif(obj.detachEvent){\n\t\t\tobj.detachEvent('on'+type, obj[type+fn]);\n\t\t\tobj[type+fn] = null;\n\t\t}else\n\t\t\tobj.removeEventListener( type, fn, false );\n\t}\n\n\tfunction cloneArray(arr){\n\t\tvar res = [];\n\t\tfor(var i=0,l=arr.length;i<l;i++){\n\t\t\tres[i] = arr[i];\n\t\t}\n\t\treturn res;\n\t}\n\t\n\tvar tubewall = {\n\n\t\tregLink: \/^https?:\\\/\\\/www\\.youtube\\.com\\\/watch\\?(?:.*&)?v=([_\\-\\d\\w]+)\/gi,\n\t\tregPlayer: \/^https?:\\\/\\\/www\\.youtube\\.com\\\/v\\\/([_\\-\\d\\w]+)\/gi,\n\n\t\trun: function(){\n\t\t\tvar p = tubewall.process;\n\t\t\taddEvent(document, 'DOMNodeInserted', function(e){\n\t\t\t\tp((e.target||e.srcElement));\n\t\t\t});\n\t\t\tp();\n\t\t},\n\n\t\tprocess: function(elem){\n\t\t\ttubewall.processLink(elem);\n\t\t\ttubewall.processPlayer(elem);\n\t\t},\n\n\t\tprocessLink: function(elem){\n\t\t\telem = elem || document;\n\n\t\t\tif(!elem.getElementsByTagName)\n\t\t\t\treturn;\n\n\t\t\tvar a = elem.getElementsByTagName('a');\n\t\t\n\t\t\tfor(var i=0,l = a.length; i<l; i++){\n\t\t\t\tvar m;\n\t\t\t\twhile((m = tubewall.regLink.exec(a[i].href)) != null){\n\t\t\t\t\ta[i].href = \"http:\\\/\\\/tubewall.isgreat.org\\\/watch\\\/{videoId}\".replace('{videoId}',m[1]);\n\t\t\t\t\ta[i].className += ' tubewall-link';\n\t\t\t\t\tif(window.location.host.indexOf('www.google.com') != -1){\n\t\t\t\t\t\ta[i].setAttribute('onmousedown',); \/\/\u53bb\u6389\u94fe\u63a5\u8ffd\u8e2a\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t},\n\n\t\tprocessPlayer: function(elem){\n\t\t\telem = elem || document;\n\n\t\t\tif(!elem.getElementsByTagName)\n\t\t\t\treturn;\n\t\t\t\n\t\t\ttubewall._replaceObject(elem);\n\t\t\ttubewall._replaceEmbed(elem);\n\t\t},\n\n\t\t_replaceObject: function(elem){\n\n\t\t\tvar objects = cloneArray(elem.getElementsByTagName('object'));\n\n\t\t\tfor(var i=0,li = objects.length; i<li; i++) {\n\t\t\t\tvar o = objects[i];\n\t\t\t\tvar params = o.getElementsByTagName('param');\n\t\t\t\tvar width = o.getAttribute('width');\n\t\t\t\tvar height = o.getAttribute('height');\n\t\t\t\n\t\t\t\tfor(var j=0,lj = params.length; j<lj; j++) {\n\t\t\t\t\tvar p = params[j];\n\t\t\t\t\tvar n = p.getAttribute('name');\n\t\t\t\t\tvar v = p.getAttribute('value');\n\t\t\t\t\tvar m = null;\n\t\t\t\t\tif(n == 'movie' && (m = tubewall.regPlayer.exec(v)) != null){\n\t\t\t\t\t\tvar player = tubewall.createPlayer(m[1],width,height);\n\t\t\t\t\t\to.parentNode.insertBefore(player, o.nextSibling);\n\t\t\t\t\t\to.parentNode.removeChild(o);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\t\t},\n\n\t\t_replaceEmbed: function(elem){\n\n\t\t\tvar embed = cloneArray(elem.getElementsByTagName('embed'));\n\n\t\t\tfor(var i=0,l = embed.length; i<l; i++) {\n\t\t\t\tvar e = embed[i];\n\t\t\t\tvar src = e.getAttribute('src');\n\t\t\t\tvar width = e.getAttribute('width');\n\t\t\t\tvar height = e.getAttribute('height');\n\t\t\t\tvar m = null;\n\t\t\t\twhile((m = tubewall.regPlayer.exec(src)) != null){\n\t\t\t\t\tvar player = tubewall.createPlayer(m[1],width,height);\n\t\t\t\t\te.parentNode.insertBefore(player, e.nextSibling);\n\t\t\t\t\te.parentNode.removeChild(e);\n\t\t\t\t\tsrc = null;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t\n\t\tlistCache: {},\n\n\t\tcreatePlayer: function(videoId, width, height){\n\t\t\twidth = width || 640;\n\t\t\theight = height || 505;\n\n\t\t\tvar flashvars = 'file='+ encodeURIComponent(\"http:\\\/\\\/tubewall.isgreat.org\\\/cloud-tube\\\/lite.php?id={videoId}&video.mp4\".replace('{videoId}',videoId));\n\n\t\t\tvar player = document.createElement('div');\n\t\t\tplayer.className = 'tubewall-player';\n\n\t\t\tvar playerFlash = document.createElement('div');\n\t\t\tplayerFlash.className = 'tubewall-player-flash';\n\n\t\t\tvar playerToolbar = document.createElement('div');\n\t\t\tplayerToolbar.className = 'tubewall-player-toolbar';\n\n\t\t\tvar title = document.createElement('span');\n\t\t\ttitle.innerHTML = '~Cloud Tube~<\/b>';\n\n\t\t\tvar showList = document.createElement('input');\n\t\t\tshowList.setAttribute('type','button');\n\t\t\tshowList.setAttribute('value','Download');\n\t\t\taddEvent(showList, 'click', function(){\n\t\t\t\tif(tubewall.listCache[videoId]){\n\t\t\t\t\tplayerToolbar.appendChild(tubewall.listCache[videoId]);\n\t\t\t\t}else{\n\t\t\t\t\ttubewall.getDownloadList(videoId, function(json){\n\t\t\t\t\t\ttubewall.listCache[videoId] = tubewall.createList(json);\n\t\t\t\t\t\tplayerToolbar.appendChild(tubewall.listCache[videoId]);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t\tplayerToolbar.appendChild(title);\n\t\t\tplayerToolbar.appendChild(showList);\n\n\t\t\tvar src = \"http:\\\/\\\/developer.longtailvideo.com\\\/player\\\/tags\\\/mediaplayer-5.0\\\/player.swf\";\n\n\t\t\tplayerFlash.innerHTML='<object width=\"480\" height=\"385\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\">'\n\t\t\t\t+ '<param name=\"movie\" value=\"'+src+'\"><\/param>'\n\t\t\t\t+ '<param name=\"allowFullScreen\" value=\"true\"><\/param>'\n\t\t\t\t+ '<param name=\"allowscriptaccess\" value=\"always\"><\/param>'\n\t\t\t\t+ '<param name=\"flashvars\" value=\"'+flashvars+'\"><\/param>'\n\t\t\t\t+'<embed '\n\t\t\t\t+' src=\"'+src+'\"'\n\t\t\t\t+' quality=\"high\"'\n\t\t\t\t+' allowfullscreen=\"true\"'\n\t\t\t\t+' wmode=\"Transparent\"'\n\t\t\t\t+' type=\"application\/x-shockwave-flash\"'\n\t\t\t\t+' width=\"'+width+'\"'\n\t\t\t\t+' height=\"'+height+'\"'\n\t\t\t\t+' flashvars=\"'+flashvars+'\"'\n\t\t\t\t+' ><\/embed>'\n\t\t\t+'<\/object>'\n\t\t\t;\n\n\t\t\tplayer.appendChild(playerFlash);\n\t\t\tplayer.appendChild(playerToolbar);\n\n\t\t\treturn player;\n\n\t\t},\n\n\t\tcreateList: function(list){\n\t\t\tvar s = document.createElement('select'),o;\n\t\t\to = document.createElement('option');\n\t\t\to.innerHTML = '== Select a format ==';\n\t\t\ts.appendChild(o);\n\t\t\tfor(var i = 0, l = list.length; i<l; i++){\n\t\t\t\to = document.createElement('option');\n\t\t\t\to.setAttribute('value', list[i]['url']);\n\t\t\t\to.innerHTML = list[i]['name'];\n\t\t\t\ts.appendChild(o);\n\t\t\t}\n\t\t\taddEvent(s,'change',function(e){\n\t\t\t\tvar t=(e.target || e.srcElement);\n\t\t\t\tvar url = t.options[t.selectedIndex].value;\n\t\t\t\tif(url!=null&&url!=)\n\t\t\t\t\twindow.location = url;\n\t\t\t});\n\t\t\treturn s;\n\t\t},\n\n\t\tjsonpCount: Number(new Date),\n\n\t\tgetDownloadList: function(videoId, callback){\n\n\t\t\tvar jp = 'tubewall_list_' + tubewall.jsonpCount ++;\n\n\t\t\twindow[jp] = function(json){\n\n\t\t\t\tcallback(json);\n\n\t\t\t\twindow[jp] = undefined;\n\t\t\t\ttry{\n\t\t\t\t\tdelete window[jp];\n\t\t\t\t}catch(e){}\n\t\t\t\tif(head){\n\t\t\t\t\thead.removeChild(script);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tvar head = document.getElementsByTagName('head')[0] || document.documentElement;\n\t\t\tvar script = document.createElement('script');\n\t\t\tscript.src = \"http:\\\/\\\/tubewall.isgreat.org\\\/download\\\/list\\\/{videoId}?callback={jp}\".replace('{videoId}',videoId).replace('{jp}',jp);\n\t\t\thead.insertBefore(script, head.firstChild);\n\t\t\t\n\t\t}\n\t\t\n\t};\n\n\ttubewall.run();\n\n})();\n"));
script.setAttribute('id','cloud_tube');
var style=d.createElement('style');
style.appendChild(d.createTextNode("\n.tubewall-link{\n\ttext-decoration:none;\n\tdisplay:inline-block;\n\tborder:1px solid;\n\tmin-height:18px;\n\tpadding:2px;\n\tpadding-left:20px;\n\t-moz-border-radius:5px;\n\t-webkit-border-radius:5px;\n\tbackground:url(data:image\/x-icon;base64,AAABAAEAEBAAAAEAGABoAwAAFgAAACgAAAAQAAAAIAAAAAEAGAAAAAAAAAAAABMLAAATCwAAAAAAAAAAAADQ0P8PCv8PCv8PCv8PCv8PCv8PCv8PCv8PCv8PCv8PCv8PCv8PCv8PCv8PCv\/Q0P8PCv8AAOoAAOoAAOoAAOoAAOoAAOoAAOoAAOoAAOoAAOoAAOoAAOoAAOoAAOoPCv8PCv8PCv\/\/\/\/8+Pv+sqv\/\/\/\/\/\/\/\/8+Pv\/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/\/\/\/\/8AAAD8lewAAAD\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/9en8sPOWz\/\/\/+aUjbbuJH\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/8AAD4KAAA8awAAPmMAAC5hAABsZQAAcmkAAC50AABrZQAAY3IAAHRvAAAvawAAPgoAADxzAABpbgAAY28AAGFw) no-repeat 2px 50% ;\n}\n.tubewall-link:hover{\n\tbackground-color:#ddeef6 !important;\n}\n.tubewall-player{\n\t-moz-border-radius:5px;\n\t-webkit-border-radius:5px;\n\tborder:1px solid;\n\tdisplay:inline-block;\n}\n.tubewall-player-toolbar a{\n\ttext-decoration:none;\n}\n.tubewall-player-flash{\n\tpadding:5px;\n}\n.tubewall-player-toolbar{\n\tfont-size:1em;\n\tmargin:0;\n\tpadding:2px;\n\tpadding-left:23px;\n\tborder-top:1px solid;\n\tword-wrap:break-word;\n\tbackground:url(data:image\/x-icon;base64,AAABAAEAEBAAAAEAGABoAwAAFgAAACgAAAAQAAAAIAAAAAEAGAAAAAAAAAAAABMLAAATCwAAAAAAAAAAAADQ0P8PCv8PCv8PCv8PCv8PCv8PCv8PCv8PCv8PCv8PCv8PCv8PCv8PCv8PCv\/Q0P8PCv8AAOoAAOoAAOoAAOoAAOoAAOoAAOoAAOoAAOoAAOoAAOoAAOoAAOoAAOoPCv8PCv8PCv\/\/\/\/8+Pv+sqv\/\/\/\/\/\/\/\/8+Pv\/Fw\/\/\/\/\/+jov8PCv+Jhv\/\/\/\/\/Ixv8PCv8PCv8PCv\/\/\/\/8+Pv\/\/\/\/8PCv\/\/\/\/8+Pv\/\/\/\/8PCv\/\/\/\/+Ihf\/\/\/\/8PCv8PCv8PCv8PCv8PCv\/\/\/\/8+Pv\/\/\/\/8PCv\/\/\/\/8+P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/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/8AAD4KAAA8awAAPmMAAC5hAABsZQAAcmkAAC50AABrZQAAY3IAAHRvAAAvawAAPgoAADxzAABpbgAAY28AAGFw) no-repeat 5px 50% !important;\n}\n.tubewall-player-toolbar ul{\n\tposition:absolute;\n\tdisplay:inline-block;\n\tpadding:0;\n\tmargin:0;\n}\n.tubewall-player-toolbar li{\n\tlist-style:none;\n\tpadding:0;\n\tmargin:0;\n}\n"));
h.appendChild(script);
h.appendChild(style);
}
})();