From 63093a82cd222e540189c1a3c58a896814282c26 Mon Sep 17 00:00:00 2001
From: Ross <64715639+Tira-tw@users.noreply.github.com>
Date: Mon, 29 Apr 2024 22:28:56 +0800
Subject: [PATCH] Add files via upload
---
language/English/how-set.md | 2 +
language/English/index.html | 110 +++++++++
language/English/index.js | 211 ++++++++++++++++++
language/Indonesia/Bagaimana mengatur.md | 2 +
language/Indonesia/index.html | 110 +++++++++
language/Indonesia/index.js | 211 ++++++++++++++++++
language/Korea/index.html | 110 +++++++++
language/Korea/index.js | 210 +++++++++++++++++
...0\353\212\224 \353\260\251\353\262\225.md" | 2 +
language/Philippines/Paano i-set.md | 2 +
language/Philippines/index.html | 110 +++++++++
language/Philippines/index.js | 211 ++++++++++++++++++
language/README.md | 24 ++
...73\203 ch\341\273\211nh s\341\273\255a.md" | 2 +
language/Vietnam/index.html | 110 +++++++++
language/Vietnam/index.js | 211 ++++++++++++++++++
language/chinese-zh-cn/index.html | 111 +++++++++
language/chinese-zh-cn/index.js | 211 ++++++++++++++++++
...02\344\275\225\350\256\276\345\256\232.md" | 2 +
language/chinese-zh-tw/index.html | 111 +++++++++
language/chinese-zh-tw/index.js | 211 ++++++++++++++++++
...02\344\275\225\350\250\255\345\256\232.md" | 2 +
22 files changed, 2286 insertions(+)
create mode 100644 language/English/how-set.md
create mode 100644 language/English/index.html
create mode 100644 language/English/index.js
create mode 100644 language/Indonesia/Bagaimana mengatur.md
create mode 100644 language/Indonesia/index.html
create mode 100644 language/Indonesia/index.js
create mode 100644 language/Korea/index.html
create mode 100644 language/Korea/index.js
create mode 100644 "language/Korea/\354\204\244\354\240\225\355\225\230\353\212\224 \353\260\251\353\262\225.md"
create mode 100644 language/Philippines/Paano i-set.md
create mode 100644 language/Philippines/index.html
create mode 100644 language/Philippines/index.js
create mode 100644 language/README.md
create mode 100644 "language/Vietnam/C\303\241ch \304\221\341\273\203 ch\341\273\211nh s\341\273\255a.md"
create mode 100644 language/Vietnam/index.html
create mode 100644 language/Vietnam/index.js
create mode 100644 language/chinese-zh-cn/index.html
create mode 100644 language/chinese-zh-cn/index.js
create mode 100644 "language/chinese-zh-cn/\345\246\202\344\275\225\350\256\276\345\256\232.md"
create mode 100644 language/chinese-zh-tw/index.html
create mode 100644 language/chinese-zh-tw/index.js
create mode 100644 "language/chinese-zh-tw/\345\246\202\344\275\225\350\250\255\345\256\232.md"
diff --git a/language/English/how-set.md b/language/English/how-set.md
new file mode 100644
index 00000000..3632a440
--- /dev/null
+++ b/language/English/how-set.md
@@ -0,0 +1,2 @@
+Change the link in index.js No.151 to the following content:
+`https://tira-tw.github.io/english-url/"+config.theme+"/index.html`
diff --git a/language/English/index.html b/language/English/index.html
new file mode 100644
index 00000000..bbf572cd
--- /dev/null
+++ b/language/English/index.html
@@ -0,0 +1,110 @@
+
+
+
The url you visit is not found.
+ want host?come! +` + +let response_header={ + "content-type": "text/html;charset=UTF-8", +} + +if (config.cors=="on"){ + response_header={ + "content-type": "text/html;charset=UTF-8", + "Access-Control-Allow-Origin":"*", + "Access-Control-Allow-Methods": "POST", + } +} + +async function randomString(len) { + len = len || 6; + let $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/ + let maxPos = $chars.length; + let result = ''; + for (i = 0; i < len; i++) { + result += $chars.charAt(Math.floor(Math.random() * maxPos)); + } + return result; +} + +async function sha512(url){ + url = new TextEncoder().encode(url) + + const url_digest = await crypto.subtle.digest( + { + name: "SHA-512", + }, + url, // The data you want to hash as an ArrayBuffer + ) + const hashArray = Array.from(new Uint8Array(url_digest)); // convert buffer to byte array + const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); + //console.log(hashHex) + return hashHex +} +async function checkURL(URL){ + let str=URL; + let Expression=/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/; + let objExp=new RegExp(Expression); + if(objExp.test(str)==true){ + if (str[0] == 'h') + return true; + else + return false; + }else{ + return false; + } +} +async function save_url(URL){ + let random_key=await randomString() + let is_exist=await LINKS.get(random_key) + console.log(is_exist) + if (is_exist == null) + return await LINKS.put(random_key, URL),random_key + else + save_url(URL) +} +async function is_url_exist(url_sha512){ + let is_exist = await LINKS.get(url_sha512) + console.log(is_exist) + if (is_exist == null) { + return false + }else{ + return is_exist + } +} +async function is_url_safe(url){ + + let raw = JSON.stringify({"client":{"clientId":"Url-Shorten-Worker","clientVersion":"1.0.7"},"threatInfo":{"threatTypes":["MALWARE","SOCIAL_ENGINEERING","POTENTIALLY_HARMFUL_APPLICATION","UNWANTED_SOFTWARE"],"platformTypes":["ANY_PLATFORM"],"threatEntryTypes":["URL"],"threatEntries":[{"url":url}]}}); + + let requestOptions = { + method: 'POST', + body: raw, + redirect: 'follow' + }; + + result = await fetch("https://safebrowsing.googleapis.com/v4/threatMatches:find?key="+config.safe_browsing_api_key, requestOptions) + result = await result.json() + console.log(result) + if (Object.keys(result).length === 0){ + return true + }else{ + return false + } +} +async function handleRequest(request) { + console.log(request) + if (request.method === "POST") { + let req=await request.json() + console.log(req["url"]) + if(!await checkURL(req["url"])){ + return new Response(`{"status":500,"key":": Error: Url info maybe is fish website or virus or not this url"}`, { + headers: response_header, + })} + let stat,random_key + if (config.unique_link){ + let url_sha512 = await sha512(req["url"]) + let url_key = await is_url_exist(url_sha512) + if(url_key){ + random_key = url_key + }else{ + stat,random_key=await save_url(req["url"]) + if (typeof(stat) == "undefined"){ + console.log(await LINKS.put(url_sha512,random_key)) + } + } + }else{ + stat,random_key=await save_url(req["url"]) + } + console.log(stat) + if (typeof(stat) == "undefined"){ + return new Response(`{"status":200,"key":"/`+random_key+`"}`, { + headers: response_header, + }) + }else{ + return new Response(`{"status":200,"key":": Error:Reach the KV write limitation."}`, { + headers: response_header, + })} + }else if(request.method === "OPTIONS"){ + return new Response(``, { + headers: response_header, + }) + + } + + const requestURL = new URL(request.url) + const path = requestURL.pathname.split("/")[1] + const params = requestURL.search; + + console.log(path) + if(!path){ + + const html= await fetch("https://tira-tw.github.io/english-url/"+config.theme+"/index.html") + + return new Response(await html.text(), { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + }) + } + + const value = await LINKS.get(path); + let location ; + + if(params) { + location = value + params + } else { + location = value + } + console.log(value) + + + if (location) { + if (config.safe_browsing_api_key){ + if(!(await is_url_safe(location))){ + let warning_page = await fetch("https://xytom.github.io/Url-Shorten-Worker/safe-browsing.html") + warning_page =await warning_page.text() + warning_page = warning_page.replace(/{Replace}/gm, location) + return new Response(warning_page, { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + }) + } + } + if (config.no_ref=="on"){ + let no_ref= await fetch("https://xytom.github.io/Url-Shorten-Worker/no-ref.html") + no_ref=await no_ref.text() + no_ref=no_ref.replace(/{Replace}/gm, location) + return new Response(no_ref, { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + }) + }else{ + return Response.redirect(location, 302) + } + + } + // If request not in kv, return 404 + return new Response(html404, { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + status: 404 + }) +} + + + +addEventListener("fetch", async event => { + event.respondWith(handleRequest(event.request)) +}) diff --git a/language/Indonesia/Bagaimana mengatur.md b/language/Indonesia/Bagaimana mengatur.md new file mode 100644 index 00000000..c1f8975c --- /dev/null +++ b/language/Indonesia/Bagaimana mengatur.md @@ -0,0 +1,2 @@ +Ubah link di index.js No.151 menjadi konten berikut:Tautan yang Anda kunjungi tidak dapat ditemukan
+ Ingin buat yang sama? Klik! +` + +let response_header={ + "content-type": "text/html;charset=UTF-8", +} + +if (config.cors=="on"){ + response_header={ + "content-type": "text/html;charset=UTF-8", + "Access-Control-Allow-Origin":"*", + "Access-Control-Allow-Methods": "POST", + } +} + +async function randomString(len) { + len = len || 6; + let $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/ + let maxPos = $chars.length; + let result = ''; + for (i = 0; i < len; i++) { + result += $chars.charAt(Math.floor(Math.random() * maxPos)); + } + return result; +} + +async function sha512(url){ + url = new TextEncoder().encode(url) + + const url_digest = await crypto.subtle.digest( + { + name: "SHA-512", + }, + url, // The data you want to hash as an ArrayBuffer + ) + const hashArray = Array.from(new Uint8Array(url_digest)); // convert buffer to byte array + const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); + //console.log(hashHex) + return hashHex +} +async function checkURL(URL){ + let str=URL; + let Expression=/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/; + let objExp=new RegExp(Expression); + if(objExp.test(str)==true){ + if (str[0] == 'h') + return true; + else + return false; + }else{ + return false; + } +} +async function save_url(URL){ + let random_key=await randomString() + let is_exist=await LINKS.get(random_key) + console.log(is_exist) + if (is_exist == null) + return await LINKS.put(random_key, URL),random_key + else + save_url(URL) +} +async function is_url_exist(url_sha512){ + let is_exist = await LINKS.get(url_sha512) + console.log(is_exist) + if (is_exist == null) { + return false + }else{ + return is_exist + } +} +async function is_url_safe(url){ + + let raw = JSON.stringify({"client":{"clientId":"Url-Shorten-Worker","clientVersion":"1.0.7"},"threatInfo":{"threatTypes":["MALWARE","SOCIAL_ENGINEERING","POTENTIALLY_HARMFUL_APPLICATION","UNWANTED_SOFTWARE"],"platformTypes":["ANY_PLATFORM"],"threatEntryTypes":["URL"],"threatEntries":[{"url":url}]}}); + + let requestOptions = { + method: 'POST', + body: raw, + redirect: 'follow' + }; + + result = await fetch("https://safebrowsing.googleapis.com/v4/threatMatches:find?key="+config.safe_browsing_api_key, requestOptions) + result = await result.json() + console.log(result) + if (Object.keys(result).length === 0){ + return true + }else{ + return false + } +} +async function handleRequest(request) { + console.log(request) + if (request.method === "POST") { + let req=await request.json() + console.log(req["url"]) + if(!await checkURL(req["url"])){ + return new Response(`{"status":500,"key":": Error: informasi URL ini mungkin situs web yang mencurigakan atau mengandung virus atau bukan URL yang benar"}`, { + headers: response_header, + })} + let stat,random_key + if (config.unique_link){ + let url_sha512 = await sha512(req["url"]) + let url_key = await is_url_exist(url_sha512) + if(url_key){ + random_key = url_key + }else{ + stat,random_key=await save_url(req["url"]) + if (typeof(stat) == "undefined"){ + console.log(await LINKS.put(url_sha512,random_key)) + } + } + }else{ + stat,random_key=await save_url(req["url"]) + } + console.log(stat) + if (typeof(stat) == "undefined"){ + return new Response(`{"status":200,"key":"/`+random_key+`"}`, { + headers: response_header, + }) + }else{ + return new Response(`{"status":200,"key":": Error:Reach the KV write limitation."}`, { + headers: response_header, + })} + }else if(request.method === "OPTIONS"){ + return new Response(``, { + headers: response_header, + }) + + } + + const requestURL = new URL(request.url) + const path = requestURL.pathname.split("/")[1] + const params = requestURL.search; + + console.log(path) + if(!path){ + + const html= await fetch("https://tira-tw.github.io/Indonesia-url/"+config.theme+"/index.html") + + return new Response(await html.text(), { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + }) + } + + const value = await LINKS.get(path); + let location ; + + if(params) { + location = value + params + } else { + location = value + } + console.log(value) + + + if (location) { + if (config.safe_browsing_api_key){ + if(!(await is_url_safe(location))){ + let warning_page = await fetch("https://xytom.github.io/Url-Shorten-Worker/safe-browsing.html") + warning_page =await warning_page.text() + warning_page = warning_page.replace(/{Replace}/gm, location) + return new Response(warning_page, { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + }) + } + } + if (config.no_ref=="on"){ + let no_ref= await fetch("https://xytom.github.io/Url-Shorten-Worker/no-ref.html") + no_ref=await no_ref.text() + no_ref=no_ref.replace(/{Replace}/gm, location) + return new Response(no_ref, { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + }) + }else{ + return Response.redirect(location, 302) + } + + } + // If request not in kv, return 404 + return new Response(html404, { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + status: 404 + }) +} + + + +addEventListener("fetch", async event => { + event.respondWith(handleRequest(event.request)) +}) diff --git a/language/Korea/index.html b/language/Korea/index.html new file mode 100644 index 00000000..2dd34c53 --- /dev/null +++ b/language/Korea/index.html @@ -0,0 +1,110 @@ + + + + + + +입력한 주소를 찾을 수 없습니다.
+` + +let response_header={ + "content-type": "text/html;charset=UTF-8", +} + +if (config.cors=="on"){ + response_header={ + "content-type": "text/html;charset=UTF-8", + "Access-Control-Allow-Origin":"*", + "Access-Control-Allow-Methods": "POST", + } +} + +async function randomString(len) { + len = len || 6; + let $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/ + let maxPos = $chars.length; + let result = ''; + for (i = 0; i < len; i++) { + result += $chars.charAt(Math.floor(Math.random() * maxPos)); + } + return result; +} + +async function sha512(url){ + url = new TextEncoder().encode(url) + + const url_digest = await crypto.subtle.digest( + { + name: "SHA-512", + }, + url, // The data you want to hash as an ArrayBuffer + ) + const hashArray = Array.from(new Uint8Array(url_digest)); // convert buffer to byte array + const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); + //console.log(hashHex) + return hashHex +} +async function checkURL(URL){ + let str=URL; + let Expression=/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/; + let objExp=new RegExp(Expression); + if(objExp.test(str)==true){ + if (str[0] == 'h') + return true; + else + return false; + }else{ + return false; + } +} +async function save_url(URL){ + let random_key=await randomString() + let is_exist=await LINKS.get(random_key) + console.log(is_exist) + if (is_exist == null) + return await LINKS.put(random_key, URL),random_key + else + save_url(URL) +} +async function is_url_exist(url_sha512){ + let is_exist = await LINKS.get(url_sha512) + console.log(is_exist) + if (is_exist == null) { + return false + }else{ + return is_exist + } +} +async function is_url_safe(url){ + + let raw = JSON.stringify({"client":{"clientId":"Url-Shorten-Worker","clientVersion":"1.0.7"},"threatInfo":{"threatTypes":["MALWARE","SOCIAL_ENGINEERING","POTENTIALLY_HARMFUL_APPLICATION","UNWANTED_SOFTWARE"],"platformTypes":["ANY_PLATFORM"],"threatEntryTypes":["URL"],"threatEntries":[{"url":url}]}}); + + let requestOptions = { + method: 'POST', + body: raw, + redirect: 'follow' + }; + + result = await fetch("https://safebrowsing.googleapis.com/v4/threatMatches:find?key="+config.safe_browsing_api_key, requestOptions) + result = await result.json() + console.log(result) + if (Object.keys(result).length === 0){ + return true + }else{ + return false + } +} +async function handleRequest(request) { + console.log(request) + if (request.method === "POST") { + let req=await request.json() + console.log(req["url"]) + if(!await checkURL(req["url"])){ + return new Response(`{"status":500,"key":": 오류: Url 정보가 사기성이거나 바이러스가 있거나 올바르지 않습니다."}`, { + headers: response_header, + })} + let stat,random_key + if (config.unique_link){ + let url_sha512 = await sha512(req["url"]) + let url_key = await is_url_exist(url_sha512) + if(url_key){ + random_key = url_key + }else{ + stat,random_key=await save_url(req["url"]) + if (typeof(stat) == "undefined"){ + console.log(await LINKS.put(url_sha512,random_key)) + } + } + }else{ + stat,random_key=await save_url(req["url"]) + } + console.log(stat) + if (typeof(stat) == "undefined"){ + return new Response(`{"status":200,"key":"/`+random_key+`"}`, { + headers: response_header, + }) + }else{ + return new Response(`{"status":200,"key":": Error:Reach the KV write limitation."}`, { + headers: response_header, + })} + }else if(request.method === "OPTIONS"){ + return new Response(``, { + headers: response_header, + }) + + } + + const requestURL = new URL(request.url) + const path = requestURL.pathname.split("/")[1] + const params = requestURL.search; + + console.log(path) + if(!path){ + + const html= await fetch("https://tira-tw.github.io/korea-url/"+config.theme+"/index.html") + + return new Response(await html.text(), { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + }) + } + + const value = await LINKS.get(path); + let location ; + + if(params) { + location = value + params + } else { + location = value + } + console.log(value) + + + if (location) { + if (config.safe_browsing_api_key){ + if(!(await is_url_safe(location))){ + let warning_page = await fetch("https://xytom.github.io/Url-Shorten-Worker/safe-browsing.html") + warning_page =await warning_page.text() + warning_page = warning_page.replace(/{Replace}/gm, location) + return new Response(warning_page, { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + }) + } + } + if (config.no_ref=="on"){ + let no_ref= await fetch("https://xytom.github.io/Url-Shorten-Worker/no-ref.html") + no_ref=await no_ref.text() + no_ref=no_ref.replace(/{Replace}/gm, location) + return new Response(no_ref, { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + }) + }else{ + return Response.redirect(location, 302) + } + + } + // If request not in kv, return 404 + return new Response(html404, { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + status: 404 + }) +} + + + +addEventListener("fetch", async event => { + event.respondWith(handleRequest(event.request)) +}) diff --git "a/language/Korea/\354\204\244\354\240\225\355\225\230\353\212\224 \353\260\251\353\262\225.md" "b/language/Korea/\354\204\244\354\240\225\355\225\230\353\212\224 \353\260\251\353\262\225.md" new file mode 100644 index 00000000..5ce5857a --- /dev/null +++ "b/language/Korea/\354\204\244\354\240\225\355\225\230\353\212\224 \353\260\251\353\262\225.md" @@ -0,0 +1,2 @@ +index.js No.151의 링크를 다음 내용으로 변경합니다: +`https://tira-tw.github.io/korea-url/"+config.theme+"/index.html` diff --git a/language/Philippines/Paano i-set.md b/language/Philippines/Paano i-set.md new file mode 100644 index 00000000..d4835802 --- /dev/null +++ b/language/Philippines/Paano i-set.md @@ -0,0 +1,2 @@ +Baguhin ang link sa index.js No.151 sa sumusunod na nilalaman:Ang url na binibisita mo ay hindi nahanap.
+ gusto gumawa ng pareho? click! +` + +let response_header={ + "content-type": "text/html;charset=UTF-8", +} + +if (config.cors=="on"){ + response_header={ + "content-type": "text/html;charset=UTF-8", + "Access-Control-Allow-Origin":"*", + "Access-Control-Allow-Methods": "POST", + } +} + +async function randomString(len) { + len = len || 6; + let $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/ + let maxPos = $chars.length; + let result = ''; + for (i = 0; i < len; i++) { + result += $chars.charAt(Math.floor(Math.random() * maxPos)); + } + return result; +} + +async function sha512(url){ + url = new TextEncoder().encode(url) + + const url_digest = await crypto.subtle.digest( + { + name: "SHA-512", + }, + url, // The data you want to hash as an ArrayBuffer + ) + const hashArray = Array.from(new Uint8Array(url_digest)); // convert buffer to byte array + const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); + //console.log(hashHex) + return hashHex +} +async function checkURL(URL){ + let str=URL; + let Expression=/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/; + let objExp=new RegExp(Expression); + if(objExp.test(str)==true){ + if (str[0] == 'h') + return true; + else + return false; + }else{ + return false; + } +} +async function save_url(URL){ + let random_key=await randomString() + let is_exist=await LINKS.get(random_key) + console.log(is_exist) + if (is_exist == null) + return await LINKS.put(random_key, URL),random_key + else + save_url(URL) +} +async function is_url_exist(url_sha512){ + let is_exist = await LINKS.get(url_sha512) + console.log(is_exist) + if (is_exist == null) { + return false + }else{ + return is_exist + } +} +async function is_url_safe(url){ + + let raw = JSON.stringify({"client":{"clientId":"Url-Shorten-Worker","clientVersion":"1.0.7"},"threatInfo":{"threatTypes":["MALWARE","SOCIAL_ENGINEERING","POTENTIALLY_HARMFUL_APPLICATION","UNWANTED_SOFTWARE"],"platformTypes":["ANY_PLATFORM"],"threatEntryTypes":["URL"],"threatEntries":[{"url":url}]}}); + + let requestOptions = { + method: 'POST', + body: raw, + redirect: 'follow' + }; + + result = await fetch("https://safebrowsing.googleapis.com/v4/threatMatches:find?key="+config.safe_browsing_api_key, requestOptions) + result = await result.json() + console.log(result) + if (Object.keys(result).length === 0){ + return true + }else{ + return false + } +} +async function handleRequest(request) { + console.log(request) + if (request.method === "POST") { + let req=await request.json() + console.log(req["url"]) + if(!await checkURL(req["url"])){ + return new Response(`{"status":500,"key":": Error: Ang impormasyon ng Url ay maaaring website ng isda o virus o hindi ang url na ito"}`, { + headers: response_header, + })} + let stat,random_key + if (config.unique_link){ + let url_sha512 = await sha512(req["url"]) + let url_key = await is_url_exist(url_sha512) + if(url_key){ + random_key = url_key + }else{ + stat,random_key=await save_url(req["url"]) + if (typeof(stat) == "undefined"){ + console.log(await LINKS.put(url_sha512,random_key)) + } + } + }else{ + stat,random_key=await save_url(req["url"]) + } + console.log(stat) + if (typeof(stat) == "undefined"){ + return new Response(`{"status":200,"key":"/`+random_key+`"}`, { + headers: response_header, + }) + }else{ + return new Response(`{"status":200,"key":": Error:Reach the KV write limitation."}`, { + headers: response_header, + })} + }else if(request.method === "OPTIONS"){ + return new Response(``, { + headers: response_header, + }) + + } + + const requestURL = new URL(request.url) + const path = requestURL.pathname.split("/")[1] + const params = requestURL.search; + + console.log(path) + if(!path){ + + const html= await fetch("https://tira-tw.github.io/philippines-url/"+config.theme+"/index.html") + + return new Response(await html.text(), { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + }) + } + + const value = await LINKS.get(path); + let location ; + + if(params) { + location = value + params + } else { + location = value + } + console.log(value) + + + if (location) { + if (config.safe_browsing_api_key){ + if(!(await is_url_safe(location))){ + let warning_page = await fetch("https://xytom.github.io/Url-Shorten-Worker/safe-browsing.html") + warning_page =await warning_page.text() + warning_page = warning_page.replace(/{Replace}/gm, location) + return new Response(warning_page, { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + }) + } + } + if (config.no_ref=="on"){ + let no_ref= await fetch("https://xytom.github.io/Url-Shorten-Worker/no-ref.html") + no_ref=await no_ref.text() + no_ref=no_ref.replace(/{Replace}/gm, location) + return new Response(no_ref, { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + }) + }else{ + return Response.redirect(location, 302) + } + + } + // If request not in kv, return 404 + return new Response(html404, { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + status: 404 + }) +} + + + +addEventListener("fetch", async event => { + event.respondWith(handleRequest(event.request)) +}) diff --git a/language/README.md b/language/README.md new file mode 100644 index 00000000..2b62b589 --- /dev/null +++ b/language/README.md @@ -0,0 +1,24 @@ +[Discord](https://discord.gg/xDeaneQMj9)Link bạn truy cập không được tìm thấy
+ Muốn làm một cái tương tự? Nhấn vào! +` + +let response_header={ + "content-type": "text/html;charset=UTF-8", +} + +if (config.cors=="on"){ + response_header={ + "content-type": "text/html;charset=UTF-8", + "Access-Control-Allow-Origin":"*", + "Access-Control-Allow-Methods": "POST", + } +} + +async function randomString(len) { + len = len || 6; + let $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/ + let maxPos = $chars.length; + let result = ''; + for (i = 0; i < len; i++) { + result += $chars.charAt(Math.floor(Math.random() * maxPos)); + } + return result; +} + +async function sha512(url){ + url = new TextEncoder().encode(url) + + const url_digest = await crypto.subtle.digest( + { + name: "SHA-512", + }, + url, // The data you want to hash as an ArrayBuffer + ) + const hashArray = Array.from(new Uint8Array(url_digest)); // convert buffer to byte array + const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); + //console.log(hashHex) + return hashHex +} +async function checkURL(URL){ + let str=URL; + let Expression=/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/; + let objExp=new RegExp(Expression); + if(objExp.test(str)==true){ + if (str[0] == 'h') + return true; + else + return false; + }else{ + return false; + } +} +async function save_url(URL){ + let random_key=await randomString() + let is_exist=await LINKS.get(random_key) + console.log(is_exist) + if (is_exist == null) + return await LINKS.put(random_key, URL),random_key + else + save_url(URL) +} +async function is_url_exist(url_sha512){ + let is_exist = await LINKS.get(url_sha512) + console.log(is_exist) + if (is_exist == null) { + return false + }else{ + return is_exist + } +} +async function is_url_safe(url){ + + let raw = JSON.stringify({"client":{"clientId":"Url-Shorten-Worker","clientVersion":"1.0.7"},"threatInfo":{"threatTypes":["MALWARE","SOCIAL_ENGINEERING","POTENTIALLY_HARMFUL_APPLICATION","UNWANTED_SOFTWARE"],"platformTypes":["ANY_PLATFORM"],"threatEntryTypes":["URL"],"threatEntries":[{"url":url}]}}); + + let requestOptions = { + method: 'POST', + body: raw, + redirect: 'follow' + }; + + result = await fetch("https://safebrowsing.googleapis.com/v4/threatMatches:find?key="+config.safe_browsing_api_key, requestOptions) + result = await result.json() + console.log(result) + if (Object.keys(result).length === 0){ + return true + }else{ + return false + } +} +async function handleRequest(request) { + console.log(request) + if (request.method === "POST") { + let req=await request.json() + console.log(req["url"]) + if(!await checkURL(req["url"])){ + return new Response(`{"status":500,"key":": Lỗi: thông tin về link là web lậu hoặc virus hoặc không phải link này"}`, { + headers: response_header, + })} + let stat,random_key + if (config.unique_link){ + let url_sha512 = await sha512(req["url"]) + let url_key = await is_url_exist(url_sha512) + if(url_key){ + random_key = url_key + }else{ + stat,random_key=await save_url(req["url"]) + if (typeof(stat) == "undefined"){ + console.log(await LINKS.put(url_sha512,random_key)) + } + } + }else{ + stat,random_key=await save_url(req["url"]) + } + console.log(stat) + if (typeof(stat) == "undefined"){ + return new Response(`{"status":200,"key":"/`+random_key+`"}`, { + headers: response_header, + }) + }else{ + return new Response(`{"status":200,"key":": Error:Reach the KV write limitation."}`, { + headers: response_header, + })} + }else if(request.method === "OPTIONS"){ + return new Response(``, { + headers: response_header, + }) + + } + + const requestURL = new URL(request.url) + const path = requestURL.pathname.split("/")[1] + const params = requestURL.search; + + console.log(path) + if(!path){ + + const html= await fetch("https://tira-tw.github.io/vietnam-url/"+config.theme+"/index.html") + + return new Response(await html.text(), { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + }) + } + + const value = await LINKS.get(path); + let location ; + + if(params) { + location = value + params + } else { + location = value + } + console.log(value) + + + if (location) { + if (config.safe_browsing_api_key){ + if(!(await is_url_safe(location))){ + let warning_page = await fetch("https://xytom.github.io/Url-Shorten-Worker/safe-browsing.html") + warning_page =await warning_page.text() + warning_page = warning_page.replace(/{Replace}/gm, location) + return new Response(warning_page, { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + }) + } + } + if (config.no_ref=="on"){ + let no_ref= await fetch("https://xytom.github.io/Url-Shorten-Worker/no-ref.html") + no_ref=await no_ref.text() + no_ref=no_ref.replace(/{Replace}/gm, location) + return new Response(no_ref, { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + }) + }else{ + return Response.redirect(location, 302) + } + + } + // If request not in kv, return 404 + return new Response(html404, { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + status: 404 + }) +} + + + +addEventListener("fetch", async event => { + event.respondWith(handleRequest(event.request)) +}) diff --git a/language/chinese-zh-cn/index.html b/language/chinese-zh-cn/index.html new file mode 100644 index 00000000..f0be2982 --- /dev/null +++ b/language/chinese-zh-cn/index.html @@ -0,0 +1,111 @@ + + + + + + +您的提供的网址无法搜寻!,请确定是否正确.
+ 是否想制作一个? 点击我! +` + +let response_header={ + "content-type": "text/html;charset=UTF-8", +} + +if (config.cors=="on"){ + response_header={ + "content-type": "text/html;charset=UTF-8", + "Access-Control-Allow-Origin":"*", + "Access-Control-Allow-Methods": "POST", + } +} + +async function randomString(len) { + len = len || 6; + let $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/ + let maxPos = $chars.length; + let result = ''; + for (i = 0; i < len; i++) { + result += $chars.charAt(Math.floor(Math.random() * maxPos)); + } + return result; +} + +async function sha512(url){ + url = new TextEncoder().encode(url) + + const url_digest = await crypto.subtle.digest( + { + name: "SHA-512", + }, + url, // The data you want to hash as an ArrayBuffer + ) + const hashArray = Array.from(new Uint8Array(url_digest)); // convert buffer to byte array + const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); + //console.log(hashHex) + return hashHex +} +async function checkURL(URL){ + let str=URL; + let Expression=/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/; + let objExp=new RegExp(Expression); + if(objExp.test(str)==true){ + if (str[0] == 'h') + return true; + else + return false; + }else{ + return false; + } +} +async function save_url(URL){ + let random_key=await randomString() + let is_exist=await LINKS.get(random_key) + console.log(is_exist) + if (is_exist == null) + return await LINKS.put(random_key, URL),random_key + else + save_url(URL) +} +async function is_url_exist(url_sha512){ + let is_exist = await LINKS.get(url_sha512) + console.log(is_exist) + if (is_exist == null) { + return false + }else{ + return is_exist + } +} +async function is_url_safe(url){ + + let raw = JSON.stringify({"client":{"clientId":"Url-Shorten-Worker","clientVersion":"1.0.7"},"threatInfo":{"threatTypes":["MALWARE","SOCIAL_ENGINEERING","POTENTIALLY_HARMFUL_APPLICATION","UNWANTED_SOFTWARE"],"platformTypes":["ANY_PLATFORM"],"threatEntryTypes":["URL"],"threatEntries":[{"url":url}]}}); + + let requestOptions = { + method: 'POST', + body: raw, + redirect: 'follow' + }; + + result = await fetch("https://safebrowsing.googleapis.com/v4/threatMatches:find?key="+config.safe_browsing_api_key, requestOptions) + result = await result.json() + console.log(result) + if (Object.keys(result).length === 0){ + return true + }else{ + return false + } +} +async function handleRequest(request) { + console.log(request) + if (request.method === "POST") { + let req=await request.json() + console.log(req["url"]) + if(!await checkURL(req["url"])){ + return new Response(`{"status":500,"key":": 错误! 你提供的网址可能是钓鱼网站/病毒/不存在!"}`, { + headers: response_header, + })} + let stat,random_key + if (config.unique_link){ + let url_sha512 = await sha512(req["url"]) + let url_key = await is_url_exist(url_sha512) + if(url_key){ + random_key = url_key + }else{ + stat,random_key=await save_url(req["url"]) + if (typeof(stat) == "undefined"){ + console.log(await LINKS.put(url_sha512,random_key)) + } + } + }else{ + stat,random_key=await save_url(req["url"]) + } + console.log(stat) + if (typeof(stat) == "undefined"){ + return new Response(`{"status":200,"key":"/`+random_key+`"}`, { + headers: response_header, + }) + }else{ + return new Response(`{"status":200,"key":": Error:Reach the KV write limitation."}`, { + headers: response_header, + })} + }else if(request.method === "OPTIONS"){ + return new Response(``, { + headers: response_header, + }) + + } + + const requestURL = new URL(request.url) + const path = requestURL.pathname.split("/")[1] + const params = requestURL.search; + + console.log(path) + if(!path){ + + const html= await fetch("https://tira-tw.github.io/china-url/"+config.theme+"/index.html") + + return new Response(await html.text(), { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + }) + } + + const value = await LINKS.get(path); + let location ; + + if(params) { + location = value + params + } else { + location = value + } + console.log(value) + + + if (location) { + if (config.safe_browsing_api_key){ + if(!(await is_url_safe(location))){ + let warning_page = await fetch("https://xytom.github.io/Url-Shorten-Worker/safe-browsing.html") + warning_page =await warning_page.text() + warning_page = warning_page.replace(/{Replace}/gm, location) + return new Response(warning_page, { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + }) + } + } + if (config.no_ref=="on"){ + let no_ref= await fetch("https://xytom.github.io/Url-Shorten-Worker/no-ref.html") + no_ref=await no_ref.text() + no_ref=no_ref.replace(/{Replace}/gm, location) + return new Response(no_ref, { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + }) + }else{ + return Response.redirect(location, 302) + } + + } + // If request not in kv, return 404 + return new Response(html404, { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + status: 404 + }) +} + + + +addEventListener("fetch", async event => { + event.respondWith(handleRequest(event.request)) +}) diff --git "a/language/chinese-zh-cn/\345\246\202\344\275\225\350\256\276\345\256\232.md" "b/language/chinese-zh-cn/\345\246\202\344\275\225\350\256\276\345\256\232.md" new file mode 100644 index 00000000..25331a5f --- /dev/null +++ "b/language/chinese-zh-cn/\345\246\202\344\275\225\350\256\276\345\256\232.md" @@ -0,0 +1,2 @@ +index.js第151中间的连结改掉以下:您的提供的網址無法搜尋!,請確定是否正確.
+ 是否想製作一個? 點擊我! +` + +let response_header={ + "content-type": "text/html;charset=UTF-8", +} + +if (config.cors=="on"){ + response_header={ + "content-type": "text/html;charset=UTF-8", + "Access-Control-Allow-Origin":"*", + "Access-Control-Allow-Methods": "POST", + } +} + +async function randomString(len) { + len = len || 6; + let $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/ + let maxPos = $chars.length; + let result = ''; + for (i = 0; i < len; i++) { + result += $chars.charAt(Math.floor(Math.random() * maxPos)); + } + return result; +} + +async function sha512(url){ + url = new TextEncoder().encode(url) + + const url_digest = await crypto.subtle.digest( + { + name: "SHA-512", + }, + url, // The data you want to hash as an ArrayBuffer + ) + const hashArray = Array.from(new Uint8Array(url_digest)); // convert buffer to byte array + const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); + //console.log(hashHex) + return hashHex +} +async function checkURL(URL){ + let str=URL; + let Expression=/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/; + let objExp=new RegExp(Expression); + if(objExp.test(str)==true){ + if (str[0] == 'h') + return true; + else + return false; + }else{ + return false; + } +} +async function save_url(URL){ + let random_key=await randomString() + let is_exist=await LINKS.get(random_key) + console.log(is_exist) + if (is_exist == null) + return await LINKS.put(random_key, URL),random_key + else + save_url(URL) +} +async function is_url_exist(url_sha512){ + let is_exist = await LINKS.get(url_sha512) + console.log(is_exist) + if (is_exist == null) { + return false + }else{ + return is_exist + } +} +async function is_url_safe(url){ + + let raw = JSON.stringify({"client":{"clientId":"Url-Shorten-Worker","clientVersion":"1.0.7"},"threatInfo":{"threatTypes":["MALWARE","SOCIAL_ENGINEERING","POTENTIALLY_HARMFUL_APPLICATION","UNWANTED_SOFTWARE"],"platformTypes":["ANY_PLATFORM"],"threatEntryTypes":["URL"],"threatEntries":[{"url":url}]}}); + + let requestOptions = { + method: 'POST', + body: raw, + redirect: 'follow' + }; + + result = await fetch("https://safebrowsing.googleapis.com/v4/threatMatches:find?key="+config.safe_browsing_api_key, requestOptions) + result = await result.json() + console.log(result) + if (Object.keys(result).length === 0){ + return true + }else{ + return false + } +} +async function handleRequest(request) { + console.log(request) + if (request.method === "POST") { + let req=await request.json() + console.log(req["url"]) + if(!await checkURL(req["url"])){ + return new Response(`{"status":500,"key":": 錯誤! 你提供的網址可能是釣魚網站/病毒/不存在!"}`, { + headers: response_header, + })} + let stat,random_key + if (config.unique_link){ + let url_sha512 = await sha512(req["url"]) + let url_key = await is_url_exist(url_sha512) + if(url_key){ + random_key = url_key + }else{ + stat,random_key=await save_url(req["url"]) + if (typeof(stat) == "undefined"){ + console.log(await LINKS.put(url_sha512,random_key)) + } + } + }else{ + stat,random_key=await save_url(req["url"]) + } + console.log(stat) + if (typeof(stat) == "undefined"){ + return new Response(`{"status":200,"key":"/`+random_key+`"}`, { + headers: response_header, + }) + }else{ + return new Response(`{"status":200,"key":": Error:Reach the KV write limitation."}`, { + headers: response_header, + })} + }else if(request.method === "OPTIONS"){ + return new Response(``, { + headers: response_header, + }) + + } + + const requestURL = new URL(request.url) + const path = requestURL.pathname.split("/")[1] + const params = requestURL.search; + + console.log(path) + if(!path){ + + const html= await fetch("https://tira-tw.github.io/taiwan-url/"+config.theme+"/index.html") + + return new Response(await html.text(), { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + }) + } + + const value = await LINKS.get(path); + let location ; + + if(params) { + location = value + params + } else { + location = value + } + console.log(value) + + + if (location) { + if (config.safe_browsing_api_key){ + if(!(await is_url_safe(location))){ + let warning_page = await fetch("https://xytom.github.io/Url-Shorten-Worker/safe-browsing.html") + warning_page =await warning_page.text() + warning_page = warning_page.replace(/{Replace}/gm, location) + return new Response(warning_page, { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + }) + } + } + if (config.no_ref=="on"){ + let no_ref= await fetch("https://xytom.github.io/Url-Shorten-Worker/no-ref.html") + no_ref=await no_ref.text() + no_ref=no_ref.replace(/{Replace}/gm, location) + return new Response(no_ref, { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + }) + }else{ + return Response.redirect(location, 302) + } + + } + // If request not in kv, return 404 + return new Response(html404, { + headers: { + "content-type": "text/html;charset=UTF-8", + }, + status: 404 + }) +} + + + +addEventListener("fetch", async event => { + event.respondWith(handleRequest(event.request)) +}) diff --git "a/language/chinese-zh-tw/\345\246\202\344\275\225\350\250\255\345\256\232.md" "b/language/chinese-zh-tw/\345\246\202\344\275\225\350\250\255\345\256\232.md" new file mode 100644 index 00000000..ace913f9 --- /dev/null +++ "b/language/chinese-zh-tw/\345\246\202\344\275\225\350\250\255\345\256\232.md" @@ -0,0 +1,2 @@ +index.js第151中間的連結改掉以下: