Greasy Fork is available in English.

video tabs

tabbed video sources on certain drama and anime sites

Version vom 2020-10-07 03:33:26 UTC. Aktuellste Version

// ==UserScript==
// @name        video tabs
// @namespace   gnblizz
// @description tabbed video sources on certain drama and anime sites
// @version     1.02
// @include     http://www.animehere.com/*
// @include     http://www.animenova.org/*
// @include     http://www.animenova.tv/*
// @include     http://www.animeplus.tv/*
// @include     http://www.animetoon.eu/*
// @include     http://www.animetoon.tv/*
// @include     http://animewow.eu/*
// @include     http://www.animewow.eu/*
// @include     http://dramago.com/*
// @include     http://www.dramago.com/*
// @include     http://www.dramagalaxy.eu/*
// @include     http://www.dramagalaxy.com/*
// @include     http://www.gogoanime.com/*
// @include     http://www.goodanime.co/*
// @include     http://www.goodanime.eu/*
// @include     http://www.goodanime.net/*
// @include     http://www.gooddrama.net/*
// @noframes
// @grant       none
// @icon        data:image/gif;base64,R0lGODlhMAAwAKECAAAAAICAgP///////yH5BAEKAAMALAAAAAAwADAAAALQnI+py+0Po5y02ouz3rz7D4biBJTmiabqyrbuC8fyHAf2jedpzuOvAAwKh6mhUfg7Hks3gHLpehptwIBTioxig0zrdStIgrslMFA8pCKp1oAZjXW6w/Mt/Nl2t8HeFl7o5QZgBagEYyawNxhUl7h4dlelFlZG+QVY6aglmIjjuKd50xla9RKI0mSCqaPJSMM0aEK4mhfbpSnTabM4WXrShtpHI6gqKvmKnCwns0tm2lOsLP3aUy08aK0zvc3d7b09Ei4+Tl5ufo6err7O3n5QAAA7
// ==/UserScript==
"use strict";
try{
(function videotabs(){
  switch(document.domain.match(/(\w+)\.\w+$/)[1]) {
  case 'gooddrama':
    MakeTabs('html,body,#body,#header,#top_block,.info_block,.note span,#eps_blocks,#downloads_heading,#comments_heading,.reply,.info_box{color:#888;background-color:#111;height:auto}table[width="790"],#eps_blocks,.right_col,.info_block .ad{opacity:.6;}.note>font>span{background-color:inherit!important;}');
    break;
  case 'dramago':
    MakeTabs('#menu-bar,.bar,#content,#top_block,#search-box-banner-inner,.info_block,#eps_blocks,.s_right_col #sidebar,#footer{background-color:#111;color:#aaa;border:1px solid #777}body{background-color:#444;background-blend-mode:color-burn;}.note span{background-color:#111!important;color:#aaa!important}');
    break;
  case 'dramagalaxy':
    MakeTabs('#content,#top_block,#search-box-banner-inner,.info_block,#eps_blocks,.s_right_col #sidebar{background-color:#121B23;color:#aaa;border:1px solid #777}img[src$="2egfcQR.png"]{display:none}');
    break;
  case 'animenova':
    MakeTabs('html,body,#body,#header,#comments_heading,.comment,.info_box{color:#555;background-color:#111;height:auto}br:empty,.note img{display:none;}.comment{border:0px}.right_col,table,.ad,.sc_ad,#g_promo,#upper_header{opacity:.6;}');
    break;
  case 'animeplus':
    MakeTabs('html,body,#body,#header,.part,.note>span,.report_video,#comments_heading,.comment,.info_box{background-color:#000!important;color:#aaa!important;}a.report_video:hover{color:red!important;}.right_col,table,.ad,.sc_ad{opacity:.6;}#comments,.comment,#body,#streams{border:1px solid #555}');
    break;
  case 'animewow':
    MakeTabs('#page,#body>.s_left_col,#body>.s_right_col,#search-box-banner-inner,#eps_blocks{color:#aaa;background-color:#111;}.vmargin,#top_block,.info_block{border:1px solid #aaa;background-color:#111;}.info_block *{color:#aaa!important}');
    break;
  case 'gogoanime':
    MakeTabs2('');
    break;
  case 'goodanime':
    MakeTabs2('.topad,#wrapper,.premiumdll,.postcontent,td[bgcolor]{background-color:#111;color:#aaa}#header,#footer,html,body{background-color:#000;color:#aaa}a h5,td[bgcolor] *{color:inherit!important;}')
    break;
  case 'animehere':
    MakeTabs3('');
    break;
  default:
    MakeTabs('');
    break;
  }
  RemoveSomeIframes();
  if(obj('#streams'))window.setTimeout(function(){try{window.autoClose=-1;MHideBar();}catch(e){}},999);
  else if(obj('#videos'))SetStyle('#videos a:visited{color:red;}');
})();
}catch(e){console.log(e)}

