其他
极路由4刷机
米沃奇 波箱保养
玩客云
玩客云刷第三方系统
玩客云-Home Assistant
服务器采购
RTL9210/RTL9210B
随身WiFi
固件备份与恢复
Debian
Debian-文件共享
Debian-物联网
Debian-授权
Debain-ZeroTier
Debian-自启动脚本
Debian-拓展内存
Debian-清理空间
Debian-USB控制
Debian-adb进9008
Debian-常见问题
Debian-快速使用
随身WiFi使用
切卡
快速找摄像头IP
edu教育邮箱申请
域名邮箱(转发)-Cloudflare
Web监控工具
WxPusher(微信消息推送)
WxPusher-API推送
WxPusher-Python推送
WxPusher-Shell推送
WxPusher-挪车通知
企业微信-应用
Godlike-免费游戏服务器
GitHub 国内访问(host)
常用螺丝替代型号
GitHub Actions
workflows-同步上游仓库(覆盖)
workflows-⭐同步上游仓库
workflows-构建 Docker镜像
FAT32不可读
Kindle
Kindle-救砖
Kindle-越狱
中国移动-RAX3000Q(Y)
OpenWrt
网络奇葩问题
小米手环_BandTOTP
本文档使用 MrDoc 发布
-
+
首页
WxPusher-挪车通知
**相关链接:** - 在线 Javascript 混淆加密:https://www.lddgo.net/encrypt/js - 草料二维码:https://cli.im/url ## Workers 部署(CloudFlare) 1. 配置 [WxPusher](/doc/777/) 创建应用,并获取 AppToken 和 需要通知对象的UID 2. 在 [CloudFlare](https://dash.cloudflare.com/) `Workers 和 Pages` 创建一个 Worker 项目 3. 复制 [下方项目代码](#自制改版) 修改并覆盖原Worker代码 4. 保存并部署 测试是否可以正常使用 5. 绑定自己域名 `Worker 项目——触发器——自定义域——添加自定义域`,添加你需要设置的域名 测试是否可以正常使用 6. 使用 Javascript 混淆加密 保护相关信息 Worker全部代码,混淆模式使用 默认,加密后覆盖回Worker 测试是否可以正常使用 7. 网址转换为二维码,扫描使用更加便捷 ## 仅电话 主要解决电话直接显示问题,扫描跳转点击拨号 使用方式:`https://movethecar.918178.xyz/?tel=xxx` 通过 `tel=xxx` 进行传递号码,访问自动拨号 ```js // 增加了最基本的验证(有英文肯定不是号码,因为可能会有电话的需求,故不作位数限制) addEventListener('fetch', event => { event.respondWith(handleRequest(event.request)) }) function handleRequest(request) { // 解析请求URL中的查询参数 const url = new URL(request.url) const phoneNumber = url.searchParams.get('tel') // 检查是否获取到了电话号码 if (phoneNumber) { // 正则表达式,用于检查是否为纯数字 const regex = /^\d+$/; // 检查电话号码是否为纯数字 if (regex.test(phoneNumber)) { // 创建一个JavaScript响应,当在客户端执行时,会尝试拨打电话 // 生成HTML内容 const htmlContent = ` <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>通知车主挪车</title> <style> * { box-sizing: border-box; margin: 0; padding: 0; } body { font-family: Arial, sans-serif; display: flex; align-items: center; justify-content: center; height: 100vh; background: #f0f2f5; color: #333; } .container { text-align: center; padding: 20px; width: 100%; max-width: 400px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); background: #fff; } h1 { font-size: 24px; margin-bottom: 20px; color: #007bff; } p { margin-bottom: 20px; font-size: 16px; color: #555; } button { width: 100%; padding: 15px; margin: 10px 0; font-size: 18px; font-weight: bold; color: #fff; border: none; border-radius: 6px; cursor: pointer; transition: background 0.3s; } .notify-btn { background: #28a745; } .notify-btn:hover { background: #218838; } .call-btn { background: #17a2b8; } .call-btn:hover { background: #138496; } </style> </head> <body> <div class="container"> <h1>通知车主挪车</h1> <p>如需通知车主,请点击以下按钮</p> <button class="call-btn" onclick="callOwner()">⭐拨打车主电话⭐</button> </div> <script> // 拨打车主电话 function callOwner() { window.location.href = 'tel:${encodeURIComponent(phoneNumber)}'; } </script> </body> </html> ` return new Response(htmlContent, { headers: { 'Content-Type': 'text/html; charset=UTF-8', }, }); } else { // 如果电话号码不是纯数字,返回错误信息 return new Response('提供的电话号码不是有效的数字', { status: 400, headers: { 'Content-Type': 'text/plain; charset=UTF-8', }, }); } } else { // 如果没有电话号码,返回错误信息 return new Response('URL中没有提供电话号码', { status: 400, headers: { 'Content-Type': 'text/plain; charset=UTF-8', }, }); } } ``` ## 自制改版 较缙哥哥改版增加了优先消息通知,满足时间后才可电话通知(更换手机或是清空缓存则重新计时) ```js // 当有请求到达时,触发fetch事件,并响应handleRequest函数 addEventListener('fetch', event => { event.respondWith(handleRequest(event.request)) }) // 处理请求的异步函数 async function handleRequest(request) { // 定义配置参数,建议使用JavaScript混淆加密,但不能完全防止被破解 const phone = 'xxx'; // 车主的手机号 const wxpusherAppToken = 'AT_xxx'; // Wxpusher APP Token const wxpusherUIDs = ['UID_xxx','UID_xxx']; // 车主的UIDs(支持多个,用英文逗号分隔) const Intervals = 3; // 发送消息间隔时间(min) const PhoneDelay = 10; // 首次发送消息通知指定时间后可电话(min) const license = 'xxx'; // 牌照号 // 生成HTML内容 const htmlContent = ` <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>通知车主挪车</title> <style> * { box-sizing: border-box; margin: 0; padding: 0; } body { font-family: Arial, sans-serif; display: flex; align-items: center; justify-content: center; height: 100vh; background: #f0f2f5; color: #333; } .container { text-align: center; padding: 20px; width: 100%; max-width: 400px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); background: #fff; } h1 { font-size: 24px; margin-bottom: 20px; color: #007bff; } p { margin-bottom: 20px; font-size: 16px; color: #555; } button { width: 100%; padding: 15px; margin: 10px 0; font-size: 18px; font-weight: bold; color: #fff; border: none; border-radius: 6px; cursor: pointer; transition: background 0.3s; } .notify-btn { background: #28a745; } .notify-btn:hover { background: #218838; } .call-btn { background: #17a2b8; } .call-btn:hover { background: #138496; } </style> </head> <body> <div class="container"> <h1>${license}</h1> <p>如需通知车主,请点击以下按钮</p> <button class="notify-btn" onclick="notifyOwner()">⭐通知车主挪车⭐</button> <button class="call-btn" onclick="callOwner()">拨打车主电话</button> </div> <script> // 获取最后通知的时间戳,如果不存在则返回0 function getLastNotifyTime() { return localStorage.getItem('lastNotifyTime') || 0; } // 设置最后通知的时间戳 function setLastNotifyTime(time) { localStorage.setItem('lastNotifyTime', time); } // 记录首次通知时间戳 function setFirstNotificationTime() { const firstNotifyTime = localStorage.getItem('firstNotifyTime'); if (firstNotifyTime === null) { // 如果没有值,则记录当前时间 const firstNotifyTime = Date.now(); localStorage.setItem('firstNotifyTime', firstNotifyTime); } } // 检查是否可以发送通知 function canNotify() { const lastNotifyTime = getLastNotifyTime(); const currentTime = Date.now(); const fiveMinutesAgo = currentTime - ${Intervals} * 60 * 1000; // 计算间隔时间的毫秒数 return lastNotifyTime < fiveMinutesAgo; // 返回是否可以发送通知 } // 调用 Wxpusher API 来发送挪车通知 function notifyOwner() { setFirstNotificationTime(); // 记录首次通知时间戳 if (!canNotify()) { // 如果不能发送通知,则提示用户等待 alert("已经通知车主请耐心等待\\n${Intervals}分钟后可再次发送通知"); return; } // 发送通知的fetch请求代码 fetch("https://wxpusher.zjiecode.com/api/send/message", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ appToken: "${wxpusherAppToken}", content: "有人通知需要挪车,快快快!!!", contentType: 1, uids: ${JSON.stringify(wxpusherUIDs)} }) }) .then(response => response.json()) .then(data => { if (data.code === 1000) { alert("通知已发送!请耐心等待..."); setLastNotifyTime(Date.now()); } else { alert("通知发送失败,请稍后重试\\n若多次失败可电话联系车主"); // 如果通知发送失败,则减少电话联系等待时间(毕竟无法联系到车主) const firstNotifyTime = localStorage.getItem('firstNotifyTime'); const ReduceTime = firstNotifyTime - 3 * 60 * 1000; localStorage.setItem('firstNotifyTime', ReduceTime); } }) .catch(error => { console.error("Error sending notification:", error); alert("通知发送出错,请检查网络连接..."); }); } // 拨打车主电话 function callOwner() { // 获取首次通知时间 const firstNotifyTime = localStorage.getItem('firstNotifyTime'); // 检查是否已经设置过首次通知时间 if (firstNotifyTime === null) { // 如果没有设置过,先发送消息通知 alert("电话前,优先以消息方式通知车主"); notifyOwner(); // 调用消息通知 } else { // 如果已经设置过,检查是否已过指定时间 const currentTime = Date.now(); const timeSinceFirstNotify = (currentTime - firstNotifyTime) / 1000 / 60; // 转换为分钟 if (timeSinceFirstNotify >= ${PhoneDelay}) { // 如果已经过指定时间,可以直接拨打电话 window.location.href = "tel:${phone}"; } else { // 如果还没有过指定时间,提示用户等待 const remainingTime = ${PhoneDelay} - timeSinceFirstNotify; alert("当前已通知车主,请耐心等待...\\n"+remainingTime.toFixed(0)+"分钟后可直接拨打电话"); } } } </script> </body> </html> ` // 返回生成的HTML内容,并设置Content-Type为text/html return new Response(htmlContent, { headers: { 'Content-Type': 'text/html;charset=UTF-8' }, }) } ``` ### 缙哥哥 改版 较原版增加了通知间隔,防止频繁通知(更换手机或是清空缓存无效) ```js addEventListener('fetch', event => { event.respondWith(handleRequest(event.request)) }) async function handleRequest(request) { const phone = '18888888888'; // 车主的手机号 const wxpusherAppToken = 'AT_xxx'; // Wxpusher APP Token const wxpusherUIDs = ['UID_xxx']; // 车主的UIDs const htmlContent = ` <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>通知车主挪车</title> <style> * { box-sizing: border-box; margin: 0; padding: 0; } body { font-family: Arial, sans-serif; display: flex; align-items: center; justify-content: center; height: 100vh; background: #f0f2f5; color: #333; } .container { text-align: center; padding: 20px; width: 100%; max-width: 400px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); background: #fff; } h1 { font-size: 24px; margin-bottom: 20px; color: #007bff; } p { margin-bottom: 20px; font-size: 16px; color: #555; } button { width: 100%; padding: 15px; margin: 10px 0; font-size: 18px; font-weight: bold; color: #fff; border: none; border-radius: 6px; cursor: pointer; transition: background 0.3s; } .notify-btn { background: #28a745; } .notify-btn:hover { background: #218838; } .call-btn { background: #17a2b8; } .call-btn:hover { background: #138496; } </style> </head> <body> <div class="container"> <h1>通知车主挪车</h1> <p>如需通知车主,请点击以下按钮</p> <button class="notify-btn" onclick="notifyOwner()">通知车主挪车</button> <button class="call-btn" onclick="callOwner()">拨打车主电话</button> </div> <script> // 获取或设置最后通知的时间戳 function getLastNotifyTime() { return localStorage.getItem('lastNotifyTime') || 0; } function setLastNotifyTime(time) { localStorage.setItem('lastNotifyTime', time); } // 检查是否可以发送通知 function canNotify() { const lastNotifyTime = getLastNotifyTime(); const currentTime = Date.now(); const fiveMinutesAgo = currentTime - 10 * 60 * 1000; return lastNotifyTime < fiveMinutesAgo; } // 调用 Wxpusher API 来发送挪车通知 function notifyOwner() { if (!canNotify()) { alert("请等待10分钟后再次尝试通知。"); return; } fetch("https://wxpusher.zjiecode.com/api/send/message", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ appToken: "${wxpusherAppToken}", content: "您好,有人需要您挪车,请及时处理。", contentType: 1, uids: ${JSON.stringify(wxpusherUIDs)} }) }) .then(response => response.json()) .then(data => { if (data.code === 1000) { alert("通知已发送!"); setLastNotifyTime(Date.now()); } else { alert("通知发送失败,请稍后重试。"); } }) .catch(error => { console.error("Error sending notification:", error); alert("通知发送出错,请检查网络连接。"); }); } // 拨打车主电话 function callOwner() { window.location.href = "tel:${phone}"; } </script> </body> </html> ` return new Response(htmlContent, { headers: { 'Content-Type': 'text/html;charset=UTF-8' }, }) } ``` ### bgwu666 版 ```js addEventListener('fetch', event => { event.respondWith(handleRequest(event.request)) }) async function handleRequest(request) { const phone = '18888888888' // 车主的手机号 const wxpusherAppToken = 'AT_xxx' // Wxpusher APP Token const wxpusherUIDs = ['UID_xxx'] // 车主的UIDs , 'UID_d0pycYubbK6d766GNDo5deknw4i4' const htmlContent = ` <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>通知车主挪车</title> <style> * { box-sizing: border-box; margin: 0; padding: 0; } body { font-family: Arial, sans-serif; display: flex; align-items: center; justify-content: center; height: 100vh; background: #f0f2f5; color: #333; } .container { text-align: center; padding: 20px; width: 100%; max-width: 400px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); background: #fff; } h1 { font-size: 24px; margin-bottom: 20px; color: #007bff; } p { margin-bottom: 20px; font-size: 16px; color: #555; } button { width: 100%; padding: 15px; margin: 10px 0; font-size: 18px; font-weight: bold; color: #fff; border: none; border-radius: 6px; cursor: pointer; transition: background 0.3s; } .notify-btn { background: #28a745; } .notify-btn:hover { background: #218838; } .call-btn { background: #17a2b8; } .call-btn:hover { background: #138496; } </style> </head> <body> <div class="container"> <h1>通知车主挪车</h1> <p>如需通知车主,请点击以下按钮</p> <button class="notify-btn" onclick="notifyOwner()">通知车主挪车</button> <button class="call-btn" onclick="callOwner()">拨打车主电话</button> </div> <script> // 调用 Wxpusher API 来发送挪车通知 function notifyOwner() { fetch("https://wxpusher.zjiecode.com/api/send/message", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ appToken: "${wxpusherAppToken}", content: "您好,有人需要您挪车,请及时处理。", contentType: 1, uids: ${JSON.stringify(wxpusherUIDs)} }) }) .then(response => response.json()) .then(data => { if (data.code === 1000) { alert("通知已发送!"); } else { alert("通知发送失败,请稍后重试。"); } }) .catch(error => { console.error("Error sending notification:", error); alert("通知发送出错,请检查网络连接。"); }); } // 拨打车主电话 function callOwner() { window.location.href = "tel:${phone}"; } </script> </body> </html> ` return new Response(htmlContent, { headers: { 'Content-Type': 'text/html;charset=UTF-8' }, }) } ``` **相关教程:** - [用Workers免服务器部署挪车二维码,可微信通知、拨打电话](https://www.dujin.org/23105.html) - [利用Cloudflare Workers部署挪车页面](https://www.52pojie.cn/thread-1980798-1-1.html)
造物者W
2024年11月22日 19:53
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
Markdown文件
分享
链接
类型
密码
更新密码