Switch JavaDoc version

Switch between JavaDoc versions since Java 7

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 Switch JavaDoc version
// @namespace https://franklinyu.github.io
// @version 0.1
// @description Switch between JavaDoc versions since Java 7
// @match https://docs.oracle.com/javase/*/docs/api/*
// ==/UserScript==

const match = location.pathname.match('/javase/(\\d+)/docs/api/(.*)')

const select = document.createElement('select')
select.style.float = 'right'
select.addEventListener('change', e => {
	location = `/javase/${e.target.value}/docs/api/${match[2]}`
})

for (const version of ['7', '8', '9', '10']) {
	const option = document.createElement('option')
	option.innerText = version
	if (version === match[1])
		option.selected = true
	select.append(option)
}

const navbar = document.getElementsByClassName('topNav')[0]
navbar && navbar.append(select)