Chrome DevTools tip #1

Oli Steadman
Jan 22, 2021

How to loop through JS elements by classname… useful for quickly scraping Google Scholar if you need somebody’s total number of citations:

var mytotal=0;// ClassName will likely be a string different to that shown:
let myquery = document.getElementsByClassName(“gsc_a_ac”)
for (var i=0, item; item = myquery[i]; i++) {
var mycount=parseInt(item.innerHTML);
console.log(mycount); // <== we can easily monitor the increment
console.log(mytotal); // <== we can easily copy/paste the answer

See it in use:

Use cmd+ctrl+C to enable hover context and display ClassName as shown for 2nd row in table