.



on-line?
? ?
Ru.Board » » » Opera Presto ( 27)

: gyra, Maz

   •

     

Alex_Qwerty

Silver Member
| | | |


:
 
// ==UserScript==
// @in-clude *
// @include *//youtube.com/*
// @include *.youtube.com/*
// @include *//youtube-nocookie.com/*
// @include *.youtube-nocookie.com/*
// @include *//youtubeeducation.com/*
// @include *.youtubeeducation.com/*
// @exclude http://tparser.org/*
// ==/UserScript==
 
if ( document.contentType=='text/html' || (''+location).match(/[/.]youtube(-nocookie|education|).com\/v\//) ) (function(opera){
 
var ScriptName = 'youtube_fix.js v18';
 
var conf = {
 fixObjects : true// object -> iframe
, fixInsertedObjects : {
 enabled: true// may break sites; use whitelist or // @exclude *
, blacklist : ['translate.yandex.ru'] // [] - works anywhere; ['tparser.org']
, whitelist : [] // [] - works anywhere; ['3dnews.ru', 'livejournal.com']
}
, blockYoutubeScripts : true// except player base.js
//, loadComments : true// don't works
, addLinksInEmbeds : true
, loadThumbnails : true
, fixList : true// for long channel lists
, fontFamily: 'Arial'
, fontSize: '16px'
, ytkey: "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8"
}
 
var showConf = true;
function log(str){
opera.postError(ScriptName +(str?': '+str:'')+(showConf?'\nconf='+JSON.stringify(conf):''));
showConf = false;
}
 
function findHost(hosts, host){
var flag = -1;
while (flag==-1 && host) {
flag = hosts.indexOf(host);
host = host.replace(/^[^.]*\.?/,'');
}
return flag;
}
var youtubeHosts = ['youtube.com','youtube-nocookie.com','youtubeeducation.com'];
 
function splitKV(str, o) {
o = o || {};
var tmp;
var re = /([\da-z_]+)=([^&]*)/gi;
while ( (tmp = re.exec(str))!==null ) { o[tmp[1]] = decodeURIComponent(tmp[2].replace(/\+/g,' '));}
return o;
}
 
function getField(obj) {
var tmp = obj;
if (tmp) for (var i=1; i<arguments.length; i++) {
tmp = tmp[arguments[i]];
if (!tmp) break;
}
return tmp;
}
 
function padZero(number, length) {
if (number===null||number===false) return;
var str = '' + number;
while ( str.length < length) { str = '0' + str; }
return str;
}
function s2hms(n) {
var h = Math.floor(n/60/60);
var m = Math.floor((n/60)%60);
var s = n%60;
return padZero(h,2)+':'+padZero(m,2)+':'+padZero(s,2);
}
 
function create(el, cn, ih){var tmp=document.createElement(el); if(cn)tmp.className=cn; tmp.innerHTML=ih||''; return tmp; }
 
function xhr(url, method, post, xml, headers){
var x = new XMLHttpRequest();
x.open(method || 'GET', url, false);
if (headers) for (var i=0; i<headers.length; i++) x.setRequestHeader(headers[i][0], headers[i][1]);
x.send(post);
return xml?x.responseXML:x.responseText;
}
 
var isYoutube = findHost(youtubeHosts, location.hostname)!=-1;
 
var lpath = location.pathname.split('/');
var lsearch = splitKV(location.search.slice(1));
var polymerShit = ['c','channel','user'];
 
if (isYoutube && lpath[1]) {
if (lpath[1]=='v' && (lpath[2]||'').length==11) {
stop();
log('redirecting to /embed/');
location = '/embed/'+v[1];
}
if (lpath[3]=='playlists') delete lpath[3];
if (~polymerShit.indexOf(lpath[1]) && !lpath[3]) {
stop();
lpath[3]='videos';
location = lpath.join('/');
}
}
 
var videoId = lsearch.v || lpath[1]=='embed' && lpath[2];
 
if (conf.blockYoutubeScripts && isYoutube) {
var once = true;
window.canBlockPlayerBase = true;
var needPlayerBase = true;
var func = function(){};
requestAnimationFrame = func;
writeEmbed = func;
writeLightweightEmbed = func;
spf = {script:{path:func, declare:func}};
   ytcsi = {info: func, tick:func};
yt = {config_:{}, pushConfigArray:func, setMsg:func}
 
yt.setConfig = function(o,v){
if (v) { yt.config_[o]=v } else {for (var k in o) yt.config_[k]=o[k]}
if (needPlayerBase && o && o.PLAYER_CONFIG && o.PLAYER_CONFIG.assets && o.PLAYER_CONFIG.assets.js) {
var s = document.createElement('script');
s.src = o.PLAYER_CONFIG.assets.js;
document.body.appendChild(s);
log('inserted player base.js: '+s.src);
needPlayerBase = false;
}
}
 
var moreButton;
 
/*
/s/player/4fbb4d5b/player_ias.vflset/ru_RU/base.js
*/
 
function ff(){
if (!moreButton) {
moreButton = document.querySelector('button#more');
if (moreButton){
var L=document.selectNodes('//link[@rel="next"]');
for (var l=0; l<L.length; l++) { L[l].parentNode.removeChild(L[l]);};
var ln=document.createElement('link');
ln.rel='next';
ln.href="javascript:document.querySelector('button#more').click()";
document.body.appendChild(ln);
opera.postError(ScriptName+' FF');
}
}
}
 
opera.addEventListener("BeforeExternalScript",function(e){
if (e.element.src.match(/\/player.*?\/base\.js/)) {
needPlayerBase = false;
} else {
e.preventDefault();
if (once) once = log('blocking youtube scripts...');
}
},false);
}
 
 
function getNextCrap(data){
//alert(JSON.stringify(data,null,'\t'))
var tmp = data[data.length-1];
//tmp = getField(tmp,'continuationItemRenderer','continuationEndpoint','continuationCommand','token')
//|| getField(data[data.length-1],'continuationItemRenderer','continuationEndpoint','continuationCommand','token');
tmp = getField(tmp,'continuationItemRenderer','continuationEndpoint')
|| getField(data[data.length-1],'continuationItemRenderer','continuationEndpoint');
if (tmp) {
window.__more_crap = tmp.continuationCommand.token;
window.__more_crap_url = tmp.commandMetadata.webCommandMetadata.apiUrl;
//alert(tmp);
}
}
 
 
document.addEventListener('DOMContentLoaded',function(){
 
var ytconfig = getField(window.yt, 'config_') || {};
var cver = ytconfig.INNERTUBE_CLIENT_VERSION; // 2.20210128.02.00
var cname = ytconfig.INNERTUBE_CLIENT_NAME; // WEB
var ckey = ytconfig.INNERTUBE_API_KEY;
 
var searchform = '<form action="/results" style="z-index: 123; position: fixed"><input name="search_query" type="text" tabindex="1" size=88 value="'
+(lsearch.search_query||'').replace(/"/g,'&quot;')+'"/><input type=submit value=search></form>';
 
if (location.pathname=='/') document.body.innerHTML = searchform;
 
if (lpath[3]=='videos' || lpath[1]=='feed' || lpath[1]=='results') {
if (!window.ytInitialData) {
for (var i=0; i<document.scripts.length; i++){
if (document.scripts[i].innerHTML.indexOf('window["ytInitialData"]')!=-1) eval(document.scripts[i].innerHTML);
}
}
 
/*
https://www.youtube.com/results?search_query=test&search=Search
ytInitialData.contents.twoColumnSearchResultsRenderer.primaryContents.sectionListRenderer.contents[0].itemSectionRenderer.contents[{videoRenderer.videoId
 
https://www.youtube.com/c/name/videos
ytInitialData.contents.twoColumnBrowseResultsRenderer.tabs[1].tabRenderer.content.sectionListRenderer.contents[0].itemSectionRenderer.contents[0].gridRenderer.items []
 
 
 
*/
 
if (window["ytInitialData"]) {
//var data = window["ytInitialData"].contents.twoColumnBrowseResultsRenderer.tabs[1].tabRenderer.content.sectionListRenderer.contents[0].itemSectionRenderer.contents[0].gridRenderer;
//alert(JSON.stringify(ytInitialData,null,'\t'));
var cont, track, browseCont, browseTrack;
var data = window["ytInitialData"].contents;
data = data.twoColumnBrowseResultsRenderer || data.twoColumnSearchResultsRenderer;
if (data.tabs) {
data = data.tabs;
data = data[1]||data[0];// 1 - channel, 0 - feed
//data = data.tabRenderer.content;
} else {
data = data.primaryContents;
}
data = data.sectionListRenderer || data.richGridRenderer || data;
 
var tmpdata = getField(data, 'contents', "twoColumnBrowseResultsRenderer", "tabs");
if (tmpdata) {
for (var i=0; i<tmpdata.length; i++){
var tmp = getField(tmpdata[i], 'tabRenderer', "endpoint", "commandMetadata", "webCommandMetadata", "webPageType");
if (tmp=="WEB_PAGE_TYPE_CHANNEL") {
data = tmpdata;
break;
}
}
}
 
var continuations = getField(data, 'tabRenderer', 'content', 'sectionListRenderer', 'contents', 0, 'itemSectionRenderer', 'contents', 0, 'gridRenderer', 'continuations');
 
 
//alert(continuations);
browseCont = getField(continuations, 0, 'nextContinuationData', 'continuation');
       browseTrack = getField(continuations, 0, 'nextContinuationData', 'clickTrackingParams');
 
//alert([cont, track,123])
//alert(JSON.stringify(data,null,'\t'))
 
//data = data.contents[0].itemSectionRenderer.contents;
data = data.contents || data;
 
for (var i=data.length; i>=0; i--) {
var tmp = getField(data[i], 'itemSectionRenderer','contents', 0, 'movieRenderer', 'offerButton');
if (tmp) data.splice(i,1);
}
 
 
//for (var i=data.length; i>=0; i--) {
//var tmp = getField(data[i], 'itemSectionRenderer','contents');
//if (tmp && tmp[0] && (tmp[0].carouselAdRenderer || tmp[0].promotedSparklesTextSearchRenderer)) data.splice(i,1);
//}
 
//data = data[0].itemSectionRenderer.contents;
 
/*
if (data[0] && data[0].gridRenderer) {
data = data[0].gridRenderer || data[0].shelfRenderer.content.expandedShelfContentsRenderer;
cont = getField(data, 'continuations', 0, 'nextContinuationData', 'continuation');
track = getField(data, 'continuations', 0, 'nextContinuationData', 'clickTrackingParams');
//var track = data.trackingParams;
data = data.items;
}/**/
 
var title = getField(ytInitialData,'header','c4TabbedHeaderRenderer','title')
|| lsearch.search_query
|| '';
document.head.innerHTML = '<title>'+title+'</title>';
 
var html = [
'<style>body {margin:10px; font-family:'+(conf.fontFamily||'Arial')+'; font-size: '+(conf.fontSize||'16px')+'}'
+'.ib {display:inline-block} .vt {width:246px; height: 200px; margin:10px; vertical-align: top}'
+'.vtb {overflow-wrap:break-word}'
//+'#search-container {height: auto !important}'
+'</style>'
+ searchform+''
,'<br><h1>'+title+'</h1>'
,'<div id=vdiv><ul id=vul>'
];
 
 
function makeLinks(data){
//alert(JSON.stringify(data,null,'\t'))
var html = [];
for (var i=0; i<data.length; i++){
var v = getField(data[i], 'richItemRenderer', 'content')
|| data[i];
var v = v.gridVideoRenderer || v.videoRenderer || v.playlistVideoRenderer;
if (v) {
//var t = v.thumbnail.thumbnails[0];
var t={width:0};
v.thumbnail.thumbnails.forEach(function(i){
if (t.width==0 || (i.width<=246 && t.width<i.width)) t = i;
});
var title = v.title.simpleText||v.title.runs[0].text;
html.push('<span class="ib vt"><a href="/watch?v='+v.videoId+'" class="vtb"><img src="'+t.url
+'" width='+(Math.min(246, t.width))+'><br>'
+ (getField(v,'thumbnailOverlays',0,'thumbnailOverlayTimeStatusRenderer','text','simpleText') || "--")
+' '+title+'</a></span>');
}
}
return html.join('');
}
 
//alert(JSON.stringify(data,null,'\t'))
getNextCrap(data);
//data = data[0].itemSectionRenderer.contents;
data = getField(data, 0, 'itemSectionRenderer','contents')
|| getField(data, 0, 'itemSectionRenderer','contents')
|| getField(data, 'tabRenderer','content','sectionListRenderer','contents',0,'itemSectionRenderer','contents',0,'gridRenderer');
//alert(JSON.stringify(data,null,'\t'))
data = data.items || data;
getNextCrap(data);
 
html.push(makeLinks(data));
 
function delMore(){
var tmp = document.querySelector('#more');
if (tmp) {tmp.parentNode.removeChild(tmp);}
}
 
function makeMore(cont1,track1){
//window.__more_href='/browse_ajax?ctoken='+cont1+'&continuation='+cont1+'&itct='+track1
window.__more_post='{"context":{"client":{"clientName":"'+cname+'","clientVersion":"'+cver+'",}},"continuation":"'+cont1+'"}';
return '<button id="more" onclick="loadNextPage()" targetId="vul">load more</button>';
}
 
function makeMoreBrowse(cont1,track1){
cname = '1';
window.__more_href='/browse_ajax?ctoken='+cont1+'&continuation='+cont1+'&itct='+track1
return '<button id="more" onclick="loadNextPage()" moreHref="/browse_ajax?ctoken='+cont1+'&continuation='+cont1+'&itct='+track1+'" targetId="vul">load more</button>';
}
 
//alert(JSON.stringify(data,null,'\t'))
if (browseCont) {
//html.push('<hr><button moreHref="/browse_ajax?action_continuation=1&direct_render=0&continuation='+cont+'&ctoken='+cont+'&itct='+track+'" targetId="vul">load more</button>');
html.push('<hr>'+makeMoreBrowse(browseCont, browseTrack));
} else if (cont) {
html.push('<hr>'+makeMore(cont, track));
} else if (lpath[1]=='results') {
if (ytInitialData.estimatedResults==0) {
html.push('<h2>no results</h2>');
} else {
//window.__more_crap = ytInitialData.contents.twoColumnSearchResultsRenderer.primaryContents.sectionListRenderer.contents[1].continuationItemRenderer.continuationEndpoint.continuationCommand.token;
//window.__more_crap = getField(data, data.length-1,'continuationItemRenderer','continuationEndpoint','continuationCommand','token');
 
}
}
 
if (window.__more_crap) {
html.push('<br><hr><br><button id=more onclick="nextSearch()">search more</button>');
}
 
html.push('</ul></div>');
 
document.body.innerHTML = html.join('');
ff();
}
}
 
/*
-html > body > ytd-app > ytd-masthead#masthead.shell.chunked > div#masthead-skeleton-icons > div.masthead-skeleton-icon
html > body > div#watch-page-skeleton.watch-skeleton. > div#container > div#info-container > pre
*/
 
if (lpath[1]=='playlist' && window["ytInitialData"]) {
//alert(JSON.stringify(window["ytInitialData"],null,'\t'));
 
var err = getField(window["ytInitialData"], 'alerts', 0, 'alertRenderer');
if (err && err.type=='ERROR') {
document.body.innerHTML = '<h1>'+err.text.runs[0].text+'</h1>';
} else {
 var title = ytInitialData.metadata.playlistMetadataRenderer.title;
 var desc = ytInitialData.metadata.playlistMetadataRenderer.description;
 
var tmp = ytInitialData.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].itemSectionRenderer.contents[0].playlistVideoListRenderer.contents;
window.__more_crap = getField(tmp, tmp.length-1,'continuationItemRenderer','continuationEndpoint','continuationCommand','token');
 
document.head.innerHTML = '<title>'+title+'</title>';
 
var html = [
'<style>body {margin:10px; font-family:'+(conf.fontFamily||'Arial')+'; font-size: '+(conf.fontSize||'16px')+'}'
+'.ib {display:inline-block} .vt {width:246px; height: 200px; margin:10px; vertical-align: top}'
+'</style>'
+ searchform+''
,'<h1>'+title+'</h1>'
,'<br><br><pre style="white-space:pre-wrap">',desc,'</pre><br><br>'
,'<div id=vdiv><ul id=vul>'
];
//alert(JSON.stringify(tmp,null,'\t'))
 
html.push(makeLinks(tmp));
 
if (window.__more_crap) {
 window.__more_crap_url = '/youtubei/v1/browse';
html.push('<br><hr><br><button id=more onclick="nextSearch()">browse more</button>');
}
html.push('</ul></div>');
 
document.body.innerHTML = html.join('');
ff();
//alert(html);
}
 
} // playlist
 
 
 
if (lpath[1]=='watch') {
tmp = document.querySelector('#search-container');
if (tmp) tmp.innerHTML = searchform;
if (window["ytInitialData"] && window["ytInitialPlayerResponse"]) {
tmp = document.querySelector('#info-container');
var mf = getField(ytInitialPlayerResponse, 'microformat', 'playerMicroformatRenderer');
if (tmp && mf) tmp.innerHTML = '<a href="'+mf.ownerProfileUrl+'/videos">'+mf.ownerChannelName+'</a> '+mf.publishDate+'<br>'+s2hms(mf.lengthSeconds)
+'<h3>'+mf.title.simpleText+'</h3><br><pre style="white-space:pre-wrap">'
+(getField(mf, 'description', 'simpleText') || '').replace(/(https?:\/\/\S+)/gi,'<a href="$1">$1</a>')
+'</pre>';
};
tmp = document.querySelector('#related');
var related = getField(window, 'ytInitialData', "contents", "twoColumnWatchNextResults", "secondaryResults", "secondaryResults", "results");
document.body.appendChild(create('style','','#player.skeleton.flexy #player-api {margin:0}'
+'#info-container {font-size: 16px}'
+'.rv {font-size: 14px; margin: 8px}'
+'#watch-page-skeleton #related {max-width:200px; margin-top:10px;}'
));
if (tmp && related) {
var html = ['<hr><hr><div id=related2>'];
//alert(JSON.stringify(related,null,'\t'));
        function getRelated(related) {
for (var i=0; i<related.length; i++){
var r = related[i].compactVideoRenderer
|| related[i].compactRadioRenderer
|| related[i].compactPlaylistRenderer
;
if (!r) continue;
var t = r.thumbnail.thumbnails[0];
var v = '/watch?v='+r.videoId;
var pt = getField(r,'publishedTimeText','simpleText')||'';
var lt = getField(r,'lengthText','simpleText')||'';
var auth = getField(r, 'shortBylineText', 'runs', 0, 'text');
var channelUrl = r.channelId ? '/channel/'+r.channelId+'/videos'
: getField(r, 'shortBylineText', 'runs', 0, 'navigationEndpoint','browseEndpoint','canonicalBaseUrl');
if (r.playlistId) {
auth = 'playlist';
v = channelUrl = '/playlist?list='+r.playlistId;
}
//html.push('<span class="ib vt rv"><a href="'+v+'"><img src="'+t.url+'" width='+t.width+'px height='+t.height+'px></a><br><a href="'+channelUrl
//+'">'+auth+'</a> '+pt+'<br>'+lt
//+' <a href="'+v+'">'+r.title.simpleText+'</a></span>');
html.push('<table class="ib vt rv"><tr><td rowspan=4><a href="'+v+'"><img src="'+t.url+'" width='+t.width+'px height='+t.height+'px></a></td>'
,'<td><a href="',v,'">', r.title.simpleText,'</a></td></tr>'
,'<tr><td>',lt,'</td></tr>'
,'<tr><td>',pt,'</td></tr>'
,'<tr><td><a href="',channelUrl,'">'+auth+'</a></td></tr></table>');
}
}
var ra = getField(related, 0, 'compactAutoplayRenderer', 'contents');
if (ra) getRelated(ra);
getRelated(related);
html.push('</div>');
document.querySelector('#watch-page-skeleton').innerHTML += html.join('');
tmp.style.display='block';
}
}
 
 
var tmp = document.querySelectorAll('a[href*="youtube.com/edit?"]');
for (var i=0,a; a=tmp[i]; i++) {
var id = a.href.match(/[?&]video_id=([\da-z_-]{11})/i);
if (id) a.href = 'https://www.youtube.com/watch?v='+id[1];
}
 
tmp = document.querySelector('#watch8-secondary-actions');
var id = location.search.match(/[?&]v=([\da-z_-]{11})/i); id = id&&id[1];
if (tmp && id) {
tmp.innerHTML = '<input readonly size=65 value=\'<iframe width="640" height="360" src="https://www.youtube.com/embed/'+id+'?autoplay=0"></iframe>\'>';
}
 
 
if (conf.fixObjects) {
 
function fixObjects(embeds) {
for (var i=0,e,o; e=embeds[i]; i++){
o=e.parentNode.tagName.toLowerCase()=='object'? e.parentNode : e;
var vid = o.outerHTML.match(/youtube(?:education|-nocookie|)\.com\/v\/([\da-z_-]{11})/i);
if (vid=vid&&vid[1]) {
var iframe = document.createElement('iframe');
var width = o.width || o.style.width || '640px';
var height = o.height || o.style.height || '480px';
if (!/[a-zA-Z%]+$/.test(width)) width +='px';
if (!/[a-zA-Z%]+$/.test(height)) height +='px';
//iframe.style = "width: "+width+" !important ; height: "+height + ' !important';
iframe.style = "width: "+width+"; height: "+height;
if (o.className) iframe.className = o.className;
if (o.id) iframe.id = o.id;
iframe.src = 'https://www.youtube.com/embed/'+vid; // youtube-nocookie.com not always works
o.parentNode.insertBefore(iframe, o);
o.parentNode.removeChild(o);
log('replaced object in html: '+vid);
}
}
}
fixObjects(document.querySelectorAll('object'));
fixObjects(document.querySelectorAll('embed'));
 
var fixInsertedObjectsEnabled = (conf.fixInsertedObjects && conf.fixInsertedObjects.enabled) && !isYoutube
&& (window != window.top ? document.body.innerHTML.length>0 : true) // scriptweeder iframe
&& (!conf.fixInsertedObjects.whitelist || (!conf.fixInsertedObjects.whitelist.length || findHost(conf.fixInsertedObjects.whitelist, location.hostname)!=-1) )
&& (!conf.fixInsertedObjects.blacklist || (!conf.fixInsertedObjects.blacklist.length || findHost(conf.fixInsertedObjects.blacklist, location.hostname)==-1) );
if (fixInsertedObjectsEnabled) {
log('warning: fixInsertedObjects may break sites');
document.addEventListener('DOMNodeInserted', function(e){
if (e.target.innerHTML && /youtube(education|-nocookie|)\.com\/v\//.test(e.target.innerHTML)) {
log('DOMNodeInserted');
var tmp = e.target.outerHTML.replace(/<object[\s\S]*?youtube(?:education|-nocookie|)\.com\/v\/([\da-z_-]{11})[\s\S]*?<\/object>/ig, function(o,id){
var tmp = o.match(/^<object[\s\S]*?>/i)[0];
var width = tmp.match(/width\s*[:=]\s*(\d\w*)/);
width = width&&width[1] || '640px';
var height = tmp.match(/height\s*[:=]\s*(\d\w*)/);
height = height&&height[1] || '480px';
if (!/[a-zA-Z%]+$/.test(width)) width +='px';
if (!/[a-zA-Z%]+$/.test(height)) height +='px';
return '<iframe src="https://www.youtube.com/embed/'+id+'" style="width: '+width+' !important; height: '+height+' !important"></iframe>';
});
if (e.target.outerHTML!= tmp) e.target.outerHTML = tmp;
}
}, false);
}
}
 
if (isYoutube && conf.loadThumbnails) {
var pics = document.querySelectorAll('img[data-thumb]');
for (var i=0; i<pics.length; i++) pics[i].src = pics[i].getAttribute('data-thumb');
}
 
 
if (conf.loadComments && conf.blockYoutubeScripts && isYoutube && location.pathname=='/watch' && window==window.top) {
var tmp = document.querySelector('#watch-discussion');
if (!tmp) {
log('no #watch-discussion');
} else {
tmp.style.display='none';
var comments = create('div', 'crutch-comments-container');
comments.appendChild(create('div', 'crutch-comments-total', 'comments disabled ?'))
tmp.parentNode.insertBefore(comments, tmp);
var headers = [['Content-Type', 'application/x-www-form-urlencoded'],['X-YouTube-Identity-Token'," "]];
var c = xhr('/watch_fragments2_ajax?v='+videoId+'&tr=scroll&distiller=1&ctoken='+window.yt.config_.COMMENTS_TOKEN+'&frags=comments&spf=load', 'POST'
, 'session_token='+encodeURIComponent(window.yt.config_.XSRF_TOKEN)+'&client_url='+location, false, headers);
if (c.indexOf('{')!=-1) {
c = JSON.parse(c);
//alert(JSON.stringify(c,null,'\t'));
//alert(c.content_html);
comments.innerHTML = c.content_html;
log('comments');
}
}
}
 
if (conf.blockYoutubeScripts && isYoutube && location.pathname=='/watch' && window==window.top) {
var s = document.createElement('style');
s.appendChild(document.createTextNode('#watch-description + .yt-uix-expander-collapsed-body {display:none !important} .yt-uix-expander-collapsed #watch-description-text {max-height: 100% !important}'));
document.body.appendChild(s);
}
 
var id = getField(window,'yt','config_','VIDEO_ID');
if (conf.addLinksInEmbeds && !location.pathname.indexOf('/embed/') && id) {
var pics = id && getField(window.yt.config_,'PLAYER_CONFIG','args') || {};
var img = pics.iurlmaxres || pics.iurlhq720 || pics.iurlsd || pics.iurl || 'https://i.ytimg.com/vi/'+id+'/hqdefault.jpg';
var span = document.createElement('span');
span.innerHTML = '&nbsp;<a href="https://www.youtube.com/watch?v='+id+'" target="_blank">link</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="'+img+'" target="_blank">img</a>';
span.style='position:absolute; top:0; left:0; background:white';
document.body.appendChild(span);
}
 
function randomString(len,alpha){
var s = '';
var s2;
while (s.length<len) {
s2=Math.random().toString(36).substr(2);
if (alpha) s2=s2.replace(/[^a-z]/g,'');
s+=s2;
}
return s.substr(0,len);
}
function randomNumber(n1,n2){
var r = Math.random()
if (!n1) return r;
if (!n2) return r*n1|0;
return (r*(n2-n1)+n1)|0;
}
function randomName(n1,n2){
var s = randomString(randomNumber(n1,n2),true);
return s[0].toUpperCase()+s.substr(1);
}
 
var tz = randomNumber(2,12)+'00';
var sh=randomNumber(1024,2048), sw=randomNumber(1024,4096);
var bih = (sh*0.6+randomNumber(sh*0.1))|0, biw = (sw*0.9+randomNumber(sw*0.05))|0;
var brdim = randomNumber(13);
brdim = [0-brdim,0-brdim,0-brdim,0-brdim,sw,sw+brdim*2,sh+brdim*2,sw-randomNumber(2,13),bih].join('%2C');
 
var date = new Date();
var ymd = date.getFullYear()+padZero(date.getMonth()+1,2)+padZero(date.getDate(),2);
//alert(ymd);
 
//X-YouTube-Client-Version: 2.20201103.05.00
//X-YouTube-Page-Label: youtube.ytfe.desktop_20201102_5_RC0
 
var headersCont = [
['X-YouTube-Client-Name', cname ||'1']
,['X-YouTube-Client-Version', cver ||('2.'+ymd+'.00.00')]
,['X-YouTube-Device','cbr=Firefox&cbrver=78.0&ceng=Gecko&cengver=78.0&cos=Windows&cosver=6.1&cplatform=DESKTOP']
,['X-YouTube-Page-CL', randomNumber(326505813,340336202)]
,['X-YouTube-Page-Label','youtube.desktop.web_'+ymd+'_0_RC0']
,['X-YouTube-Variants-Checksum','49a40afdb89281a8ab56a2aa5b0cab6d']
,['X-YouTube-Utc-Offset',tz]
,['X-YouTube-Time-Zone',randomName(4,14)+'/'+randomName(4,20)]
,['X-YouTube-Ad-Signals','dt='+Date.now()+'&flash='+randomNumber(2)+'&frm='+randomNumber(2)+'&u_tz='+tz+'&u_his='+randomNumber(4)+'&u_java&u_h='+sh+'&u_w='+sw+'&u_ah='+sh+'&u_aw='+sw+'&u_cd='+randomNumber(25)+'&u_nplug='+randomNumber(2)+'&u_nmime='+randomNumber(3)+'&bc='+randomNumber(30)+'&bih='+bih+'&biw='+biw+'&brdim='+brdim+'&vis='+randomNumber(2)+'&wgl=true&ca_type=image']
,['X-SPF-Referer',''+location]
,['X-SPF-Previous',''+location]
];
 
 
nextSearch = function() {
var shit = {"context":{"client": {"clientName": "WEB","clientVersion": "2."+ymd+".00.00"}}, "continuation": window.__more_crap};
var url = window.__more_crap_url || '/youtubei/v1/search';
url = url + "?key="+conf.ytkey;
var tmp = xhr(url, 'POST', JSON.stringify(shit), false);
tmp = JSON.parse(tmp);
//tmp = tmp.onResponseReceivedCommands[0].appendContinuationItemsAction.continuationItems;
tmp = getField(tmp, 'onResponseReceivedCommands',0,'appendContinuationItemsAction','continuationItems')
|| getField(tmp, 'onResponseReceivedActions',0,'appendContinuationItemsAction','continuationItems')
;
window.__more_crap = getField(tmp,1,'continuationItemRenderer','continuationEndpoint','continuationCommand','token');
//alert(JSON.stringify(tmp,null,'\t'));
tmp = getField(tmp,0, 'itemSectionRenderer', 'contents') || tmp;
var more = document.querySelector('#more');
more.parentNode.removeChild(more);
//alert(JSON.stringify(tmp,null,'\t'));
getNextCrap(tmp);
document.querySelector('#vul').innerHTML+= makeLinks(tmp)+(window.__more_crap?'<br><hr><br><button id=more onclick="nextSearch()">load more</button>':'');
}
 
// load more videos
if (conf.blockYoutubeScripts && isYoutube) {
var more = document.querySelector('button#more');
if (more) {
loadNextPage = function(){
delMore();
//var next = more.getAttribute('moreHref');// old link all the time!
var next = window.__more_href;
//alert(next);
//var targetid = this.getAttribute('targetId');
if (next) {
//xhr(url, 'POST', post, false, headers);
 
var tmp = xhr(next, 'GET', false, false, headersCont);
//alert(tmp);
tmp = JSON.parse(tmp);
//alert(JSON.stringify(tmp,null,'\t'));
tmp = tmp[1].response.continuationContents.gridContinuation;
 
var cont = getField(tmp,'continuations',0,'nextContinuationData');//"nextContinuationData": {"continuation": "4q","clickTrackingParams": "CA" }
 
var html = '<hr>'+makeLinks(tmp.items);
 
if (cont && cont.continuation) {
html += '<hr>'+makeMore(cont.continuation, cont.clickTrackingParams);
}
document.querySelector('#vul').innerHTML+= html;
//var more = document.querySelector('#more');
}
}
}
}
 
// first video in channel
var upsell = document.querySelector('#upsell-video');
if (upsell) {
id = upsell.getAttribute('data-video-id');
if (id) upsell.innerHTML = '<a href="/watch?v='+id+'"><img src="https://i.ytimg.com/vi/'+id+'/mqdefault.jpg"></a>';
}
 
},false);
 
})(opera)
 


: 2144 | . 09-09-2006 | : 14:23 04-01-2020 | : Alex_Qwerty, 14:53 08-10-2021
     


Ru.Board » » » Opera Presto ( 27)


Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.Board
© Ru.Board 2000-2020

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

.ru