Skip to content

Instantly share code, notes, and snippets.

@PiNaKa30
Created May 6, 2019 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PiNaKa30/8efc5b1188f29d23e7ae21e269fce100 to your computer and use it in GitHub Desktop.
Save PiNaKa30/8efc5b1188f29d23e7ae21e269fce100 to your computer and use it in GitHub Desktop.
// Script By PiNaKa30 [https://github.com/PiNaKa30]
// Worked on older platform, untested on newer one !
clear();
var found = 0;
// Add Tutor Name here..
var tutorName = "Shourya";
// Add Your Favourite Classes here..
var classesRequired = ["Class V", "Class VI", "Class VII", "Class VIII", "Class IX", "Class X"];
// Add Subjects you DONT want to take here..
var subjectsNotRequired = [];
// Add Annoying Students here..
var Blacklist = [];
function notifyMe(tut) {
if (Notification.permission !== "granted")
Notification.requestPermission();
else {
var notification = new Notification('Toppr Doubt Has Arrived', {
icon: 'https://community.toppr.com/static/img/favicon.ico',
body: "Hey " + tut + "!\nA student is waiting for you"});
}
notification.onclick = function () {
window.open("https://community.toppr.com/content/doubts/chat/my-chats/");
};
}
var run = setInterval(detectAndClickButton, 200);
function detectAndClickButton() {
if(found == 1){
clearInterval(run);
}
var parent = document.getElementsByClassName("style__doubt-container___2SF-V style__clr___26B6m");
for(var i = 0; i < parent.length; ++i) {
if(found == 1)
break;
var doubt = parent[i];
if(doubt != undefined) {
var studentName = doubt.children[1].children[1].children[0].children[0].innerHTML;
var studentClass = doubt.children[1].children[2].children[2].innerHTML;
var studentSubject = doubt.children[1].children[2].children[1].innerHTML;
console.log(studentName + " (" + studentClass + ") " + studentSubject);
var ind1 = classesRequired.indexOf(studentClass);
var ind2 = Blacklist.indexOf(studentName);
var ind3 = subjectsNotRequired.indexOf(studentSubject);
if((ind1 != -1) && (ind2 == -1) && (ind3 == -1)){
doubt.click();
setTimeout(function() {
var buttons = document.getElementsByClassName("style__button___1bexT style__button-green___1cJYa");
buttons[0].click();
notifyMe(tutorName);
console.log(buttons[0]);
found = 1;
}, 30);
}
}
}
}
// Just copy this script and press Enter. Script stops when it finds a doubt.
// After solving the doubt, press up key and Enter to run the script again !
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment