Last active 1756168990

f97's Avatar f97 revised this gist 1756168990. Go to revision

1 file changed, 25 insertions, 7 deletions

clc.js

@@ -1,23 +1,41 @@
1 + // CLC TimezoneDB Mock
2 + // Giữ schema y như TimezoneDB, nhưng timestamp mock lại
3 +
1 4 try {
2 5 const YEARS_TO_SUBTRACT = 60 * 60 * 24 * 18200; // ~49.86 năm
3 6 const TWO_HOURS = 7200; // 2 giờ
4 - const now = Math.floor(Date.now() / 1000);
7 + const nowSec = Math.floor(Date.now() / 1000);
5 8
6 9 // Đếm số lần gọi
7 - let callCount = parseInt($persistentStore.read("v3") || "0") + 1;
8 - $persistentStore.write(callCount.toString(), "v3");
10 + let callCount = parseInt($persistentStore.read("v3") || "0", 10) + 1;
11 + $persistentStore.write(String(callCount), "v3");
12 +
13 + // Tạo timestamp giả
14 + const fakeTimestamp = nowSec - YEARS_TO_SUBTRACT + (callCount * TWO_HOURS);
9 15
10 - // Tạo body giả
16 + // Build body theo schema TimezoneDB (mock cơ bản, bạn có thể hardcode thêm)
11 17 const body = {
12 18 status: "OK",
13 - message: "local mock",
14 - timestamp: now - YEARS_TO_SUBTRACT + (callCount * TWO_HOURS)
19 + message: "",
20 + countryCode: "VN",
21 + zoneName: "Asia/Ho_Chi_Minh",
22 + abbreviation: "ICT",
23 + gmtOffset: 25200, // +7h
24 + dst: "0",
25 + zoneStart: fakeTimestamp - 86400, // giả: hôm trước
26 + zoneEnd: fakeTimestamp + 86400, // giả: hôm sau
27 + nextAbbreviation: "ICT",
28 + timestamp: fakeTimestamp,
29 + formatted: new Date(fakeTimestamp * 1000).toISOString().replace("T", " ").split(".")[0]
15 30 };
16 31
17 32 $done({
18 33 response: {
19 34 status: 200,
20 - headers: { "Content-Type": "application/json" },
35 + headers: {
36 + "Content-Type": "application/json; charset=utf-8",
37 + "Cache-Control": "no-store"
38 + },
21 39 body: JSON.stringify(body)
22 40 }
23 41 });

f97's Avatar f97 revised this gist 1756168039. Go to revision

1 file changed, 1 insertion, 1 deletion

clc.module

@@ -5,7 +5,7 @@
5 5
6 6 [Script]
7 7 # Chặn mọi request tới api.timezonedb.com và trả JSON local
8 - CLC-Time=type=http-request,pattern=^https?:\/\/api\.timezonedb\.com\/.* ,script-path=clc.js
8 + CLC-Time=type=http-request,pattern=^https?:\/\/api\.timezonedb\.com\/.* ,script-path=https://demo.opengist.io/f97/cfa7470912c74cae8834bbd590f86666/raw/HEAD/clc.js
9 9
10 10 [MITM]
11 11 hostname=%APPEND% api.timezonedb.com

f97's Avatar f97 revised this gist 1756168002. Go to revision

2 files changed, 37 insertions

clc.js(file created)

@@ -0,0 +1,26 @@
1 + try {
2 + const YEARS_TO_SUBTRACT = 60 * 60 * 24 * 18200; // ~49.86 năm
3 + const TWO_HOURS = 7200; // 2 giờ
4 + const now = Math.floor(Date.now() / 1000);
5 +
6 + // Đếm số lần gọi
7 + let callCount = parseInt($persistentStore.read("v3") || "0") + 1;
8 + $persistentStore.write(callCount.toString(), "v3");
9 +
10 + // Tạo body giả
11 + const body = {
12 + status: "OK",
13 + message: "local mock",
14 + timestamp: now - YEARS_TO_SUBTRACT + (callCount * TWO_HOURS)
15 + };
16 +
17 + $done({
18 + response: {
19 + status: 200,
20 + headers: { "Content-Type": "application/json" },
21 + body: JSON.stringify(body)
22 + }
23 + });
24 + } catch (e) {
25 + $done({});
26 + }

clc.module(file created)

@@ -0,0 +1,11 @@
1 + #!name=CLC Time Mock
2 + #!desc=Mock TimezoneDB: local time minus ~50 years + +2h per call
3 + #!author=f97
4 + #!homepage=https://f97.xyz
5 +
6 + [Script]
7 + # Chặn mọi request tới api.timezonedb.com và trả JSON local
8 + CLC-Time=type=http-request,pattern=^https?:\/\/api\.timezonedb\.com\/.* ,script-path=clc.js
9 +
10 + [MITM]
11 + hostname=%APPEND% api.timezonedb.com

f97's Avatar f97 revised this gist 1756165849. Go to revision

1 file changed, 2 insertions, 2 deletions

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("v1_call_count") || "0") + 1;
9 - $persistentStore.write(callCount.toString(), "v1_call_count");
8 + let callCount = parseInt($persistentStore.read("v3") || "0") + 1;
9 + $persistentStore.write(callCount.toString(), "v3");
10 10
11 11 // Update timestamp if exists
12 12 if (body?.timestamp) {

f97's Avatar f97 revised this gist 1756165370. Go to revision

2 files changed, 4 insertions, 4 deletions

with_call_count.js renamed to 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("x7_call_count") || "0") + 1;
9 - $persistentStore.write(callCount.toString(), "x7_call_count");
8 + let callCount = parseInt($persistentStore.read("v1_call_count") || "0") + 1;
9 + $persistentStore.write(callCount.toString(), "v1_call_count");
10 10
11 11 // Update timestamp if exists
12 12 if (body?.timestamp) {

timezone.module

@@ -1,10 +1,10 @@
1 - #!name=Timezone Shift
1 + #!name=Timezone
2 2 #!homepage=https://f97.xyz
3 3 #!author=f97
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/count.js
8 8
9 9 [MITM]
10 10 hostname=%APPEND% api.timezonedb.com

f97's Avatar f97 revised this gist 1756141677. 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("r26_call_count") || "0") + 1;
9 - $persistentStore.write(callCount.toString(), "r26_call_count");
8 + let callCount = parseInt($persistentStore.read("x7_call_count") || "0") + 1;
9 + $persistentStore.write(callCount.toString(), "x7_call_count");
10 10
11 11 // Update timestamp if exists
12 12 if (body?.timestamp) {

f97's Avatar f97 revised this gist 1751449070. 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's Avatar f97 revised this gist 1751444977. 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's Avatar f97 revised this gist 1751444662. 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's Avatar f97 revised this gist 1751441727. 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
Newer Older