appendModel

append model in orderDetailAddPage

As of 09.05.2022. See ბოლო ვერსია.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         appendModel
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  append model in orderDetailAddPage
// @author       FengXia
// @match        http://47.107.106.156/*
// @icon         
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    let newNode = document.createElement("td");
    newNode.innerText="规格:";
    newNode.id="model"
    let newNode2 = document.createElement("td");
    let oldxhr=window.XMLHttpRequest
    function newobj(){}
    
    window.XMLHttpRequest=function(){
        let tagetobk=new newobj();
        tagetobk.oldxhr=new oldxhr();
        let handle={
        get:    function(target, prop, receiver) {
                if(prop==='oldxhr'){
                    return Reflect.get(target,prop);
                }
                if(typeof Reflect.get(target.oldxhr,prop)==='function')
                {
                    if(Reflect.get(target.oldxhr,prop+'proxy')===undefined)
                    {
                        target.oldxhr[prop+'proxy']=(...funcargs)=> {
                            let result=target.oldxhr[prop].call(target.oldxhr,...funcargs)
                            // console.log('函数劫持获取结果',result)
                            return result;
                        }

                    }
                    return Reflect.get(target.oldxhr,prop+'proxy')
                }
                if(prop.indexOf('response')!==-1)
                {
                    //console.log('属性劫持结果',Reflect.get(target.oldxhr,prop))
                    let xhrString = Reflect.get(target.oldxhr,prop)
                    try {
                        xhrString = JSON.parse(xhrString)
                        //console.log('属性劫持结果2',xhrString)
                        //console.log('属性劫持结果3',xhrString.detail.goodsInfo.model)
                        let modelString =xhrString.detail.goodsInfo.model;

                        if (modelString){
                            let ops=document.querySelectorAll('#sales-form-orderDetailAddPage tbody tr');
                            let findModel=document.querySelectorAll('#sales-form-orderDetailAddPage tbody #model');
                            if (findModel){
                            }
                            newNode2.innerHTML=`<input class="len150 readonly" readonly="readonly" name="model" placeholder=${modelString}>`
                            ops[11].appendChild(newNode);
                            ops[11].appendChild(newNode2);
                        }
                        return Reflect.get(target.oldxhr,prop)
                    } catch(err){
                        return Reflect.get(target.oldxhr,prop)
                    }
                }
                return Reflect.get(target.oldxhr,prop);
            },
            set(target, prop, value) {
                return Reflect.set(target.oldxhr, prop, value);
            },
            has(target, key) {
                debugger;
                return Reflect.has(target.oldxhr,key);
            }
        }

        let ret = new Proxy(tagetobk, handle);

        return ret;
        let ops=document.querySelector('#sales-form-orderDetailAddPage .ops');
    }
})();