mesakey / pchome_search_title_filter

// ==UserScript==
// @name         pchome_search_title_filter
// @namespace    http://mesak.tw
// @version      1.0
// @description  pchome search title bar
// @author       Mesak
// @match        https://ecshweb.pchome.com.tw/search/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=pchome.com.tw
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
     $('.bar_spinbtn').append(`標題搜尋:<input type="text" id="fix_title_filter" value="">`).on('keypress blur','#fix_title_filter',(e)=>{
       let word = e.currentTarget.value
       let words = word.split(' ')
       let $productList = $('#ItemContainer > dl')
        if( word == '')
        {
            $productList.show();
        }else{
         $productList.hide();
         $productList.each((key,node)=>{
             let title = $('.prod_name',node).text()
             let resutls  = []
             words.forEach( (value) => {
                 resutls.push( title.toLowerCase().search(value.toLowerCase()) !== -1)
             })
             if( !resutls.includes(false) ){
                 $(node).show();
             }


         })
        }
     })


    // Your code here...
})();