Greasy Fork

Greasy Fork is available in English.

Taobao Sales Filter

根据销量过滤淘宝搜索页面的商品

当前为 2019-10-29 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Taobao Sales Filter
// @namespace    zzway.space
// @version      0.1
// @description  根据销量过滤淘宝搜索页面的商品
// @author       Zzway
// @match        https://s.taobao.com/*
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==

(function() {
    'use strict'

    window.onload= ()=>{
        let li=document.createElement('li')
        li.title='鼠标点击空白处或按回车 即可生效'
        let input=document.createElement('input')
        input.type='number'
        input.min=0
        input.style.width='100%'
        input.value=GM_getValue('limit',1)
        let span=document.createElement('span')
        span.innerText='销量过滤'
        span.style.backgroundColor='#f40'
        span.style.color='white'
        span.style['font-size']='x-large'

        li.appendChild(input)
        li.appendChild(span)
        let root=document.querySelector('.tb-side > ul')
        root.appendChild(li)

        let itemList = document.querySelectorAll('.items > div.item')
        let cntList = document.querySelectorAll('div.deal-cnt')

		filter()
        input.addEventListener('focusout',filter)
		input.addEventListener('keydown',e=>{
			if(e.code=='Enter'){filter()}
		})
        function filter(){
            cntList.forEach((element, key) => {
                let number = Number(element.innerText.replace('人付款', ''))
				console.info(number)
                console.info(number < input.value)
                if (number < input.value) {
                    itemList[key].hidden = true
                }else{
                    itemList[key].hidden = false
                }
            })
            GM_setValue('limit', input.value)
        }
    }

})();