function RemoveSomeIframes() {
  var streams = obj('#streams'), dbgt = [];
  if(streams) {
    var a = objs('IFRAME'), i = a.length, o, name;
    if(i) do {
      o = a[--i];
      if(!streams.contains(o)) {
	if(o.id)
	  name = '#' + o.id;
	else {
	  try {
	    name = o.src.match(/\/\/(?:www\.)?([^/]+)/)[1];
	  } catch (e) {
	    name = 'unknown';
	  }
	}
	var div = obj('+DIV'), btn = obj('+BUTTON');
	btn.type = 'button';
	btn.innerHTML = 'show ' + name + ' content';
	btn.title = o.getAttribute('src');
	if(o.parentNode.nodeName == 'TD')
	  o = o.parentNode;
	btn.setAttribute('onclick', 'this.parentNode.innerHTML=decodeURIComponent("'+encodeURIComponent(o.outerHTML)+'");');
	div.appendChild(btn);
	o.parentNode.insertBefore(div, o);
	o.parentNode.removeChild(o);
      }
    } while(i);
  }
}

function obj(name, parent) {
  if(!parent) parent = document;
  var node = null;
  switch (name.charAt(0)) {
  case '#': node = parent.getElementById(name.slice(1)); break;
  case '.': node = parent.getElementsByClassName(name.slice(1))[0]; break;
  case '+': node = document.createElement(name.slice(1).toUpperCase()); if(parent != document) parent.appendChild(node); break;
  default:  node = parent.getElementsByTagName(name)[0]; break;
  }
  return node;
}

function objs(name, parent) {
  if(!parent) parent = document;
  var node = null;
  switch (name.charAt(0)) {
  case '.': node = parent.getElementsByClassName(name.slice(1)); break;
  default: node = parent.getElementsByTagName(name); break;
  }
  return node;
}

function SetStyle(style) {
  if(style) obj('+STYLE', obj('HEAD')).innerHTML = style;
}

function RemoveElement(node) { 
  if(typeof(node)=='string') node = obj(node);
  if(node) return node.parentNode.removeChild(node);
}

function domainName(href) {
  if(!href) href = document.location.href;
  var m = href.match(/\:\/\/(?:www\.|embed\.)?([^\/]+)/);
  return(m ? m[1] : 'unknown');
}

function SetCookie(name, value, min) {
  if(!min) min = 10080; // a week
  var d = new Date();
  d.setTime(min*60000+d.getTime());
  document.cookie=name+'='+value+';expires='+ d.toUTCString()+';'+'path=..';
}

function GetCookie(name) {
  var m = document.cookie.match(new RegExp(name+'=([^;]+)', ''));
  return(m ? m[1] : '');
}

function MakeTabs(style) {
  if(obj('#player_tabs')) return true;
  var content = obj('#streams');
  if(content) {
    var va = objs('.vmargin', content), i=va.length;
    if(i) {
      var tabs = obj('+UL');
      tabs.setAttribute('id', 'player_tabs');
      do {
	var o = va[--i];
	var ifr = obj('IFRAME', o);
	if(ifr) {
	  var tab = obj('+LI'), src = ifr.getAttribute('src');
	  if(src.match(/[?&]/) == '&') ifr.setAttribute('src', src.replace('&', '?')); // bugfix
	  if(!ifr.getAttribute('allowfullscreen')) ifr.setAttribute('allowfullscreen', 'true'); // enable fs for html5 video
	  tab.innerHTML = domainName(src);
	  tab.setAttribute('id', 'player_tab_'+i);
	  tab.onclick = function(event) { if(event.ctrlKey) NewWindow(this); else TabSelect(this) };
	  o.setAttribute('id', 'player_data_'+i);
	  o.innerHTML = encodeURI(o.innerHTML);
	  tabs.insertBefore(tab, tabs.firstChild);
	}
      } while(i);
      obj('+LI', tabs).innerHTML = '&nbsp';
      content.insertBefore(tabs, va[0]);
      obj('+DIV', content).setAttribute('id', 'yahvtplayer');
      SetStyle('.vmargin{display:none}#player_tabs li{background-color:#393939;color:white;display:block;float:left;width:auto;padding:5px 10px;cursor:pointer;}#player_tabs li:hover{color:yellow;}#player_tabs li:last-child{cursor:auto;float:unset}#player_tabs .active_tab{background-color:#505050}#player_tabs .active_tab:hover{color:gray}a.report_video:link{color:#0047AB}');
      TabSelect(GetCookie('us_preferedServer'));
      Disclaimer();
      SetStyle(style);
      return true;
    }
  } // auto expand description - it's foolish to hide the last few words of a sen...[expand]
  if(obj('#brief_notes'))SetStyle('span#brief_notes,span#full_notes a[href="#"]{display:none!important;}span#full_notes{display:inline!important;}a:visited{color:red;}');
  return false;
}

