AO Auto choose player

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==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(); 
        }
      }
    }
  }
}

}