Greasy Fork

扫描发货手动输入补全工具

2024/5/20 16:26:34

目前为 2024-05-27 提交的版本。查看 最新版本

// ==UserScript==
// @name        扫描发货手动输入补全工具
// @namespace   Violentmonkey Scripts
// @match       https://www.dianxiaomi.com/package/scanPackShipped.htm
// @grant       GM_xmlhttpRequest
// @license     MIT
// @version     1.1
// @author      -
// @description 2024/5/20 16:26:34
// ==/UserScript==
(async function(){
  let url = "https://www.dianxiaomi.com/package/list.htm?pageNo=1&pageSize=300&shopId=-1&state=allocated_has&platform=&isSearch=0&searchType=orderId&authId=-1&startTime=&endTime=&country=&orderField=order_pay_time&isVoided=0&isRemoved=0&ruleId=-1&sysRule=&applyType=&applyStatus=&printJh=-1&printMd=-1&commitPlatform=&productStatus=&jhComment=-1&storageId=0&isOversea=-1&isFree=0&isBatch=0&history=&custom=-1&timeOut=0&refundStatus=0&buyerAccount=&forbiddenStatus=-1&forbiddenReason=0&behindTrack=-1&orderId="
  let list = await new Promise((resolve) => {
      GM_xmlhttpRequest({
        method: "GET",
        url: url,
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        onload: function (response) {
          html = $(response.responseText);
          resolve(html.find("#orderListTable tr[data-orderid]").map(function(){return $(this).children("td:eq(5)").find("a[data-as='q2341']").text()}).toArray());
        }
      });
    });
  let acomp = $("#scanShippingInput").autocomplete({source:list})
  $("#scanShippingInput").on("input",function(){
    var val = $(this).val();
    if(list.includes(val)){
      acomp.autocomplete( "disable" );
    }else{
      acomp.autocomplete( "enable" );
    }
  })
})()