video tabs

tabbed video sources on certain drama and anime sites

目前為 2016-04-03 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        video tabs
// @namespace   gnblizz
// @description tabbed video sources on certain drama and anime sites
// @version     1.03
// @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://www.animewow.org/*
// @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){}},1999);
  } else if(obj('#videos'))SetStyle('#videos a:visited{color:red;}');
})();
}catch(e){console.log(e)}

function RemoveSomeIframes() {
  var streams = obj('#streams');
  if(streams) {
    var o, name, a=objs('IFRAME'), i=a.length;
    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;
  switch(name.charAt(0)) {
  case '.': return parent.getElementsByClassName(name.slice(1)); break;
  default: return parent.getElementsByTagName(name); break;
  }
}

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 Remember(name, value) {
  localStorage.setItem(name, value);
}

function remembered(name) {
  return localStorage.getItem(name);
}

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) };
	  tab.onmouseup = function(event) {if(!event.ctrlKey)switch(event.button){case 1:break;case 0:TabSelect(this);default:return;}NewWindow(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(remembered('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'), o;
  if(streams) {
    var ifr = obj('IFRAME', streams);
    if(ifr) {
      streams.setAttribute('id', 'streams');
      for(o of streams.children) {
	if(o.nodeType == 1 && obj('IFRAME', o))
	  o.setAttribute('class','vmargin');
      }
      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) };
	  tab.onmouseup = function(event) {if(!event.ctrlKey)switch(event.button){case 1:break;case 0:TabSelect(this);default:return;}NewWindow(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(remembered('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':
    try {
      n = n.id.slice(-1);
    } catch(e) {
      n = '0';
    }
    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);
    Remember('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.';
  o = document.querySelector('.info_block .note>span.imp:last-of-type');
  if(o && o.textContent == '95%')
    o.textContent = '0.5%';// a slightly more realistic value
}

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