| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- function getZL(ele) {
- if (!ele.querySelector('.zy-meli-card-wrap') || !ele.querySelector('.zy-meli-card-wrap').shadowRoot) {
- return -1
- }
- let temp = ele.querySelector('.zy-meli-card-wrap').shadowRoot.querySelectorAll('.meli-card-info-row .meli-card-info-value')[1].innerText
- temp = temp.replace('g', '')
- if (temp == '-') return -1
- if (temp == '') return -1
- return parseInt(temp)
- }
- function orderList () {
- let domList = []
- document.querySelectorAll('.ui-search-layout__item').forEach(element => {
- domList.push(element)
- });
- domList = domList.sort((a, b) => getZL(b) - getZL(a));
- domList.forEach(element => {
- console.log(getZL(element))
- });
- let tempDom = ``
- domList.forEach(element => {
- tempDom += element.outerHTML
- });
- document.querySelector('.ui-search-layout.ui-search-layout--grid').innerHTML = tempDom
- }
- function orderList2 () {
- let domList = []
- document.querySelectorAll('.ui-search-layout__item').forEach(element => {
- domList.push(element)
- });
- domList = domList.sort((a, b) => getZL(a) - getZL(b));
- domList.forEach(element => {
- console.log(getZL(element))
- });
- let tempDom = ``
- domList.forEach(element => {
- tempDom += element.outerHTML
- });
- document.querySelector('.ui-search-layout.ui-search-layout--grid').innerHTML = tempDom
- }
- window.pugeCreated = function (el) {
- el.innerHTML = '<div class="owo"><div class="owo button" id="cddx" >按重量大->小</div><div class="owo button" id="cxdd" >按重量小->大</div></div>'
- setTimeout(() => {
- window.cddx.onclick = function () {
- orderList()
- }
- window.cxdd.onclick = function () {
- orderList2()
- }
- }, 1000);
- }
|