更新 'weixin/login.user.js'

This commit is contained in:
502647092 2021-09-07 02:14:55 +00:00
parent f0c183032a
commit d5142724dd
2 changed files with 97 additions and 37 deletions

97
weixin/login.user.js Normal file
View File

@ -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()
})();

View File

@ -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()
})();