// ==UserScript== // @name Carousell fliter // @namespace see7di@gmail.com // @description 用來按照您設定的關鍵字過濾隱藏掉旋轉拍賣商品列表内的特定商品 // @version 3.5 // @icon https://hr4.com/careers/driveautogroup/images/path-parts.png // @author see7di@gmail.com // @match *://tw.carousell.com/* // @match *://tw.carousell.com/search/* // @exclude *://tw.carousell.com/p/* // @exclude *://tw.carousell.com/login/* // @exclude *://tw.carousell.com/inbox/* // @exclude *://tw.carousell.com/settings/* // @exclude *://*.exclude.com/live_chat* // @grant GM_getValue // @grant GM_setValue // @require https://code.jquery.com/jquery-2.2.4.min.js // @supportURL https://www.youtube.com/channel/UCFSN_dR_z4uJz2E8mByRERA // @homepage https://www.youtube.com/channel/UCFSN_dR_z4uJz2E8mByRERA // @grant GM_xmlhttpRequest // @connect * // @run-at document-end // @downloadURL none // ==/UserScript== //https://www.youtube.com/user/see7di/playlists?view=1 //https://tw.carousell.com/search/?addRecent=false&canChangeKeyword=false&includeSuggestions=false&price_end=222&price_start=1&sc=0a0208301a0408bce9652a210a05707269636522160a0909000000000000f03f1209090000000000c06b4078012a140a0b636f6c6c656374696f6e7312030a013078012a210a05707269636522160a0909000000000000f03f1209090000000000c06b4078013204080378013a02180742060801100118004a0620012801400150005a020801&searchId=wkcMW7&searchType=all&sort_by=3 (function() { "use strict"; var cfg={ n1:0, n2:0, n3:0, loop:10, debug:false, }; window.setTimeout(function(){ //列表 no loop $("iframe").remove(); //$("header",$("#root")).remove(); $("footer",$("#main")).remove(); //$('header[style^="margin-top"]').remove(); $('p:contains("出售")').parent().parent().parent().remove(); $("body").prepend("

Carousell fliter!

