Advertisement
Guest User

WasHoertLagfrei.user.js

a guest
Aug 29th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name           Was Hรถrt Ihr Gerade Lagfrei
  3. // @namespace      spongeforum
  4. // @include        http://spongeforum.de/spieleforum/38-*
  5. // @include        http://spongeforum.de/*form=PostAdd*&threadID=38*
  6. // @grant          GM_xmlhttpRequest
  7. // ==/UserScript==
  8.  
  9. function loadTitle(e, videoId)
  10. {
  11.     requestURL = "http://gdata.youtube.com/feeds/api/videos/" + videoId;
  12.     //if (text == null)
  13.     GM_xmlhttpRequest({
  14.         method: "GET",
  15.         url: requestURL,
  16.         onload: function(content) {
  17.             var t = content.responseText;
  18.             var title = t.match(/<title.*?>(.*?)<\/title>/);
  19.             e.innerHTML = title != null ? title[1] : 'Zu wenig Mehl';
  20.         }
  21.     });
  22. }
  23.  
  24. document.addEventListener('DOMContentLoaded',function(e){
  25.     var videos = document.querySelectorAll('iframe.youtube-player');
  26.     for (var i = 0; i < videos.length; ++i) {
  27.         var index = videos[i].id;
  28.         var url = videos[i].src;
  29.         var videoId = url.substring(url.lastIndexOf('/')+1, url.indexOf('?'));
  30.         var n = videos[i].parentNode;
  31.         n.id = 'yt_' + videoId;
  32.         n.style.display = 'none';
  33.         var title = n.parentNode.firstChild.nextSibling; //.container-3
  34.         title = title.firstChild.nextSibling.nextSibling.nextSibling; //.container-content
  35.         title = title.firstChild.nextSibling.nextSibling.nextSibling.firstChild; //a
  36.         title.video = n;
  37.         title.onclick = function(e) {
  38.             var v = e.target.video;
  39.             if (v == null)
  40.                 return true;
  41.             v.style.display = v.style.display == 'none' ? 'block' : 'none';
  42.             return false;
  43.         };
  44.         loadTitle(title, videoId);
  45.     }
  46. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement