aboutsummaryrefslogtreecommitdiffstats
path: root/src/scripts/auto-login.ts
diff options
context:
space:
mode:
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);