DEV Community

Cover image for Coronavirus stats: worldwide country position bookmarklet
Janko
Janko

Posted on

Coronavirus stats: worldwide country position bookmarklet

javascript:
void( 
document.body.onclick = async function (event) {
 event = event || window.event;
 var element = event.target || event.srcElement;
 await new Promise(resolve => setTimeout(resolve, 10));
 state = 'Czechia'; /* CHANGE THIS TO SEE OTHER STATE */
 index = document.body.innerText.search(state);
 place = document.body.innerText.substring(index - 4,index).match(/\n([0-9]+)/);
 alert(state + ' is #' + place[1] + ' in ' + element.textContent + ' worldwide.')} );
Enter fullscreen mode Exit fullscreen mode

Simply add this code in place of a bookmark URL - Alt Text

Go to https://www.worldometers.info/coronavirus/ and click this bookmark. Then - when you click on the first row of the data table with data
Alt Text
the bookmarklet will show you the position of the selected country (see in code)
Alt Text

Top comments (0)