aboutsummaryrefslogtreecommitdiffstats
path: root/src/scripts/auto-login.ts
diff options
context:
space:
mode:
authorArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2023-02-04 12:20:46 +0530
committerArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2023-02-04 12:20:46 +0530
commita08607762db5681785159358084213558a5f11f9 (patch)
treef3a6245c685ca942ce5fcf918e116509506b7c5a /src/scripts/auto-login.ts
downloadbanglar-bhumi-utils-a08607762db5681785159358084213558a5f11f9.tar.gz
banglar-bhumi-utils-a08607762db5681785159358084213558a5f11f9.zip
Initial commit
Diffstat (limited to 'src/scripts/auto-login.ts')
-rw-r--r--src/scripts/auto-login.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/scripts/auto-login.ts b/src/scripts/auto-login.ts
new file mode 100644
index 0000000..0da8ce3
--- /dev/null
+++ b/src/scripts/auto-login.ts
@@ -0,0 +1,32 @@
+const proxiedPost = $.post;
+
+let loginData: any = null;
+
+$.post = function() {
+ 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);