1. // ==UserScript==
  2. // @name Fast Youtube embedded player
  3. // @description Fast HTML5 direct playback at 720p is used when selected and available. The script also hugely improves load speed of pages with lots of embedded Youtube videos by instantly showing clickable and immediately accessible placeholders, then the thumbnails are loaded in background.
  4. // @version 1.5.5
  5. // @include *
  6. // @exclude https://www.youtube.com/*
  7. // @author wOxxOm
  8. // @namespace wOxxOm.scripts
  9. // @license MIT License
  10. // @grant GM_getValue
  11. // @grant GM_setValue
  12. // @grant GM_addStyle
  13. // @grant GM_xmlhttpRequest
  14. // @connect www.youtube.com
  15. // @connect youtube.com
  16. // @run-at document-start
  17. // ==/UserScript==
  18.  
  19. /* jshint lastsemic:true, multistr:true, laxbreak:true, -W030, -W041, -W084 */
  20.  
  21. var resizeToFit = GM_getValue('resize', true);
  22. var playHTML5 = GM_getValue('playHTML5', false);
  23. var skipCustom = GM_getValue('skipCustom', false);
  24.  
  25. var $ = function(selORnode, sel) { return sel ? selORnode.querySelector(sel) : document.querySelector(selORnode) };
  26. var $$ = function(selORnode, sel) { return sel ? selORnode.querySelectorAll(sel) : document.querySelectorAll(selORnode) };
  27.  
  28. var embedSelector;
  29. initEmbedSelector();
  30.  
  31. processEmbeds($$(embedSelector));
  32.  
  33. document.addEventListener('DOMContentLoaded', function(e) {
  34. adjustNodesIfNeeded(e);
  35. injectStylesIfNeeded();
  36. });
  37.  
  38. window.addEventListener('resize', adjustNodesIfNeeded);
  39.  
  40. var mutQueue = [];
  41. new MutationObserver(function(mutations) {
  42. if (mutations.length == 1) {
  43. // ricing: skip singular mutations with no ELEMENT_NODE added
  44. // (like removal of nodes or creation of TEXT_NODE)
  45. var added = mutations[0].addedNodes;
  46. if (added.length==0 || added.length==1 && added[0].nodeType!=1)
  47. return;
  48. }
  49. mutQueue.push(mutations);
  50. if (mutations.length < 100)
  51. processQueue();
  52. else
  53. setTimeout(processQueue, 0);
  54. }).observe(document, {subtree:true, childList:true});
  55.  
  56. function processQueue() {
  57. while (mutQueue.length) {
  58. var mutationBatch = mutQueue.shift();
  59. for (var m=0, ml=mutationBatch.length, mutation; (m<ml) && (mutation=mutationBatch[m]); m++) {
  60. for (var n=0, nodes=mutation.addedNodes, nl=nodes.length, node; (n<nl) && (node=nodes[n]); n++) {
  61. if (node.nodeType != 1) // skip non-ELEMENT_NODE
  62. continue;
  63. if (node.localName == 'iframe' || node.localName == 'embed') {
  64. if (node.matches(embedSelector))
  65. processEmbeds([node]);
  66. }
  67. else if (node.children.length) {
  68. var embeds = $$(node, embedSelector);
  69. if (embeds.length)
  70. processEmbeds(embeds);
  71. }
  72. }
  73. }
  74. }
  75. }
  76.  
  77. function processEmbeds(nodes) {
  78. for (var i=0, nl=nodes.length, n; i<nl && (n=nodes[i]); i++) {
  79. var np = n.parentNode, npw;
  80. if (!np ||
  81. np.localName == 'object' && !np.parentNode ||
  82. n.className.indexOf('instant-youtube-') >= 0 ||
  83. n.src.indexOf('autoplay=1') > 0 ||
  84. n.onload && getComputedStyle(np).display == 'none' // skip some retarded loaders
  85. )
  86. continue;
  87.  
  88. var id = n.src.match(/(?:embed\/|v[=\/])([^\s,.()\[\]?]+?)(?:[&?\/].*|$)/);
  89. if (!id)
  90. continue;
  91. id = id[1];
  92.  
  93. // find parent node with nonzero width (i.e. independent of our video element) to be used in fit-to-width mode
  94. while (np && !(npw=np.clientWidth))
  95. np = np.parentNode;
  96.  
  97. var containerWidth = resizeToFit ? npw : n.clientWidth;
  98. var containerHeight = resizeToFit ? npw / 16 * 9 : n.clientHeight;
  99.  
  100. var div = document.createElement('div');
  101. div.className = 'instant-youtube-container';
  102. div.srcEmbed = n.src.replace(/&$/, '');
  103. div.style.maxWidth = containerWidth + 'px';
  104. div.style.height = containerHeight + 'px';
  105. div.originalWidth = n.width;
  106. div.originalHeight = n.height;
  107. div.videoID = id;
  108.  
  109. var wrapper = div.appendChild(document.createElement('div'));
  110. wrapper.className = 'instant-youtube-wrapper';
  111.  
  112. var img = wrapper.appendChild(document.createElement('img'));
  113. img.className = 'instant-youtube-thumbnail';
  114. img.src = 'https://i.ytimg.com/vi/' + id + '/maxresdefault.jpg';
  115. img.style.cssText = 'max-width:100%; margin:0 0 0 0;';
  116. img.title = 'Shift-click to use alternative player';
  117. img.onload = function(e) {
  118. var img = e.target;
  119. if (img.naturalWidth <= 120)
  120. return img.onerror(e);
  121. var fitToWidth = true;
  122. if (img.naturalHeight) {
  123. var ratio = img.naturalWidth / img.naturalHeight;
  124. if (ratio > 4.1/3 && ratio < 16/9.1) {
  125. img.style.cssText += 'width:auto!important; height:100%!important';
  126. fitToWidth = false;
  127. }
  128. }
  129. if (fitToWidth) {
  130. img.style.cssText += 'width:100%!important; height:auto!important';
  131. img.style.marginTop = ((img.parentNode.clientHeight - img.clientHeight) / 2).toFixed(1) + 'px';
  132. }
  133. if (img.videoWidth)
  134. fixThumbnailAR(div);
  135. img.style.setProperty('opacity', '1');
  136. };
  137. img.onerror = function(e) {
  138. var img = e.target;
  139. if (img.src.indexOf('maxresdefault') > 0)
  140. img.src = img.src.replace('maxresdefault','hqdefault');
  141. };
  142.  
  143. GM_xmlhttpRequest({
  144. method: 'GET',
  145. url: div.srcEmbed.replace(/\/(embed\/|v[=\/])/, '/watch?v='),
  146. context: div,
  147. onload: parseWatchPage
  148. });
  149.  
  150. wrapper.insertAdjacentHTML('beforeend', '\
  151. <svg class="instant-youtube-play-button"><path fill-rule="evenodd" clip-rule="evenodd" fill="#1F1F1F" class="ytp-large-play-button-svg" d="M84.15,26.4v6.35c0,2.833-0.15,5.967-0.45,9.4c-0.133,1.7-0.267,3.117-0.4,4.25l-0.15,0.95c-0.167,0.767-0.367,1.517-0.6,2.25c-0.667,2.367-1.533,4.083-2.6,5.15c-1.367,1.4-2.967,2.383-4.8,2.95c-0.633,0.2-1.316,0.333-2.05,0.4c-0.767,0.1-1.3,0.167-1.6,0.2c-4.9,0.367-11.283,0.617-19.15,0.75c-2.434,0.034-4.883,0.067-7.35,0.1h-2.95C38.417,59.117,34.5,59.067,30.3,59c-8.433-0.167-14.05-0.383-16.85-0.65c-0.067-0.033-0.667-0.117-1.8-0.25c-0.9-0.133-1.683-0.283-2.35-0.45c-2.066-0.533-3.783-1.5-5.15-2.9c-1.033-1.067-1.9-2.783-2.6-5.15C1.317,48.867,1.133,48.117,1,47.35L0.8,46.4c-0.133-1.133-0.267-2.55-0.4-4.25C0.133,38.717,0,35.583,0,32.75V26.4c0-2.833,0.133-5.95,0.4-9.35l0.4-4.25c0.167-0.966,0.417-2.05,0.75-3.25c0.7-2.333,1.567-4.033,2.6-5.1c1.367-1.434,2.967-2.434,4.8-3c0.633-0.167,1.333-0.3,2.1-0.4c0.4-0.066,0.917-0.133,1.55-0.2c4.9-0.333,11.283-0.567,19.15-0.7C35.65,0.05,39.083,0,42.05,0L45,0.05c2.467,0,4.933,0.034,7.4,0.1c7.833,0.133,14.2,0.367,19.1,0.7c0.3,0.033,0.833,0.1,1.6,0.2c0.733,0.1,1.417,0.233,2.05,0.4c1.833,0.566,3.434,1.566,4.8,3c1.066,1.066,1.933,2.767,2.6,5.1c0.367,1.2,0.617,2.284,0.75,3.25l0.4,4.25C84,20.45,84.15,23.567,84.15,26.4z M33.3,41.4L56,29.6L33.3,17.75V41.4z"></path><polygon fill-rule="evenodd" clip-rule="evenodd" fill="#FFFFFF" points="33.3,41.4 33.3,17.75 56,29.6"></polygon></svg>\
  152. <span class="instant-youtube-link">' + (playHTML5 ? 'Play with Youtube player' : 'Play directly (up to 720p)') + '</span>\
  153. <div class="instant-youtube-options">\
  154. <label>Resize to fit <input data-action="resize" type="checkbox"' + (resizeToFit ? ' checked' : '') + '></label>\
  155. <label title="Tip: shift-clicking thumbnails will use alternative player">\
  156. Play directly <input data-action="direct" type="checkbox"' + (playHTML5 ? ' checked' : '') + '></label>\
  157. <label title="Do not process customized videos with enablejsapi=1 parameter (requires page reload)">Safe <input data-action="safe" type="checkbox"' + (skipCustom ? ' checked' : '') + '></label>\
  158. </div>\
  159. ');
  160.  
  161. if (n.parentNode.localName == 'object')
  162. n = n.parentNode;
  163. n.parentNode.insertBefore(div, n);
  164. n.remove();
  165.  
  166. div.addEventListener('click', clickHandler);
  167. }
  168.  
  169. injectStylesIfNeeded();
  170. return true;
  171. }
  172.  
  173. function adjustNodesIfNeeded(e) {
  174. if (resizeToFit && !adjustNodesIfNeeded.scheduled)
  175. adjustNodesIfNeeded.scheduled = setTimeout(function() {
  176. adjustNodes(e);
  177. adjustNodesIfNeeded.scheduled = 0;
  178. }, 16);
  179. }
  180.  
  181. function adjustNodes(e, clickedContainer) {
  182. var force = !!clickedContainer;
  183. var nearest = force ? clickedContainer : null;
  184.  
  185. var vids = [].slice.call($$('div.instant-youtube-container'));
  186.  
  187. if (!nearest && e.type != 'DOMContentLoaded') {
  188. var minDistance = window.innerHeight*3/4 |0;
  189. var nearTargetY = window.innerHeight/2;
  190. vids.forEach(function(n) {
  191. var bounds = n.getBoundingClientRect();
  192. var distance = Math.abs((bounds.bottom + bounds.top)/2 - nearTargetY);
  193. if (distance < minDistance) {
  194. minDistance = distance;
  195. nearest = n;
  196. }
  197. });
  198. }
  199.  
  200. if (nearest) {
  201. var bounds = nearest.getBoundingClientRect();
  202. var nearestCenterYpct = (bounds.top + bounds.bottom)/2 / window.innerHeight;
  203. }
  204.  
  205. var resized = false;
  206.  
  207. vids.forEach(function(n) {
  208. var w, h;
  209.  
  210. if (resizeToFit) {
  211. for (var p=n.parentElement; p && !(w=p.clientWidth); p=p.parentElement) {}
  212. h = w / 16 * 9;
  213. } else {
  214. w = n.originalWidth;
  215. h = n.originalHeight;
  216. }
  217.  
  218. if (force && Math.abs(w - parseFloat(n.style.maxWidth)) <= 2)
  219. return;
  220.  
  221. if (n.style.maxWidth != w + 'px') n.style.maxWidth = w + 'px';
  222. if (n.style.height != h + 'px') n.style.height = h + 'px';
  223.  
  224. var img = $(n, 'img');
  225. if (img.style.marginTop != '0px')
  226. img.style.marginTop = ((h - img.clientHeight) / 2).toFixed(1) + 'px';
  227.  
  228. var video = $(n, 'video');
  229. if (video) {
  230. video.width = w;
  231. video.height = h;
  232. }
  233.  
  234. resized = true;
  235. });
  236.  
  237. if (resized && nearest)
  238. setTimeout(function() {
  239. var bounds = nearest.getBoundingClientRect();
  240. var h = bounds.bottom - bounds.top;
  241. var projectedCenterY = nearestCenterYpct * window.innerHeight;
  242. var projectedTop = projectedCenterY - h/2;
  243. var safeTop = Math.min(Math.max(0, projectedTop), window.innerHeight - h);
  244. window.scrollBy(0, bounds.top - safeTop);
  245. }, 16);
  246. }
  247.  
  248. function parseWatchPage(response) {
  249. var div = response.context;
  250. var txt = response.responseText;
  251.  
  252. // parse width & height to adjust the thumbnail
  253. var w = txt.match(/<meta property="og:video:width" content="(\d+)">/);
  254. var h = txt.match(/<meta property="og:video:height" content="(\d+)">/);
  255. if (w && h)
  256. fixThumbnailAR(div, w[1]|0, h[1]|0);
  257.  
  258. // parse video sources
  259. var m = txt.match(/ytplayer\.config\s*=\s*(\{.+?\});\s*ytplayer\.load/);
  260. var videoInfo = [];
  261. if (m) {
  262. var cfg = JSON.parse(m[1]), streams = {};
  263. cfg.args.url_encoded_fmt_stream_map.split(',').forEach(function(stream) {
  264. var params = {};
  265. stream.split('&').forEach(function(kv) {
  266. params[kv.split('=')[0]] = decodeURIComponent(kv.split('=')[1]);
  267. });
  268. streams[params.itag] = params;
  269. });
  270. cfg.args.fmt_list.split(',').forEach(function(fmt) {
  271. var itag = fmt.split('/')[0];
  272. var dimensions = fmt.split('/')[1];
  273. var stream = streams[itag];
  274. if (stream) {
  275. videoInfo.push({
  276. src: stream.url,
  277. title: stream.quality + ', ' + dimensions + ', ' + stream.type
  278. });
  279. }
  280. });
  281. } else {
  282. var rx = /url=([^=]+?mime%3Dvideo%252F(?:mp4|webm)[^=]+?)(?:,quality|,itag|.u0026)/g;
  283. var text = txt.split('url_encoded_fmt_stream_map')[1];
  284. while (m = rx.exec(text)) {
  285. videoInfo.push({
  286. src: decodeURIComponent(decodeURIComponent(m[1]))
  287. });
  288. }
  289. }
  290.  
  291. var title = txt.match(/<title>(.+?)(?:\s*-\s*YouTube)?<\/title>/);
  292. if (title) {
  293. var duration = txt.match(/<meta itemprop="duration" content="\D*(\d+.*?)S?">/);
  294. var a = div.firstElementChild.appendChild(document.createElement('a'));
  295. a.className = 'instant-youtube-persistent-title';
  296. a.innerHTML = '<strong>' + title[1] + '</strong>' +
  297. (duration ? '<span>' + duration[1].replace(/[HM]/, ':0').replace(/\b0(\d\d)/, '$1') + '</span>' : '');
  298. a.href = 'https://www.youtube.com/watch?v=' + div.videoID;
  299. a.target = '_blank';
  300. ['animation', 'webkitAnimation', 'mozAnimation'].some(function(prop) {
  301. if (prop in a.style) {
  302. a.style[prop] = 'instant-youtube-fadein 1s ease-in';
  303. setTimeout(function() { a.style[prop] = '' }, 1000);
  304. return true;
  305. }
  306. });
  307. }
  308.  
  309. if (videoInfo.length)
  310. div.videoInfo = videoInfo;
  311.  
  312. injectStylesIfNeeded();
  313. }
  314.  
  315. function fixThumbnailAR(div, w, h) {
  316. var img = $(div, 'img');
  317. var thw = img.naturalWidth, thh = img.naturalHeight;
  318. if (!thw || !thh) {
  319. // thumbnail is still loading
  320. img.videoWidth = w;
  321. img.videoHeight = h;
  322. return;
  323. } else if (!w || !h) {
  324. // invoked from img.onload
  325. w = img.videoWidth;
  326. h = img.videoHeight;
  327. }
  328. var divw = div.clientWidth, divh = div.clientHeight;
  329. // if both video and thumbnail are 4:3, fit the image to height
  330. if (Math.abs(h/w*divw / divh - 1) > 0.05 && Math.abs(thh/thw*divw / divh - 1) > 0.05) {
  331. img.style.cssText = img.style.cssText.replace(/\bheight:.*?;/, 'height:' + img.clientHeight + 'px!important;');
  332. if (!img.videoWidth) // skip animation if thumbnail is already loaded
  333. img.style.transition = 'height 1s ease, margin-top 1s ease';
  334. setTimeout(function() {
  335. img.style.cssText += 'width:auto!important; height:100%!important';
  336. img.style.marginTop = '0';
  337. setTimeout(function() {
  338. img.style.transition = '';
  339. }, 1000);
  340. }, 0);
  341. }
  342. }
  343.  
  344. function clickHandler(e) {
  345. if (e.target.href)
  346. return;
  347. if (e.target.closest('.instant-youtube-options'))
  348. return options(e);
  349. div = e.target.closest('.instant-youtube-container');
  350. div.removeEventListener('click', clickHandler);
  351. $(div, 'svg').outerHTML = '<span class="instant-youtube-loading-button"></span>';
  352.  
  353. var alternateMode = e.shiftKey || e.target.className == 'instant-youtube-link';
  354. if (div.videoInfo && (!!playHTML5 + !!alternateMode == 1))
  355. playDirectly(div);
  356. else
  357. switchToIFrame.call(div);
  358. }
  359.  
  360. function playDirectly(div) {
  361. $(div, '.instant-youtube-options').style.display = 'none';
  362. $(div, '.instant-youtube-link').style.display = 'none';
  363.  
  364. var video = document.createElement('video');
  365. video.controls = true;
  366. video.autoplay = true;
  367. video.style.cssText = 'width:'+div.clientWidth+'px!important; height:'+div.clientHeight+'px!important;';
  368. video.className = 'instant-youtube-embed';
  369. video.volume = GM_getValue('volume', 0.5);
  370.  
  371. div.videoInfo.forEach(function(src) {
  372. var srcdom = video.appendChild(document.createElement('source'));
  373. Object.keys(src).forEach(function(k) { srcdom[k] = src[k] });
  374. srcdom.onerror = switchToIFrame.bind(div);
  375. });
  376.  
  377.  
  378. if (window.chrome) {
  379. video.addEventListener('click', function(e) {
  380. this.paused ? this.play() : this.pause();
  381. });
  382. }
  383. video.interval = (function() {
  384. return setInterval(function() {
  385. if (video.volume != GM_getValue('volume', 0.5))
  386. GM_setValue('volume', video.volume);
  387. }, 1000);
  388. })();
  389. var title = $(div, '.instant-youtube-persistent-title');
  390. if (title) {
  391. video.onpause = function() { title.removeAttribute('hidden') };
  392. video.onplay = function() { title.setAttribute('hidden', true) };
  393. }
  394. video.onloadeddata = function(e) {
  395. pauseOtherVideos(this);
  396. div.firstElementChild.appendChild(this);
  397. this.style.opacity = 1;
  398. var img = $(div, 'img');
  399. img.style.transition = 'opacity 1s';
  400. img.style.opacity = 0;
  401. };
  402. }
  403.  
  404. function switchToIFrame(e) {
  405. var div = this;
  406. var wrapper = div.firstElementChild;
  407. if (e) {
  408. console.log('Direct linking failed on %s, switching to IFRAME player', div.srcEmbed);
  409. var video = e.target ? e.target.closest('video') : e.path && e.path[e.path.length-1];
  410. while (video.lastElementChild)
  411. video.lastElementChild.remove();
  412. }
  413.  
  414. wrapper.insertAdjacentHTML('beforeend',
  415. '<iframe class="instant-youtube-embed" allowtransparency="true" src="' +
  416. div.srcEmbed.replace('http:', 'https:').replace('/v/', '/embed/') +
  417. (div.srcEmbed.indexOf('?') > 0 ? '&' : '?') +
  418. 'html5=1' +
  419. '&autoplay=1' +
  420. '&autohide=2' +
  421. '&border=0' +
  422. '&controls=1' +
  423. '&fs=1' +
  424. '&showinfo=1' +
  425. '&ssl=1' +
  426. '&theme=dark' +
  427. '&enablejsapi=1' +
  428. '" frameborder="0" allowfullscreen width="' + div.clientWidth + '" height="' + div.clientHeight + '"></iframe>');
  429.  
  430. wrapper.lastElementChild.onload = function() {
  431. pauseOtherVideos(this);
  432. this.style.opacity = 1;
  433.  
  434. var div = this.closest('.instant-youtube-container');
  435. div.setAttribute('iframe', '');
  436. setTimeout(function() {
  437. $(div, 'img').style.display = 'none';
  438. var title = $(div, '.instant-youtube-persistent-title');
  439. if (title)
  440. title.remove();
  441. }, 2000);
  442. };
  443. }
  444.  
  445. function pauseOtherVideos(activePlayer) {
  446. [].forEach.call(activePlayer.ownerDocument.getElementsByClassName('instant-youtube-embed'), function(v) {
  447. if (v == activePlayer)
  448. return;
  449. switch (v.localName) {
  450. case 'video':
  451. if (!v.paused)
  452. v.pause();
  453. break;
  454. case 'iframe':
  455. try { v.contentWindow.postMessage('{"event":"command", "func":"pauseVideo", "args":""}', '*') } catch(e) {}
  456. break;
  457. }
  458. });
  459. }
  460.  
  461. function options(e) {
  462. var action = e.target.dataset.action;
  463. var state = e.target.checked;
  464. switch (action) {
  465. case 'resize':
  466. GM_setValue('resize', resizeToFit = state);
  467. adjustNodes(e, e.target.closest('.instant-youtube-container'));
  468. break;
  469. case 'direct':
  470. GM_setValue('playHTML5', playHTML5 = state);
  471. [].forEach.call($$('.instant-youtube-container .instant-youtube-link'), function(e) {
  472. e.textContent = playHTML5 ? 'Play with Youtube player' : 'Play directly (up to 720p)';
  473. });
  474. break;
  475. case 'safe':
  476. GM_setValue('skipCustom', skipCustom = state);
  477. initEmbedSelector();
  478. break;
  479. default:
  480. return;
  481. }
  482. [].forEach.call($$('.instant-youtube-container [data-action="' + action + '"]'), function(e) {
  483. e.checked = state;
  484. });
  485. }
  486.  
  487. function initEmbedSelector() {
  488. embedSelector = 'iframe[src*="youtube.com/embed"]~~~, embed[src*="youtube.com/v"]~~~'
  489. .replace(/~~~/g, skipCustom ? ':not([src*="enablejsapi=1"])' : '');
  490. }
  491.  
  492. function injectStylesIfNeeded() {
  493. if (document.head.innerHTML.indexOf('.instant-youtube-container') > 0)
  494. return;
  495. GM_addStyle('\
  496. .instant-youtube-container {contain:strict; position:relative; overflow:hidden; cursor:pointer; background-color:black; padding:0; margin:0; font:normal 14px/1.0 sans-serif,Arial,Helvetica,Verdana; text-align:center}\
  497. .instant-youtube-container .instant-youtube-wrapper {width:100%; height:100%}\
  498. .instant-youtube-container .instant-youtube-thumbnail {transition:opacity 0.1s ease-out; opacity:0; padding:0; margin:0}\
  499. .instant-youtube-container .instant-youtube-play-button {position:absolute; left:0; right:0; top:0; bottom:0; margin:auto; width:85px; height:60px}\
  500. .instant-youtube-container .instant-youtube-loading-button {position:absolute; left:0; right:0; top:0; bottom:0; padding:0; margin:auto; display:block; width:20px; height:20px; background: url("data:image/gif;base64,R0lGODlhFAAUAJEDAMzMzLOzs39/f////yH/C05FVFNDQVBFMi4wAwEAAAAh+QQFCgADACwAAAAAFAAUAAACPJyPqcuNItyCUJoQBo0ANIxpXOctYHaQpYkiHfM2cUrCNT0nqr4uudsz/IC5na/2Mh4Hu+HR6YBaplRDAQAh+QQFCgADACwEAAIADAAGAAACFpwdcYupC8BwSogR46xWZHl0l8ZYQwEAIfkEBQoAAwAsCAACAAoACgAAAhccMKl2uHxGCCvO+eTNmishcCCYjWEZFgAh+QQFCgADACwMAAQABgAMAAACFxwweaebhl4K4VE6r61DiOd5SfiN5VAAACH5BAUKAAMALAgACAAKAAoAAAIYnD8AeKqcHIwwhGntEWLkO3CcB4biNEIFACH5BAUKAAMALAQADAAMAAYAAAIWnDSpAHa4GHgohCHbGdbipnBdSHphAQAh+QQFCgADACwCAAgACgAKAAACF5w0qXa4fF6KUoVQ75UaA7Bs3yeNYAkWACH5BAUKAAMALAIABAAGAAwAAAIXnCU2iMfaRghqTmMp1moAoHyfIYIkWAAAOw==")}\
  501. .instant-youtube-container:hover .ytp-large-play-button-svg {fill:#CC181E}\
  502. .instant-youtube-container .instant-youtube-link, .instant-youtube-container .instant-youtube-link:link, .instant-youtube-container .instant-youtube-link:visited, .instant-youtube-container .instant-youtube-link:active, .instant-youtube-container .instant-youtube-link:focus {\
  503. position:absolute; top:50%; left:0; right:0; width:20em; height:1.7em; margin:60px auto; padding:0; border:none; \
  504. display:block; text-align:center; text-decoration:none; color:white; text-shadow:1px 1px 3px black; font-weight:bold;\
  505. }\
  506. .instant-youtube-container span.instant-youtube-link {font-weight:normal; font-size:12px}\
  507. .instant-youtube-container .instant-youtube-link:hover {color:white; text-decoration:underline; background:transparent}\
  508. .instant-youtube-container .instant-youtube-embed {position:absolute; left:0; top:0; padding:0; margin:0; height:inherit!important; opacity:0; transition:opacity 2s!important}\
  509. .instant-youtube-container iframe {z-index:10}\
  510. .instant-youtube-container .instant-youtube-persistent-title {\
  511. display:block; z-index:9; background-color:rgba(0,0,0,0.5); color:white;\
  512. width:100%; height: 1.9em; top:0; left:0; right:0; position:absolute; z-index: 9;\
  513. color:white; text-shadow:1px 1px 2px black; text-align:center; text-decoration:none;\
  514. margin:0; padding:0.5em 0.5em 0.2em; border:none;\
  515. }\
  516. .instant-youtube-container .instant-youtube-persistent-title strong:after {content:" - watch on Youtube"; font-weight:normal; margin-right:1ex}\
  517. .instant-youtube-container .instant-youtube-persistent-title span {color:inherit}\
  518. .instant-youtube-container .instant-youtube-persistent-title span:before {content:"("}\
  519. .instant-youtube-container .instant-youtube-persistent-title span:after {content:")"}\
  520. @-webkit-keyframes instant-youtube-fadein { from {opacity:0} to {opacity:1} }\
  521. @-moz-keyframes instant-youtube-fadein { from {opacity:0} to {opacity:1} }\
  522. @keyframes instant-youtube-fadein { from {opacity:0} to {opacity:1} }\
  523. .instant-youtube-container:not(:hover) .instant-youtube-persistent-title[hidden] {display:none; margin:0}\
  524. .instant-youtube-container .instant-youtube-persistent-title:hover {text-decoration:underline}\
  525. .instant-youtube-container .instant-youtube-persistent-title strong {color:white}\
  526. .instant-youtube-container .instant-youtube-options {position:absolute; right:2px; bottom:0; color:white; text-shadow:1px 1px 2px black; padding:0; margin:0; opacity:0.6}\
  527. .instant-youtube-container .instant-youtube-options:hover {opacity:1; background:rgba(0,0,0,0.5); padding-left:1ex;}\
  528. .instant-youtube-container .instant-youtube-options * {display:inline; color:white; font-size:13px; vertical-align:middle; padding:0; margin:0}\
  529. ');
  530. }