pchome_search_title_filter

pchome search title bar

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         pchome_search_title_filter
// @namespace    http://mesak.tw
// @version      1.1
// @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';
     $('#layoutBread').css({justifyContent:'space-between'});
     $('#layoutBread').append(`<div style="width:40%">標題搜尋:<input type="text" id="fix_title_filter" value="" style="border:1px #000 solid"></div>`).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...
})();