AO Auto choose player

Add to anime-odcinki.pl's players auto choose player in order of players

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        AO Auto choose player
// author       Wiktor Radecki
// @namespace   AnimeOdcinki
// @include     http://anime-odcinki.pl/*
// @version     3
// @grant       none
// @description Add to anime-odcinki.pl's players auto choose player in order of players
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// ==/UserScript==

// Należy wyedytowac liste z odtwarzaczmi... jest sprawdzane po tej liscie czy jest taki player
// jesli jest to wybiera go i przelacza.
// Bierze pirwszy na liscie, wiec trzeba wpisac w kolejnosci w jakiej chce sie wybierac otwarzacze.
var players = ['VK Player', 'Google Player', 'Tune Player', 'MP4Upload Player'];

var done = false;

$(document).ready(choosePlayer);

function filterByNonNext(array) {
  var divs = [];
  for(var i = 0; i < array.length; i++){
    var div = array[i];
    if(contains(div.innerHTML,'&lt;&lt;') 
       || contains(div.innerHTML, '&gt;&gt;')
       || contains(div.innerHTML, '<<') 
       || contains(div.innerHTML, '>>'))
      continue;
    divs.push(div);
  }
  return divs;
}

function contains(text, search){
  return text.indexOf(search) > -1;
}

function choosePlayer(){
var playerDiv = $('#video-player-control');
if (playerDiv.length) {
  var divs = filterByNonNext(playerDiv.children());
  for (var i = 0; !done && i < players.length; i++) {
    var player = players[i];
    for (var j = 0; j < divs.length && !done; j++) {
      var div = divs[j];
      if(contains(div.innerHTML,player)){
        done = true;
        if(div !== divs[0]){
          div.click(); 
        }
      }
    }
  }
}

}