JS for filtering out all the locked(non-free,Subscribe to unlock) questions

For How to use it part, please see my github repo.

Thanks @Sanjaychandak95 for updating the script.

Note : This script might not work if the leetcode site updated their frontend code.

var x = document.getElementsByTagName("tr");
var sum = x.length;
for (let i = 0; i < x.length; i++) {
    if (x[i]["cells"][2]) {
	if(x[i]["cells"][2].firstElementChild){
	if(x[i]["cells"][2].firstElementChild.getElementsByTagName("span")){
        if (x[i]["cells"][2].firstElementChild.getElementsByTagName("span")[1]) {
            if (x[i]["cells"][2].firstElementChild.getElementsByTagName("span")[1].attributes[3].value === "Subscribe to unlock") {
                x[i].hidden = true;
                sum--
            }
        }
      }
    }
}
}
console.log(sum);
Comments (2)