ReportTracker

Live report tracker with alerts

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name			ReportTracker
// @version			1.3
// @description		Live report tracker with alerts
// @match			https://epicmafia.com/*
// @author       Croned (The)
// @namespace https://greasyfork.org/en/users/9694-croned
// @grant       GM_setValue
// @grant       GM_getValue
// ==/UserScript==

console.log("ReportTracker activated!");

//Get the list of tracked reports
var reportJSON = GM_getValue("em_reportList");
if (reportJSON) {
	reportJSON = JSON.parse(reportJSON);
}
else {
	reportJSON = {data: []};
    GM_setValue("em_reportList", JSON.stringify(reportJSON));
}
//console.log(reportJSON);
var reportList = reportJSON.data;

//Set the checker interval
var checkInt = setInterval(function() {
	reportJSON = GM_getValue("em_reportList");
	reportJSON = JSON.parse(reportJSON);
	reportList = reportJSON.data;
	
	var tempJSON = reportJSON;
	
	for (var index in reportList) {
		var reportObj = reportList[index];
		(function(report){
			$.get("/report/" + report.id, function(page){
				var div = $("<div></div>");
				div.html(page);
				if (div.find("h2").text().split(" ")[1] == report.id) {
					var status = div.find(".report_status").text();
					var verdict = div.find("#report_statement").text();
					/*console.log(div);
					console.log(status);
					console.log(report.id);*/
					
					if (status != report.status && status == "In Progress") {
						//console.log("Report " + report.id + " is now In Progress!");
						//errordisplay(".errordisplay", "Report " + report.id + " is now In Progress!");
						alert("Report " + report.id + " is now In Progress!");
						tempJSON.data[index].status = status;
						setTimeout(function(){
							GM_setValue("em_reportList", JSON.stringify(tempJSON));
						}, 500);
						
					}
					else if (status != report.status && status == "Closed") {
						//console.log("Report " + report.id + " is now closed with a verdict of " + verdict.replace(" ", "") || "[no verdict]");
						//errordisplay(".errordisplay", "Report " + report.id + " is now closed with a verdict of " + verdict.replace(" ", "") || "[no verdict]");
						alert("Report " + report.id + " is now closed with a verdict of " + verdict.replace(" ", "") || "[no verdict]");
						tempJSON.data.splice(index, 1);
						setTimeout(function(){
							GM_setValue("em_reportList", JSON.stringify(tempJSON));
						}, 500);
					}
				}
				else {
					//console.log("Report " + report.id + " was deleted");
					//errordisplay(".errordisplay", "Report " + report.id + " was deleted");
					alert("Report " + report.id + " was deleted");
					tempJSON.data.splice(index, 1);
					setTimeout(function(){
						GM_setValue("em_reportList", JSON.stringify(tempJSON));
					}, 500);
				}
			});
		})(reportObj);
	}
}, 5000);

//Insert checkboxes for tracking on report pages
var isReport = $(".report_status").text();
if (isReport && isReport != "Closed") {
	$("#report_r1").after("<input type='checkBox' id='trackBox'></input> Track");
}

//Check boxes of reports already tracked
for (var index in reportList) {
	if (reportList[index].id == window.location.pathname.split("/")[2]) {
		$("#trackBox").prop('checked', true);
	}
}

//Detect checkbox checking
var matches;
$("#trackBox").click(function() {
	if ($("#trackBox").prop('checked')) {
		reportJSON.data.push({id: window.location.pathname.split("/")[2], status: "Open"});
		GM_setValue("em_reportList", JSON.stringify(reportJSON));
	}
	else {
		for (var index in reportList) {
			if (reportJSON.data[index].id == window.location.pathname.split("/")[2]) {
				reportJSON.data.splice(index, 1);
				GM_setValue("em_reportList", JSON.stringify(reportJSON));
			}
		}
	}
});