白嫖 worker 自建短链服务 Url-Shorten-Worker 支持自定义短链
源码 GitHub:
https://github.com/crazypeace/Url-Shorten-Worker
搭建方法:
https://zelikk.blogspot.com/2022/07/url-shorten-worker-hide-tutorial.html
支持自定义短链的修改思路:
gh-pages 分支下
index.html
<input type="text" class="form-customs-shorturl" placeholder="customs shorturl" id="customShortURL">
main.js
body: JSON.stringify({ url: document.querySelector("#text").value, customShortURL: document.querySelector("#customShortURL").value })
准备放到 worker 的脚本
获取
let req_customShortURL=req["customShortURL"]
增加自定义短链的处理
if (config.custom_link && (req_customShortURL != "")){let is_exist=await LINKS.get(req_customShortURL)if (is_exist != null) {return new Response(`{"status":500,"key":": Error: Custom shortURL existed."}`, {headers: response_header,})}else{random_key = req_customShortURLstat, await LINKS.put(req_customShortURL, req_url)}}
======
后记
在
https://gcore.jsdelivr.net/gh/crazypeace/Url-Shorten-Worker@gh-pages/main.js
最终修改为调用
https://crazypeace.github.io/Url-Shorten-Worker/main.js
当然,这样的调用方式墙内用不了。
我在
如果等到
const html= await fetch("https://crazypeace.github.io/Url-Shorten-Worker/"+config.theme+"/index-cdn.html")
评论
发表评论