Simple devtools script to track when User is coming online/offline with privacy options on (whatsapp is not showing last seen)
function getElementByXpath(path) {
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}
var online = false;
setInterval(function() {
if (getElementByXpath('//*[@id="main"]/header/div[2]/div[1]/div/span').textContent == "User to track") { var lastSeen = getElementByXpath('//*[@id="main"]/header/div[2]/div[2]/span');
if (lastSeen != null) {
var today = new Date();
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
console.log(date + " "+ time + ", " + lastSeen.textContent);
if (online == false) {
new Notification(date + " "+ time + ", " + lastSeen.textContent);
online = true;
}
} else {
if (online == true) {
var today = new Date();
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
new Notification(date + " "+ time + " Offline");
online = false;
}
}
}
}, 1000);