rokidog
Silver Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору // ==UserScript== // @name YouTube force flash // @version 4 // @author Bladru // @description Forces YouTube to use flash player instead of HTML5 one. // @include https://*.youtube.com/* // @include https://*.youtube-nocookie.com/* // @include https://*.youtubeeducation.com/* // @include https://*.googleapis.com/* // ==/UserScript== /* Opera only. Save as "YouTube_force_flash.js" (without .user). http://forum.ru-board.com/topic.cgi?forum=5&topic=48802&start=1040#19 */ (function(){ function patch_scripts(UserJSEvent){ var script = UserJSEvent.element; /* replacing 'if(!b)' in function(a,b) with 'if(!(b="flash"))' */ var regex_match = /(\)\{if\(!)b(\)\{var c;if\(!\(c=!a\.[\w$]+\.html5&&[\w$.]+\(a\)\)\)\{if\(![\w$.]+\(a\.[\w$]+\.disable\.html5\)\))/; var str_replace = '$1(b="flash")$2'; if (script.src.match(/\/www-[^\/]*\/base\.js$/) || script.src.match(/\/www-[^\/]*\/www-embed-player\.js$/) || script.src.match(/\/www-[^\/]*\/www-pageframe\.js$/) // not sure where is it used ){ // console.debug(script.src); if (!regex_match.test(script.text)) console.warn('YouTube_force_flash: no match found in ' + script.src); script.text = script.text.replace(regex_match, str_replace); } /* RegEx to escape js code: string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); */ /* one of the targeted functions: Jh=function(a,b){if(!a.isDisposed()){if(!b){var c;if(!(c=!a.C.html5&&Hh(a))){if(!g.ja(a.C.disable.html5)){var d;c=!0;void 0!=a.C.args.deviceHasDisplay&&(c=a.C.args.deviceHasDisplay);if(2.2==Lh)d=!0;else{a:{var e=c;c=g.r("yt.player.utils.videoElement_");c||(c=g.xd("VIDEO"),g.p("yt.player.utils.videoElement_",c,void 0));try{if(c.canPlayType)for(var e=e?Qba:Rba,h=0;h<e.length;h++)if(c.canPlayType(e[h])){d=null;break a}d="fmt.noneavailable"}catch(k){d="html5.missingapi"}}d=!d}d&&(d=Mh(a)||a.C.assets.js); a.C.disable.html5=!d;d||(a.C.args.html5_unavailable="1")}c=!!a.C.disable.html5}b=c?Hh(a)?"flash":"unsupported":"html5"}("flash"==b?a.FR:a.GR).call(a)}}; */ } window.opera.addEventListener('BeforeScript', patch_scripts); /* disable HTML5 player creation on youtube.com pages */ function prevent_create(UserJSEvent){ if (window.yt && yt.player && yt.player.Application) yt.player.Application.create = function(){}; } window.opera.addEventListener('AfterScript', prevent_create); })(); | Всего записей: 2038 | Зарегистр. 21-06-2010 | Отправлено: 17:01 27-07-2017 | Исправлено: rokidog, 17:11 27-07-2017 |
|