aboutsummaryrefslogtreecommitdiffstats
path: root/src/scripts/login.ts
blob: e2d5d5bc730c28718364ca3c909c779ffe0fafa4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
document.addEventListener("DOMContentLoaded", () => {
	const proxiedPost = $.post;

	let loginData: any | null = null;

	$.post = function() {
		if (arguments[0].endsWith("viewLoginAreaAction")) {
			(window as any).DrawLoginCaptcha = () => {};
			const callback = arguments[1];
			arguments[1] = (html: any) => {
				callback(html);
				const captchaValueElement = document.getElementById("txtCaptcha") as HTMLInputElement;
				const captchaInputElement = document.getElementById("txtInput") as HTMLInputElement;
				captchaValueElement.value = "ffffff";
				captchaInputElement.value = "ffffff";
				captchaValueElement.style.display = "none";
				captchaInputElement.style.display = "none";
				(document.querySelector(".captcharefresh") as HTMLElement).style.display = "none";
			}
		} else if (arguments[0].endsWith("viewPasswordRecoveryArea")) {
			(window as any).Captcha = () => {};
			const callback = arguments[1];
			arguments[1] = (html: any) => {
				callback(html);
				const captchaInputElement = document.getElementById("dText") as HTMLInputElement;
				const captchaValueElement = document.getElementById("captaText") as HTMLInputElement;
				captchaValueElement.value = "ffffff";
				captchaInputElement.value = "ffffff";
				captchaValueElement.style.display = "none";
				captchaInputElement.style.display = "none";
				(document.getElementById("captchaRef") as HTMLElement).style.display = "none";
			}
		} else if (arguments[0].endsWith("login.action")) {
			const callback = arguments[2];
			arguments[2] = (data: any) => {
				if (!data.exception && data.checkmsg === "success") {
					loginData = arguments[1];
				}
				callback(data);
			};
		}

		return proxiedPost.apply(this, Array.from(arguments) as any);
	};

	setInterval(() => {
		if (loginData) {
			$.post(
				"/BanglarBhumi/login.action",
				loginData,
				data => {
					if (data.exception || data.checkmsg !== "success") {
						loginData = null;
					}
				},
				"json"
			);
		}
	}, 1000 * 60 * 5);
});