"); $("#carousell_btn").bind("click",function(){ console.clear(); var obj; if(cfg.n1>0){ $('._done_').each(function(i){ obj=$(this).parent().parent().parent().parent(); jQuery('*',obj).add([obj]).each(function(){ jQuery.event.remove(this);jQuery.removeData(this) }); obj.innerHTML=''; obj.remove(); }); }obj=null; guoLv(); }); $("#carousell_ico").bind("click",function(){ doSetting() }); $("#carousell_keys").bind("blur",function(){ saveKeys(); }); $("#carousell_user").bind("blur",function(){ saveUser(); }); var str_list=$.trim(GM_getValue("black_keys_list")).toLowerCase(); if(str_list==''){ str_list='褲|帽|襪|裙|袖|恤|衫|鞋|恤|髮|童裝|足膜|長洋|大衣|上衣|香水|和服|男裝|女裝|短褲|秋裝|蜜粉|卸妝'; GM_setValue("black_keys_list",str_list); } $("#carousell_keys").val(str_list); if(cfg.debug==true){ console.log("black_keys_list:"+str_list); } str_list=''; str_list=$.trim(GM_getValue("black_user_list")).toLowerCase(); if(str_list==''){ str_list='vincent31|doli8|go_89|yoya1985'; GM_setValue("black_user_list",str_list); } $("#carousell_user").val(str_list); if(cfg.debug==true){ console.log("black_user_list:"+str_list); } str_list=null; window.setTimeout(function(){ //no loop $('a[aria-label]').parent().parent().parent().parent().remove(); $("#root").find("div:first").attr("style","margin-top:0"); if(isPc()==false){ cfg.loop=1; //手機版若一次連續多頁多次會導致n3計數器錯誤 $("#carousell_box").css({"top":"10px","bottom":""}); } $('button:contains("Show more results")').click(); },500); },1500); var guoLv=function(){ //Fliter cfg.n1++; var arr_list=getArray($.trim($("#carousell_keys").val()).toLowerCase()); //alert(isPc()) if(cfg.debug==true){ console.log("arr_list:"+arr_list); //$("div[data-testid]").attr("style","border:3px solid red;") //$("div[data-testid]").find("div:first").find("a:nth-of-type(2)").attr("style","border:3px solid red;") //$("#main div[data-testid]").find("div:first > a > p:nth-child(2)").attr("style","border:3px solid red;") //$("div[data-testid]").find("div:first").find("p:nth-of-type(1)").attr("style","border:3px solid red;") //$('div > a:eq(2)',$("div[data-testid]")).attr("style","border:3px solid orange;") } if(isPc()==true){ var arrlist=$('p[style^="--max"]',$("div[data-testid]")); }else{ var arrlist=$("#main div[data-testid]").find("div:first > a > p:nth-child(2)"); } arrlist=arrlist.attr({"style":"border:2px solid blue;--max-line:2;text-transform:lowercase;"}).addClass("_done_"); //console.log(arrlist) arrlist.each(function(i){ cfg.n2++; var title=$.trim($(this).text()).toLowerCase(); if(cfg.debug==true){ console.log("title:"+title); } var user=$.trim($(this).parent().parent().parent().find('p[data-testid]').text()).toLowerCase(); var arr_name=getArray($.trim($("#carousell_user").val()).toLowerCase()); if(cfg.debug==true){ //$(this).parent().parent().parent().find('p[data-testid]').attr("style","border:3px solid blue"); console.log("user:"+user); console.log("arr_name:"+arr_name); } var in_user_list=false; var obj0; for(var x in arr_name){ if(user==arr_name[x].toLowerCase()){ if(cfg.debug==true){ $(this).parent().parent().parent().find('p[data-testid]').attr("style","border:3px solid orange"); } cfg.n3++; in_user_list=true; //$(this).parent().parent().parent().parent().remove(); obj0=$(this).parent().parent().parent().parent(); jQuery('*',obj0).add([obj0]).each(function(){ jQuery.event.remove(this);jQuery.removeData(this) }); obj0.innerHTML=''; obj0.remove(); //$(this).parent().parent().parent().parent().css({"display":"none"}); break; } }arr_name=obj0=null; if(in_user_list==false){ var obj1; for(var y in arr_list){ //console.log("title:"+title+" | arr_list[y]:"+arr_list[y]) if(title.indexOf(arr_list[y])!=-1){ //$(this).parent().parent().parent().attr("style","border:3px solid blue"); cfg.n3++; //$(this).parent().parent().parent().parent().remove(); obj1=$(this).parent().parent().parent().parent(); jQuery('*',obj1).add([obj1]).each(function(){ jQuery.event.remove(this);jQuery.removeData(this) }); obj1.innerHTML=''; obj1.remove(); //$(this).parent().parent().parent().parent().css({"display":"none"}); break; } }user=title=obj1=null; }in_user_list=null; }); arr_list=null; arrlist=null; $("#carousell_btn").prop("disabled",true); $("#carousell_memo").html("第"+cfg.n1+"次過濾,共找到"+cfg.n2+"個商品
其中"+cfg.n3+"個已被過濾掉!"); if(cfg.n1 % cfg.loop == 0){ $("#carousell_btn").prop("disabled",false); }else{ window.setTimeout(function(){ //no loop $('button:contains("顯示更多結果")').click(); $('button:contains("瀏覽更多")').click(); window.setTimeout(function(){ guoLv(); },2000); },1000); } } var doSetting=function(){ if($("#carousell_ico").text()=="▼"){ $("#carousell_ico").text("▲"); $("#carousell_setting").css({"display":""}); }else{ $("#carousell_ico").text("▼"); $("#carousell_setting").css({"display":"none"}); } } var saveKeys=function(){ //Save the keywords var str_list=$.trim($("#carousell_keys").val().toLowerCase()); GM_setValue("black_keys_list",str_list); str_list=null; $("#carousell_ico").text("▼"); $("#carousell_setting").css({"display":"none"}); } var saveUser=function(){ //Save user list var str_list=$.trim($("#carousell_user").val().toLowerCase()); GM_setValue("black_user_list",str_list); str_list=null; $("#carousell_ico").text("▼"); $("#carousell_setting").css({"display":"none"}); } var isPc=function (){ //pc返回true var userAgentInfo=navigator.userAgent; var Agents =new Array("Android","iPhone","SymbianOS","Windows Phone","iPad","iPod"); var flag=true; for(var v=0;v0) { flag=false; break; } } return flag; } var getArray=function(string){ //Get array from string if (!string) return []; return string.split("|").map(v => v.trim()).filter(v => v.length); } })();