//goodanime.eu
function MakeTabs2(style) {
  var streams = obj('.postcontent');
  if(streams) {
    var ifr = obj('IFRAME', streams);
    if(ifr) {
      streams.setAttribute('id', 'streams');
      var a = streams.childNodes, i = a.length;
      do {
	var o = a[--i];
	if(o.nodeType == 1 && obj('IFRAME', o))
	  o.setAttribute('class','vmargin');
      } while(i);
      return MakeTabs(style);
    }
  }
  return false;
}

//animehere.com
function MakeTabs3(style) {
  if(obj('#player_tabs')) return true;
  var content = obj('#playbox');
  if(content) {
    var va = objs('IFRAME', content), i=va.length;
    if(i) {
      var tabs = obj('+UL');
      tabs.id = 'player_tabs';
      do {
	var ifr = va[--i];
	if(ifr) {
	  var tab = obj('+LI'), src = ifr.getAttribute('src'), o = obj('+DIV', content);
	  if(src.match(/[?&]/) == '&') ifr.setAttribute('src', src.replace('&', '?')); // bugfix
	  if(!ifr.getAttribute('allowfullscreen')) ifr.setAttribute('allowfullscreen', 'true'); // enable fs for html5 video
	  tab.innerHTML = domainName(src);
	  tab.setAttribute('id', 'player_tab_'+i);
	  tab.onclick = function(event) { if(event.ctrlKey) NewWindow(this); else TabSelect(this) };
	  o.setAttribute('id', 'player_data_'+i);
	  o.setAttribute('class', 'vmargin');
	  o.innerHTML = encodeURI(ifr.outerHTML);
	  tabs.insertBefore(tab, tabs.firstChild);
	  RemoveElement(ifr);
	}
      } while(i);
      obj('+LI', tabs).innerHTML = '&nbsp';
      content.insertBefore(tabs, va[0]);
      obj('+DIV', content).setAttribute('id', 'yahvtplayer');
      SetStyle('.vmargin{display:none}#player_tabs li{background-color:#393939;color:white;float:left;padding:5px 10px;display:block;cursor:pointer;}#player_tabs li:hover{color:yellow;}#player_tabs li:last-child{cursor:auto;float:unset}#player_tabs .active_tab{background-color:#505050}#player_tabs .active_tab:hover{color:gray}a.report_video:link{color:#0047AB}');
      TabSelect(GetCookie('us_preferedServer'));
      Disclaimer();
      SetStyle(style);
      return true;
    }
  } // auto expand description - it's foolish to hide the last few words of a sen...[expand]
  if(obj('#brief_notes'))SetStyle('span#brief_notes,span#full_notes a[href="#"]{display:none!important;}span#full_notes{display:inline!important;}a:visited{color:red;}');
  return false;
}
 
function NewWindow(n) {
  var m = decodeURI(obj('#player_data_'+n.id.slice(-1)).innerHTML).match(/src="(\S+?)"/);
  if(m)
    window.open(m[1].replace(/&/g,'&'), '_newtab');
}

function TabSelect(n) {
  var o, a;
  switch(typeof(n)) {
  case 'object':
    n = n.id.slice(-1);
    break;
  case 'string':
    a = obj('#player_tabs').childNodes;
    for(o = 0;; o++) {
      if(o >= a.length) { n = 0; break; }
      if(a[o].innerHTML == n) { n = a[o].id.slice(-1); break; }
    }
    break;
  }
  o = obj('#player_tab_'+n);
  if(o.getAttribute('class') != 'active_tab') {
    a = obj('.active_tab');
    if(a) a.removeAttribute('class');
    o.setAttribute('class', 'active_tab');
    obj('#yahvtplayer').innerHTML = decodeURI(obj('#player_data_'+n).innerHTML);
    SetCookie('us_preferedServer', o.innerHTML);
  }
}

function Disclaimer() {
  var o = obj('#footer');
  if(o && o.textContent.match(/(Copyright|©)/i))
    obj('+P',o).innerHTML = '<br>Disclaimer: Video materials used here are the property of their respective and rightful owners.';
}

// public domain by gnblizz
// contact me with my username + '@web.de'