源码 GitHub https://github.com/crazypeace/Url-Shorten-Worker
演示站 https://urlsrv.crazypeace.workers.dev/bodongshouqulveweifengci
申请Cloudflare账号,略。
创建一个KV
记得这个KV的名字,以 urlsrv 为例
https://blogger.googleusercontent.com/img/a/AVvXsEjebnhhOSRKgzvkla6s7hLBCSHe2slJpr1hf-DoNrXWNJIH6RCTLyoA5cJA2s4mQuTYxSfsZduWFOAH6jN-NfqbIak4wJImRpDsCOopdX6FA7kbiDZRwn10pZZZWERZ3K0y7Btqi9Chl79_Rn5g2opntlmiXkMVIDRnVuz0Eis6AXT8cCTZdMuSMOwg
查看此KV
https://blogger.googleusercontent.com/img/a/AVvXsEhBUJuZnhvq_cBbkx1gUw0D4R___9xhJRwJbVDS0WZY5J6iaNB4xOpYpjtLME1182MWIb1-sHHMtK6wLhMz-YxtMknUE7iVGr4zyWKqLbCNLeO_sh_ePMIwH-lCL19Dvbdc1S8npBaWi5r5V51CvyLSKFoM9CTM_ddCfJeBod2K6OKfaxU-arpfgVx7
添加一个条目Entry
密钥key为password,值value为一个随机字符串.
* password这个key是在脚本中要引用的,所以要设置这个。
随机字符串可以使用http://git.io/xkcdpw生成
随机字符串以 yejiandianci 为例
https://blogger.googleusercontent.com/img/a/AVvXsEhfciJWtH4Bi106WPz83oSYbZ79PX9gCXkvsJUYPn97FP_WCSj7_wXhIu2Tio8rIywZQ5B1pRRpkI52uMOplpF6q5XQCWkGZK-zIvqgFYlRzDkePaf-LpgafJNZ0cUAz5kFsZ2B6msMY98lHA0flGy_TM_euMpTVBeJMFxgcnKj84AeGqDUJVU21Ulw
创建Worker服务
https://blogger.googleusercontent.com/img/a/AVvXsEiLc3UMWhDYvcSGYsJse4r1h-hbBhYt-V7MzOe6Tzl1it7YUsmmAYpEneGbZZ9P-2tVB7BkGY2bSUZGdX99eDACGRK-P1FSzb7NDBkvXsdxdTFkUifP5t6M3q-gB2EMJX-KlW-OWxSaKKQVMcP1MiGpMHieFef38rPa_Qe37lW401ZQub4aRnPgXZdt
https://blogger.googleusercontent.com/img/a/AVvXsEgwkVtGRGWmzk-lDr29-GEVYWp6tvReRugVH1bKU7QKkcfaJGmDqJTW9A9eu_dKtm2Qa9-WAU67VogNd072-g9hEBe6bR8jEmmqeDm9LekHhnf_7SyBeUgNCHLzTRSsPCMvH0-EuTMbNxIeFo2xtrqbnmH2JWcBYkk3mHyGpyd036h_LCPuSC1zX4Mx
设置绑定KV
https://blogger.googleusercontent.com/img/a/AVvXsEg_2uH-69uno099gSqDipIjI-6aKD0EH_vmAMEV58UDz87FWlThVpKLHQxV7XiOxRxMHViPjAynoifkko7jsophtQuS9p7AgAAZ-hRVeNjcuyRRQ3UlU3Rbp3-5D22ZVvu3Sqe3mff4k0qQRTwvCSL3xgzZqbHG0GwQTzD9HGOQAZDajhJpGPJt-8ZI
https://blogger.googleusercontent.com/img/a/AVvXsEgxXF5orTn9cYMB_XccuNbJ64A5Q0y1DWL1wEMpuO-SlccHKLUPR79eI-ZfL1ZnXSoww7-LQcokGa1vj_-6ig8qRK2z-TEZkmsYCp-43oMKaOH6_R7MAPIIAmYwP5ZYtDPtMo-W1munfYkINBhAxA7g1sq53e9K8KTzkgbEeMsWeEdYw-zXscTsTOHB
变量名称必须设置为 LINKS, KV的名字选刚刚创建的 urlsrv* LINKS 是在脚本中要引用的,所以要设置这个。换句话说,如果你使用别的脚本,可能这个变量名称就不是LINKS了。
编辑Worker的脚本
https://blogger.googleusercontent.com/img/a/AVvXsEiZsgUcVCEgCMPntaeOxGVW4vUMdsR3vrjdyZPnanWkzBfPveGi2b_cIAmazyvkvdRLCWxqgyTBsEpjIW8QGXYRjTKgKWQ2u7FQok9SEfywOMaX9sYOTxAWzoxkmc0Bputj4pG_Dc6ZEmUhyrAoa-POYnL05HoQu5mYcwcK7DerVjkRLw_BDart1DIX
把原有的内容全部删掉
https://blogger.googleusercontent.com/img/a/AVvXsEhQDPoDkOnEBdU5XYRu3HqsgltaYbm5mFAHW156M_mipznfuktozLpKwb-3Wx-h3jkQBRGUCtiZL1Yt2NylmaGJ7unYlYJc1UvfBDhNXZbkzOz4UcuUJE9DTpPW5kMGxcC1pw9VFz1T9_xqCILShmsyfqnFYxhzi0LEJBkilQch7vGt0gs9FpaFhtDI
换成:https://github.com/crazypeace/Url-Shorten-Worker/blob/main/worker.js 的内容
保存并部署
https://blogger.googleusercontent.com/img/a/AVvXsEjC_7tMH4LcpVUlggbN8k8yg1GMa1zfHIle5htJDmhCCHY8Nt0mZ_mjp1-oqQnSulpE2suMxYdDLB-ZZyiRzlo7ff_DFjUKO1EQV_aBjKtqkZ_RzTDDAyDBp8DYfB7yK9lr0FM6rjhN1dR09Qpz7T1_lbtjLBU2FzA7MpvMvNr0aFYTXqoJvBeZYaPg
======
完
要访问 你的worker域名/yejiandianci 来打开使用页面
如:https://snowy-disk-fd82.ciys.workers.dev/yejiandianci
======
后记
你可以通过在你自己的域名下worker页面添加一个路由指向worker的方式来实现比如 https://1way.eu.org/mtSzm6 替代 snowy-disk-fd82.ciys.workers.dev/yejiandianci 的效果。
======
配置参数的作用
const config ={ result_page:false,// After get the value from KV, if use a page to show the result. theme: "", // Homepage theme, use the empty value for default theme. To use urlcool theme, please fill with "theme/urlcool" . cors: true, // Allow Cross-origin resource sharing for API requests. unique_link: false, // 一个长链是否只有唯一的短链(会增加写入的使用量) custom_link: true, // 允许自定义短链 snapchat_mode: false, // 短链只能访问一次(访问后就删除了) visit_count: true, // 使用记数(会大大增加写入的使用量, 多人共用不推荐打开) load_kv: false, // 从KV加载全部数据(自用推荐打开, 多人共用会看到别人的数据) system_type: "shorturl", // shorturl, pastebin, imghost,}
======
如果要当网络记事本 PasteBin
演示站 https://pastebin.crazypeace.workers.dev/tieludasiliqiuweiyue
演示视频 https://www.youtube.com/watch?v=toBeb3DNpZc
https://blogger.googleusercontent.com/img/a/AVvXsEgsaF1ZEcOtF55asf7fy0Ofj-Lone0ZraAsJrN0IIWfaNFuPPjhK-tPtIzer-PwxViwJxXznmq31mfWj23EFS1LaKN-HKxdY5xnuhYGjryhGMdGBWqn8oFdWYvsfA6pGYrsMnOfklaRitRq0N7nsTCIxBQuSVccZTBwk_TDk03H6TrYmL1Wih_ya5mYQmM
======
如果要当图床 Image Hosting
演示站 https://imghost.crazypeace.workers.dev/imghostimghost
演示视频 https://www.youtube.com/watch?v=B7wH4tB1-O8
https://blogger.googleusercontent.com/img/a/AVvXsEjij-pG6wdpI6HhOrLK3GTUqzQRm-PCGY-jgbzTLn9DfwzVW9-HCWwEnwlHhSyxIRxDsDNleD9Mp2OFFWDCNsPPkhJSNdfsGembPL3G8UMVObUSgo7d6uT1KnJnEtxlMDlHFKYDabmTNiJgW90nmBZagptvKwAY3OEoPeiRFhGqU-s78ZBXpf_ntGSqeXU
======
如果要当网络日记本, 支持MarkDown
演示站 https://journal.crazypeace.workers.dev/journaljournal
演示视频 https://www.youtube.com/watch?v=DZcXqyIm_R0
https://www.youtube.com/watch?v=Ra6SXZFeGM8
https://blogger.googleusercontent.com/img/a/AVvXsEgQtWAW2Qp0r2oKeTrYDPDulFrRuvthLkkARqAQvgzcwFOiP6VqRtsoOQIYyz8J8q5dtbs1Am2I4Xzj4Qvq3VArZ0N_Lk46LeodVWC-YM86gAOfT6b8UzJq5_LipVKz-BzCMqAFqc3Fvl3O84i1OEpmxOF6WFrYx2YyAwO_rj3TWeYb6F171nG9XWaQb4w
======
如果要做一次性二维码
演示站 https://snapchat.crazypeace.workers.dev/huiyingebielianaiputi
https://blogger.googleusercontent.com/img/a/AVvXsEj1zeE7FgCARuR9ZbuYtV_SURngU8bRGgGlWCzWh9vXWPGBDjo9asJYxOhJxzmadK3rBDTBhqLqfZqQLm_OCVv9fH8Q7-yDOW9hUoV73vTUwiD63rM5PWfKWoIVA9dFlxlRA6O6eZZztvZzQiApH-Hq20MTGTSbrH8qQ5RlSbvm3zePQFxUMiYAoM8CP4E
======
开发记录
直接访问域名返回404。在KV中设置一个entry,保存秘密path,只有访问这个path才显示使用页面。
https://zelikk.blogspot.com/2022/07/url-shorten-worker-hide-tutorial.html
支持自定义短链
https://zelikk.blogspot.com/2022/07/url-shorten-worker-custom.html
API 不公开服务
https://zelikk.blogspot.com/2022/07/url-shorten-worker-api-password.html
页面缓存设置过的短链
https://zelikk.blogspot.com/2022/08/url-shorten-worker-localstorage.html
长链接文本框预搜索localStorage
https://zelikk.blogspot.com/2022/08/url-shorten-worker-bootstrap-list-group-oninput.html
增加删除某条短链的按钮
https://zelikk.blogspot.com/2022/08/url-shorten-worker-delete-kv-localstorage.html
访问计数功能 可查询短链 成为功能完整的短链API系统
https://zelikk.blogspot.com/2023/11/url-shorten-worker-visit-count-api-api.html
阅后即焚功能, 可制作一次性二维码
https://zelikk.blogspot.com/2023/11/url-shorten-worker-snapchat-mode.html
增加读取 KV 中全部记录的功能
https://zelikk.blogspot.com/2024/01/url-shorten-worker-load-cloudflare-kv.html
变身网络记事本 Pastebin
https://zelikk.blogspot.com/2024/01/url-shorten-worker-pastebin.html
变身图床 Image Hosting
https://zelikk.blogspot.com/2024/01/url-shorten-worker-image-hosting-base64.html
变身日记本 NetJournal 支持Markdown
https://zelikk.blogspot.com/2024/02/url-shorten-worker-netjournal.html
https://zelikk.blogspot.com/2024/02/url-shorten-worker-netjournal-markdown.html
https://zelikk.blogspot.com/202
暂无评论内容