配合浏览器的自动填充账号密码功能,实现电子商务平台(ECP2.0)及电工交易专区(SGCCETP)的自动登录及自动输入ping码
目前為
// ==UserScript==
// @name ECP自动填充ping码
// @namespace http://tampermonkey.net/
// @version 0.3
// @description 配合浏览器的自动填充账号密码功能,实现电子商务平台(ECP2.0)及电工交易专区(SGCCETP)的自动登录及自动输入ping码
// @author coccvo
// @match https://sgccetp.com.cn/*
// @match https://ecp.sgcc.com.cn/*
// @icon https://sgccetp.com.cn/portal/favicon.ico
// @grant none
// @license MIT
// ==/UserScript==
(function() {
"use strict";
console.log("location.hostname:",location.hostname)
if(location.href.match('https://sgccetp.com.cn/isc/newlogin.html'))//电工交易专区登录页面
{
setInterval(function(){var button = document.getElementById("register"); button.click();}, 300); //切换手机登录到Ukey登录
if(document.querySelector("input#uKeyPin") != null && document.querySelector("input#cipher") != null)
{
setTimeout(function(){
document.querySelector('button[onclick="newLogin()"]').click();
}, 900);//点击登录按钮
setInterval(function(){
document.querySelector("input.pin").value='1234';
document.querySelector('.sure.none').disabled = false;
document.querySelector('.sure.none').click();
}, 1200);//输入ping,点确定
};
}
if(location.href.match('https://ecp.sgcc.com.cn/isc/newlogin.html'))//ECP2.0平台登录页面
{
setTimeout(function(){var button = document.getElementById("register"); button.click();}, 300); //切换手机登录到Ukey登录
setTimeout(function(){
document.querySelector('button[class="fa btn btn-primary btn-sm"]').click();
}, 1000);//点击登录按钮
setInterval(function(){
document.querySelector("input.pin").value='1234';
document.querySelector('.sure.none').disabled = false;
document.querySelector('.sure.none').click();
}, 1200);//输入ping,点确定
}
if(location.href.match('https://sgccetp.com.cn/purchase') || location.href.match('https://ecp.sgcc.com.cn/ecp2.0/purchase_ext'))//系统页面
{
let spans = document.querySelectorAll('span');
for (let i = 0; i < spans.length; i++) {
if (spans[i].innerText === '用户PIN:') {
setTimeout(function () {
let pinInput = document.querySelector('.pin');
let sureBtn = document.querySelector('.sure.none');
//pinInput.value = '';
pinInput.value = '1234';
setTimeout(function(){
sureBtn.removeAttribute('disabled');
sureBtn.click();
}, 500);
}, 900);//输入ping,点确定
}
}
}
})();