效果演示:
对其中隐私部分已经隐藏,请自行测试
JS控制台代码:
let lastPhoneNumber = '';
const checkPhoneNumber = () => {
const elements = document.querySelectorAll('[class*="sd-Icon-iconmobile"]');
elements.forEach(element => {
const phoneNumberElement = element.nextElementSibling;
const phoneNumberText = phoneNumberElement.textContent.trim();
const phoneNumber = phoneNumberText.match(/\d{11}/)[0];
console.log(phoneNumber);
if (phoneNumber !== lastPhoneNumber) {
console.log("获取到新号码");
const qrCodeUrl = 'https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=' + phoneNumber;
const existingQRCode = document.querySelector('.qr-code');
if (existingQRCode) {
existingQRCode.src = qrCodeUrl;
} else {
const img = document.createElement('img');
img.src = qrCodeUrl;
img.className = 'qr-code';
phoneNumberElement.parentNode.insertBefore(img, phoneNumberElement.nextSibling);
}
lastPhoneNumber = phoneNumber;
}
});
};
setInterval(checkPhoneNumber, 3000);
油猴脚本:
// ==UserScript==
// @name MOKA手机号二维码
// @version 1.0
// @description 获取MOKA简历中的手机号码自动生成二维码方便手机扫描拨号
// @author hearts
// @match https://app.mokahr.com/candidates/application/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
let lastPhoneNumber = '';
const checkPhoneNumber = () => {
const elements = document.querySelectorAll('[class*="sd-Icon-iconmobile"]');
elements.forEach(element => {
const phoneNumberElement = element.nextElementSibling;
const phoneNumberText = phoneNumberElement.textContent.trim();
const phoneNumber = phoneNumberText.match(/\d{11}/)[0];
console.log(phoneNumber);
if (phoneNumber !== lastPhoneNumber) {
console.log("获取到新号码");
const qrCodeUrl = 'https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=' + phoneNumber;
const existingQRCode = document.querySelector('.qr-code');
if (existingQRCode) {
existingQRCode.src = qrCodeUrl;
} else {
const img = document.createElement('img');
img.src = qrCodeUrl;
img.className = 'qr-code';
phoneNumberElement.parentNode.insertBefore(img, phoneNumberElement.nextSibling);
}
lastPhoneNumber = phoneNumber;
}
});
};
setInterval(checkPhoneNumber, 3000);
})();
标签:code,浏览器,img,拨号,lastPhoneNumber,phoneNumber,phoneNumberElement,const,MOKA
From: https://blog.csdn.net/aimersong69/article/details/136862872