ECP自动填充ping码

配合浏览器的自动填充账号密码功能,实现电子商务平台(ECP2.0)及电工交易专区(SGCCETP)的自动登录及自动输入ping码

目前為 2023-04-13 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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,点确定
      }
    }
  }
})();