Alibaba vector icon library batch add icons
The Alibaba vector icon library is the most commonly used to find icons . But adding a library icon to the shopping cart in the Alibaba vector icon library is very troublesome. For example, the mobile phone Taobao icon library has a total of 434 \color{#FF3030}{434}4 3 4 icons, if you manually add them to the shopping cart one by one, it is time-consuming and laborious, and thankless.
So is there a better way?
After my observation, I found that the class attribute of the elements added to the shopping cart in each icon contains "icon − gouwuche 1" \color{#FF3030}{"icon-gouwuche1"}“icon−g o u w u c h e 1 " This value.
We can use the getElementsByClassName method to find out all the icon’s add-in shopping cart options, and then make each option call the click method, so that the function of adding a library icon to the shopping cart in batches can be realized.
code show as below:
let iconList = document.getElementsByClassName('icon-gouwuche1');
for(let i = 0,length = iconList.length;i < length;i++){
let iconItem = iconList[i];
setTimeout(function(){
//延时操作防止页面卡死
iconItem.click();
},i);
}
As shown in the figure below, 434 \color{#FF3030}{434} in this library4 3 4 icons are all added to the shopping cart.