goodsSelect

try to take over the world!

Stan na 04-02-2021. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         goodsSelect
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        *://*.jd.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var arr = []
    let time = setInterval(() => {
        var addItem = document.getElementById("addItem")
        if (addItem) {
            if (document.getElementById("btn-s")) {
                clearInterval(time)
                return
            }
            var button = document.createElement("button");
            button.id = "btn-s";
            button.innerHTML = "自定义添加";
            button.style.marginRight = "30px"
            button.style.cursor = "pointer"
            button.style.color = "#3da8f5"

            var input = document.createElement("input");
            input.id = "ipt"
            input.placeholder = "请输入货物名称/规格型号(添加多条以逗号隔开)";
            input.style.marginRight = "30px"
            input.style.border = "1px solid #999"
            input.style.width = "700px"
            input.style.height = "30px"
            input.style.lineHeight = "30px"
            input.style.borderRadius = "4px";
            input.style.paddingLeft = "15px";

            addItem.parentElement.insertBefore(button, addItem);
            addItem.parentElement.insertBefore(input, button);

            button.onclick = function () {

                $("#addItem").click()
                var goodsArr = document.getElementById("goodsSelect");
                let arrValue = input.value.split(',')
                arrValue.forEach(item => {
                    if (item) {
                        for (var i = 0; i < goodsArr.length; i++) {
                            if (goodsArr.options[i].value.indexOf(item) !== -1) {
                                var res = arr.findIndex(val => {
                                    return val === goodsArr.options[i].value
                                })
                                console.log(arr)
                                console.log(res)
                                if (res === -1) {
                                    arr.push(goodsArr.options[i].value)
                                }else {
                                    arr.splice(res,1)
                                }
                            }
                        }
                    }
                })
                arr.forEach(item => {
                    if (item) {
                        changeGoods(item)
                        $("#addItem").click()
                    }
                })
            }
        }
    }, 1000)
})();