锦城金融实训课程终结者系列之-银行信贷模拟

页面input元素复制粘贴(银行信贷模拟版)

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

// ==UserScript==
// @name         锦城金融实训课程终结者系列之-银行信贷模拟
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  页面input元素复制粘贴(银行信贷模拟版)
// @license      MIT
// @author       廖哥
// @match        https://www.baidu.com/
// @icon         https://www.google.com/s2/favicons?domain=bilibili.com
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';
    GM_addStyle("#_mainOtherBox {position: fixed: antiquewhite; top: 0;left: 0;z-index: 10000;background-color: #ff9999;padding: 0 13px 0 8px;color:#000;font-size: 10px;}");
    GM_addStyle("#other {width: 150px;height: 50px;line-height: 50px;font-size: 22px;position: fixed;top: 100px;right: 200px;}");
//创建按钮容器
    let _main = document.createElement('div');
    _main.class = 'otherBox';
    _main.id = '_mainOtherBox';
    _main.style.position="fixed";
    _main.style.left="220px";
    _main.style.top="20px";
    _main.style['z-index']="999999";
    _main.innerText = '网页快捷键:';
//创建按钮,复制事件
    let _copy = document.createElement('button');
    _copy.innerText = '复制';
    _copy.class = 'other';
    _copy.addEventListener('click',()=>
{
        var url = document.URL;
        var values = [];
        var ids = [];
        var inputs = document.getElementsByTagName('input');
        GM_setValue('Test',[199900,10,100]);
        for(var i=0; i<inputs.length; i++)
        {
            if (inputs[i].type=='text')
            {
                values.push(inputs[i].value);
                ids.push(inputs[i].id);
            };
        };
        var urls = GM_getValue('Urls');
// 新建复制项
        GM_setValue('Urls',urls.push(url.slice(0,url.indexOf('.aspx'))));
        GM_setValue('Values',GM_getValue('Values').push(values));
        GM_setValue('Ids',GM_getValue('Ids').push(ids));
// 重写复制项
        if (urls.indexOf(url.slice(0,url.indexOf('.aspx'))) != -1)
        {
            let urlIdex = urls.indexOf(url.slice(0,url.indexOf('.aspx')));
            let newValues = GM_getValue('Values')[urlIdex] = values;
            let newIds = GM_getValue('Ids')[urlIdex] = ids;
            GM_setValue('Values',newValues);
            GM_setValue('Ids',newIds);
        };
        alert('复制页面成功!');
});
//创建按钮,粘贴事件
    let _paste = document.createElement('button');
    _paste.innerText = '粘贴';
    _paste.class = 'other'
    _paste.addEventListener('click',()=>{
        var urlObjects = GM_getValue('urlObjects',{Url:'', Values:[], Ids:[]});
        var url = document.URL;
        let urlList = urlObjects.Url.split(',');
        let urlIdex = urlList.indexOf(url.slice(0,url.indexOf('.aspx')));
        var values = urlObjects.Values[urlIdex];
        var ids = urlObjects.Ids[urlIdex];
        var inputs = document.getElementsByTagName('input');
        for(var id of ids){
            for(var i=0; i<inputs.length; i++){
                if (inputs[i].type=='text' && inputs[i].id==id){
                    inputs[i].value=values[ids.indexOf(id)];
                };
            };
        };
        alert('粘贴页面成功!');

});
//放置按钮
    document.body.appendChild(_main);
    document.getElementById('_mainOtherBox').appendChild(_copy);
    document.getElementById('_mainOtherBox').appendChild(_paste);
})();

QingJ © 2025

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