f97 revised this gist . Go to revision
1 file changed, 2 insertions, 2 deletions
with_call_count.js
@@ -5,8 +5,8 @@ try { | |||
5 | 5 | const now = Math.floor(Date.now() / 1000); | |
6 | 6 | ||
7 | 7 | // Get and increment call count | |
8 | - | let callCount = parseInt($persistentStore.read("call_count") || "0") + 1; | |
9 | - | $persistentStore.write(callCount.toString(), "call_count"); | |
8 | + | let callCount = parseInt($persistentStore.read("r26_call_count") || "0") + 1; | |
9 | + | $persistentStore.write(callCount.toString(), "r26_call_count"); | |
10 | 10 | ||
11 | 11 | // Update timestamp if exists | |
12 | 12 | if (body?.timestamp) { |
f97 revised this gist . Go to revision
1 file changed, 1 insertion, 1 deletion
timezone.module
@@ -4,7 +4,7 @@ | |||
4 | 4 | #!desc=Adjust TimezoneDB timestamp by subtracting ~50 years | |
5 | 5 | ||
6 | 6 | [Script] | |
7 | - | TimezoneDB=type=http-response,pattern=timezonedb,requires-body=1,script-path=https://demo.opengist.io/f97/cfa7470912c74cae8834bbd590f86666/raw/HEAD/fix.js | |
7 | + | TimezoneDB=type=http-response,pattern=timezonedb,requires-body=1,script-path=https://demo.opengist.io/f97/cfa7470912c74cae8834bbd590f86666/raw/HEAD/with_call_count.js | |
8 | 8 | ||
9 | 9 | [MITM] | |
10 | 10 | hostname=%APPEND% api.timezonedb.com |
f97 revised this gist . Go to revision
1 file changed, 1 insertion, 1 deletion
timezone.module
@@ -4,7 +4,7 @@ | |||
4 | 4 | #!desc=Adjust TimezoneDB timestamp by subtracting ~50 years | |
5 | 5 | ||
6 | 6 | [Script] | |
7 | - | TimezoneDB=type=http-response,pattern=timezonedb,requires-body=1,script-path=https://demo.opengist.io/f97/cfa7470912c74cae8834bbd590f86666/raw/HEAD/with_call_count.js | |
7 | + | TimezoneDB=type=http-response,pattern=timezonedb,requires-body=1,script-path=https://demo.opengist.io/f97/cfa7470912c74cae8834bbd590f86666/raw/HEAD/fix.js | |
8 | 8 | ||
9 | 9 | [MITM] | |
10 | 10 | hostname=%APPEND% api.timezonedb.com |
f97 revised this gist . Go to revision
1 file changed, 1 insertion, 1 deletion
timezone.module
@@ -4,7 +4,7 @@ | |||
4 | 4 | #!desc=Adjust TimezoneDB timestamp by subtracting ~50 years | |
5 | 5 | ||
6 | 6 | [Script] | |
7 | - | TimezoneDB=type=http-response,pattern=timezonedb,requires-body=1,script-path=https://demo.opengist.io/f97/cfa7470912c74cae8834bbd590f86666/raw/HEAD/fix.js | |
7 | + | TimezoneDB=type=http-response,pattern=timezonedb,requires-body=1,script-path=https://demo.opengist.io/f97/cfa7470912c74cae8834bbd590f86666/raw/HEAD/with_call_count.js | |
8 | 8 | ||
9 | 9 | [MITM] | |
10 | 10 | hostname=%APPEND% api.timezonedb.com |
f97 revised this gist . Go to revision
1 file changed, 19 insertions
with_call_count.js(file created)
@@ -0,0 +1,19 @@ | |||
1 | + | try { | |
2 | + | const body = JSON.parse($response.body); | |
3 | + | const YEARS_TO_SUBTRACT = 60 * 60 * 24 * 18200; // ~49.86 years | |
4 | + | const TWO_HOURS = 7200; // 2 hours in seconds | |
5 | + | const now = Math.floor(Date.now() / 1000); | |
6 | + | ||
7 | + | // Get and increment call count | |
8 | + | let callCount = parseInt($persistentStore.read("call_count") || "0") + 1; | |
9 | + | $persistentStore.write(callCount.toString(), "call_count"); | |
10 | + | ||
11 | + | // Update timestamp if exists | |
12 | + | if (body?.timestamp) { | |
13 | + | body.timestamp = now - YEARS_TO_SUBTRACT + (callCount * TWO_HOURS); | |
14 | + | } | |
15 | + | ||
16 | + | $done({ body: JSON.stringify(body) }); | |
17 | + | } catch (error) { | |
18 | + | $done({}); | |
19 | + | } |
f97 revised this gist . Go to revision
1 file changed, 3 insertions, 1 deletion
fix.js
@@ -1,8 +1,10 @@ | |||
1 | 1 | try { | |
2 | 2 | let body = JSON.parse($response.body); | |
3 | 3 | const secondsToSubtract = 60 * 60 * 24 * 18200; // ~49.86 năm | |
4 | + | const now = Math.floor(Date.now() / 1000); | |
5 | + | ||
4 | 6 | if (body?.timestamp) { | |
5 | - | body.timestamp = Number(body.timestamp) - secondsToSubtract; | |
7 | + | body.timestamp = Number(now ?? body.timestamp) - secondsToSubtract; | |
6 | 8 | } | |
7 | 9 | $done({ body: JSON.stringify(body) }); | |
8 | 10 | } catch (e) { |
f97 revised this gist . Go to revision
1 file changed, 1 insertion, 1 deletion
now.js
@@ -6,7 +6,7 @@ const now = Math.floor(Date.now() / 1000); | |||
6 | 6 | ||
7 | 7 | if (body?.timestamp) { | |
8 | 8 | body.now = now; | |
9 | - | body.timestamp = now + 3000; | |
9 | + | body.timestamp = now; | |
10 | 10 | } | |
11 | 11 | ||
12 | 12 | $done({ body: JSON.stringify(body) }); |
f97 revised this gist . Go to revision
1 file changed, 1 insertion, 1 deletion
now.js
@@ -6,7 +6,7 @@ const now = Math.floor(Date.now() / 1000); | |||
6 | 6 | ||
7 | 7 | if (body?.timestamp) { | |
8 | 8 | body.now = now; | |
9 | - | body.timestamp = now; | |
9 | + | body.timestamp = now + 3000; | |
10 | 10 | } | |
11 | 11 | ||
12 | 12 | $done({ body: JSON.stringify(body) }); |
f97 revised this gist . Go to revision
1 file changed, 1 insertion
now.js
@@ -6,6 +6,7 @@ const now = Math.floor(Date.now() / 1000); | |||
6 | 6 | ||
7 | 7 | if (body?.timestamp) { | |
8 | 8 | body.now = now; | |
9 | + | body.timestamp = now; | |
9 | 10 | } | |
10 | 11 | ||
11 | 12 | $done({ body: JSON.stringify(body) }); |
f97 revised this gist . Go to revision
1 file changed, 1 insertion, 1 deletion
now.js
@@ -2,7 +2,7 @@ try { | |||
2 | 2 | let body = JSON.parse($response.body); | |
3 | 3 | ||
4 | 4 | // Lấy timestamp hiện tại theo giờ hệ thống (UTC, tính theo giây) | |
5 | - | const now = Date.now(); | |
5 | + | const now = Math.floor(Date.now() / 1000); | |
6 | 6 | ||
7 | 7 | if (body?.timestamp) { | |
8 | 8 | body.now = now; |