// ==UserScript== // @name 蝦皮廣告封鎖器 // @namespace https://greasyfork.org/scripts/437545 // @version 1.3.1 // @description 蝦皮搜尋結果的前幾個商品廣告封鎖 // @author fmnijk // @match https://shopee.tw/* // @icon https://www.google.com/s2/favicons?domain=shopee.tw // @grant GM_addStyle // @license MIT // @require https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js // @downloadURL none // ==/UserScript== history.pushState = ( f => function pushState(){ var ret = f.apply(this, arguments); window.dispatchEvent(new Event('pushstate')); window.dispatchEvent(new Event('locationchange')); return ret; })(history.pushState); history.replaceState = ( f => function replaceState(){ var ret = f.apply(this, arguments); window.dispatchEvent(new Event('replacestate')); window.dispatchEvent(new Event('locationchange')); return ret; })(history.replaceState); window.addEventListener('popstate',()=>{ window.dispatchEvent(new Event('locationchange')) }); (function() { 'use strict'; const styles = String.raw` /*隱藏蝦皮搜尋結果廣告商品*/ .col-xs-2-4.shopee-search-item-result__item:has(.Sh\+UIZ){ display: none !important; } ` GM_addStyle(styles); // 定时器 removead(); window.addEventListener('locationchange', function (){ removead(); }) })(); function removead() { setIntervalX(() => { $(".col-xs-2-4.shopee-search-item-result__item").each(function() { //console.log($(".F7xq8U", $(this)).text()); if ($(".F7xq8U", $(this)).text().indexOf("Ad") != -1){ $(this).hide(); } if ($(".F7xq8U", $(this)).text().indexOf("廣告") != -1){ $(this).hide(); } }); }, 100, 20); } function setIntervalX(callback, delay, repetitions) { var x = 0; var intervalID = window.setInterval(function () { callback(); if (++x === repetitions) { window.clearInterval(intervalID); } }, delay); }