Random Episode Selector

Select random episode from Wikipedia list article.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name     Random Episode Selector
// @grant    none
// @namespace   com.cool.pax
// @include     https://en.wikipedia.org/wiki/List_of_*
// @version     1
// @description:en  Select random episode from Wikipedia list article.
// @description Select random episode from Wikipedia list article.
// ==/UserScript==

function getRandomInt(max) {
  return Math.floor(Math.random() * Math.floor(max));
}

var x = Array.from( document.querySelectorAll( ".vevent" ) );

var i = getRandomInt( x.length );

var h = x[i].querySelector( "th" );
var s = x[i].querySelector( ".summary" );

var ex = x[i].nextElementSibling;

if ( ex.className == "vevent" )
  ex = "";
else
  ex = ex.textContent;

alert( h.id + "\n" + s.textContent + "\n\n" + ex );