diff --git a/weixin/login.user.js b/weixin/login.user.js new file mode 100644 index 0000000..d80e7e5 --- /dev/null +++ b/weixin/login.user.js @@ -0,0 +1,97 @@ +// ==UserScript== +// @name 微信登录通知 +// @namespace https://miaowoo.cc/ +// @version 0.2 +// @description 自动化登录通知 +// @author MiaoWoo +// @match https://pay.weixin.qq.com/index.php/core/home/login** +// @match https://cover.weixin.qq.com/** +// @match https://work.weixin.qq.com/wework_admin/wwqrlogin/mng/login_qrcode** +// @grant none +// ==/UserScript== + +(function () { + 'use strict'; + let api = "https://oauth.yumc.pw/qr/push" + async function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)) + } + async function post(url, data) { + return await fetch(url, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(data) + }).then(r => r.json()) + } + async function wxpay() { + let qrcode = null + while (!(qrcode = document.getElementById('IDQrcodeImg'))) { + await sleep(100) + } + let url = null + while (!(url = qrcode.getAttribute('title'))) { + await sleep(100) + } + await post(api, { url, title: '微信支付' }) + } + async function cover() { + if (location.hash != "#/login") { + return + } + let qrcode = null + while (!(qrcode = document.querySelector('.qrcode'))) { + await sleep(100) + } + let img = null + while (!(img = qrcode.children[0])) { + await sleep(100) + } + while (!(img.src.startsWith('data:image/png;base64'))) { + await sleep(100) + } + let base64 = img.src + await post(api, { base64, title: '微信红包封面' }) + } + async function work() { + let qrcode = null + while (!(qrcode = document.querySelector('.qrcode_wrap'))) { + await sleep(100) + } + let img = null + while (!(img = qrcode.children[0])) { + await sleep(100) + } + while (img.style.display) { + await sleep(100) + } + while (!(img.src.startsWith('https://work.weixin.qq.com/wwqrlogin'))) { + await sleep(100) + } + await sleep(500) + let originClass = img.className + img.className = '' + // 创建canvas DOM元素,并设置其宽高和图片一样 + var canvas = document.createElement("canvas"); + canvas.width = img.width; + canvas.height = img.height; + // 坐标(0,0) 表示从此处开始绘制,相当于偏移。 + canvas.getContext("2d").drawImage(img, 0, 0); + img.className = originClass + let base64 = canvas.toDataURL() + await post(api, { base64, title: '企业微信' }) + } + async function main() { + if (location.origin == "https://pay.weixin.qq.com") { + await wxpay() + } + if (location.origin == "https://cover.weixin.qq.com") { + await cover() + } + if (location.origin == "https://work.weixin.qq.com") { + await work() + } + } + main() +})(); \ No newline at end of file diff --git a/weixin/pay.user.js b/weixin/pay.user.js deleted file mode 100644 index 07da588..0000000 --- a/weixin/pay.user.js +++ /dev/null @@ -1,37 +0,0 @@ -// ==UserScript== -// @name 微信商户登录通知 -// @namespace https://miaowoo.cc/ -// @version 0.1 -// @description 自动化登录通知 -// @author MiaoWoo -// @match https://pay.weixin.qq.com/index.php/core/home/login** -// @grant none -// ==/UserScript== - -(function() { - 'use strict'; - async function sleep(ms) { - return new Promise(resolve => setTimeout(resolve, ms)) - } - async function post(url, data) { - return await fetch(url, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(data) - }).then(r => r.json()) - } - async function main() { - let qrcode = null - while (!(qrcode = document.getElementById('IDQrcodeImg'))) { - await sleep(100) - } - let url = null - while (!(url = qrcode.getAttribute('title'))) { - await sleep(100) - } - await post('https://oauthtest.yumc.pw/qr/wxpay', {url}) - } - main() -})(); \ No newline at end of file