1
0
Fork 0
UserScript/weixin/login.user.js

87 lines
2.6 KiB
JavaScript

// ==UserScript==
// @name 微信登录通知
// @namespace https://miaowoo.cc/
// @version 0.3
// @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)
}
let src = img.src
await post(api, { src, 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()
})();