WHUCodeInference

武大本科生院附件下载自动填验证码

目前为 2023-10-10 提交的版本。查看 最新版本

// ==UserScript==
// @name         WHUCodeInference
// @namespace    http://luxiaoxiao.work/
// @version      0.1
// @description  武大本科生院附件下载自动填验证码
// @author       LXX
// @license      MIT
// @match        https://uc.whu.edu.cn/system/_content/download.jsp*
// @icon         https://uc.whu.edu.cn/2022/images/favicon.ico
// @grant        GM_xmlhttpRequest
// ==/UserScript==

(function() {
    'use strict';
    var image = document.getElementById("codeimg");
    const inference = function(){

        while(image.complete != true)
        {
            image = document.getElementById("codeimg");
        }
        var canvas = document.createElement('canvas');
        canvas.width = 60
        canvas.height = 20;
        var context = canvas.getContext('2d');
        context.drawImage(image, 0, 0);

        var base64Data = canvas.toDataURL('image/png');

        console.log(base64Data);
        base64Data = base64Data.replace(/^data:image\/png;base64,/, '');
        base64Data = base64Data.replace(/\+/g, '-').replace(/\//g, '_');
        console.log(base64Data);

        GM_xmlhttpRequest({
            method: 'get',
            url: 'https://code.luxiaoxiao.work/code/' + base64Data,
            onload: function(response){
                console.log(response);
                document.getElementById('codeValue').value = response.responseText;
            }
        })
    }
    inference();

    const callback = function(){
        console.log('changed!');
        inference();
    }
    const observer = new MutationObserver(callback);
    const config = {
        attributes: true
    }
    observer.observe(image, config);

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址