[MAC][AdGuard 2.4.3.718] Facebook Sponsored ads are NOT blocked

Blaz

Moderator & Translator
Staff member
Moderator
@Boo Berry

giodeluigi's account on facebook is somehow using different elements than my account on same language selection. I sent him a new rule to test until tomorrow and if still working, it will be added. So far it seems to be working or facebook does not send him ads while we tested on AnyDesk.
 

Blaz

Moderator & Translator
Staff member
Moderator
Added rule with fix for @giodeluigi's account, along other items:

Added:
tz_MA
sy_SY
cb_IQ
ar_AR
sz_PL
eo_EO
es_LA

Fixed:
pt_BR / gl
my_MM

Code:
facebook.com,facebookcorewwi.onion#%#!function(){var e=new MutationObserver(function(){var g=document.querySelectorAll("div[id^='mount_']");if(0<g.length)var e=document.querySelectorAll('div[role="feed"] > div[data-pagelet^="FeedUnit"]');else e=document.querySelectorAll('[id^="substream"] > div:not(.hidden_elem) div[id^="hyperfeed_story_id"]');e.forEach(function(e){function t(e,t){for(0<g.length?"0"==(s=e.querySelectorAll('div[role="article"] span[dir="auto"] > a > span > span > span[data-content]')).length&&(s=e.querySelectorAll('div[role="article"] span[dir="auto"] > a > span[aria-label]')):s=e.querySelectorAll('.userContentWrapper h5 + div[data-testid*="sub"] a [class] [class]'),socheck=0;socheck<s.length;socheck++)s[socheck].innerText.contains(t)&&(c=["1"],i=["1"],d=["1"],r=l=a=1,socheck=s.length)}function n(e,t,n,o,a){d=0<g.length?(s=e.querySelectorAll('div[role="article"] span[dir="auto"] > a > span span[data-content='+t+"]"),c=e.querySelectorAll('div[role="article"] span[dir="auto"] > a > span span[data-content='+n+"]"),i=e.querySelectorAll('div[role="article"] span[dir="auto"] > a > span span[data-content='+o+"]"),e.querySelectorAll('div[role="article"] span[dir="auto"] > a > span span[data-content='+a+"]")):(s=e.querySelectorAll('.userContentWrapper h5 + div[data-testid*="sub"] a [data-content='+t+"]"),c=e.querySelectorAll('.userContentWrapper h5 + div[data-testid*="sub"] a [data-content='+n+"]"),i=e.querySelectorAll('.userContentWrapper h5 + div[data-testid*="sub"] a [data-content='+o+"]"),e.querySelectorAll('.userContentWrapper h5 + div[data-testid*="sub"] a [data-content='+a+"]")),0==s.length&&(s=e.querySelectorAll('.userContentWrapper h5 + div[data-testid*="label"] a [data-content='+t+"]"),c=e.querySelectorAll('.userContentWrapper h5 + div[data-testid*="label"] a [data-content='+n+"]"),i=e.querySelectorAll('.userContentWrapper h5 + div[data-testid*="label"] a [data-content='+o+"]"),d=e.querySelectorAll('.userContentWrapper h5 + div[data-testid*="label"] a [data-content='+a+"]"))}var o=0,a=0,l=0,r=0,s=0,c=0,i=0,d=0,u=e.querySelectorAll("div[style='width: 100%'] > a[href*='oculus.com/quest'] > div"),h=document.querySelector("[lang]"),f=document.querySelectorAll("link[rel='preload'][href*='/l/']");if(h)h=document.querySelector("[lang]").lang;else h="en";var p=e.querySelectorAll('a[ajaxify*="ad_id"] > span'),y=e.querySelectorAll('a[href*="ads/about"]');if("display: none !important;"!=e.getAttribute("style")&&!e.classList.contains("hidden_elem")){if(0<p.length||0<y.length){if(m+=1,0<g.length){if(""==(S=e.querySelectorAll("a[href]")[0].innerText))var S=e.querySelectorAll("a[href]")[1].innerText;if(""==S)S=e.querySelectorAll("a[href]")[0].querySelectorAll("a[aria-label]")[0].getAttribute("aria-label")}else S=e.querySelectorAll("a[href]")[2].innerText;console.log("--------"),console.log("Ad hidden from: "+S),console.log("Total ads hidden: "+m),console.log("F length: "+p.length),console.log("H length: "+y.length),console.log("--------"),e.style="display:none!important;"}else if(0<u.length){m+=1;S="Facebook";console.log("--------"),console.log("Ad hidden from: "+S),console.log("Total ads hidden: "+m),console.log("Non-declared ad"),console.log("--------"),e.style="display:none!important;"}else if("af"==h)t(e,"Geborg");else if("de"==h||"nl"==h)n(e,"G","e","s","n");else if("am"==h)t(e,"የተከፈለበት ማስታወቂያ");else if("ar"==h)t(e,"مُموَّل");else if("as"==h)t(e,"পৃষ্ঠপোষকতা কৰা");else if("az"==h)t(e,"Sponsor dəstəkli");else if("co"==h)t(e,"Spunsurizatu");else if("bs"==h||"sl"==h||"cs"==h)n(e,"S","p","z","n");else if("da"==h||"en"==h||"et"==h||"fy"==h||"it"==h||"ku"==h||"nb"==h||"nn"==h||"pl"==h||"sq"==h||"sv"==h||"zz"==h){if(0<g.length)if(f[0].href.contains("en_UD"))t(e,"pəɹosuodS");else if(f[0].href.contains("ja_KS"))t(e,"広告");else if(f[0].href.contains("tz_MA"))t(e,"ⵉⴷⵍ");else if(f[0].href.contains("sy_SY"))t(e,"ܒܘܕܩܐ ܡܡܘܘܢܐ");else if(f[0].href.contains("cb_IQ"))t(e,"پاڵپشتیکراو");else if(f[0].href.contains("ar_AR"))t(e,"مُموَّل");else if(f[0].href.contains("sz_PL"))t(e,"Szpōnzorowane");else if(f[0].href.contains("eo_EO"))t(e,"Reklamo");else if(f[0].href.contains("es_LA"))n(e,"P","u","c","d");else{if(n(e,"S","p","s","n"),0==o&&0==a&&0==l&&0==r)for("0"==(s=e.querySelectorAll('div[role="article"] span[dir="auto"] > a > span > span > span[data-content]')).length&&(s=e.querySelectorAll('div[role="article"] span[dir="auto"] > a > span[aria-label]')),socheck=0;socheck<s.length;socheck++)s[socheck].innerText.contains("S")&&(o=1),s[socheck].innerText.contains("p")&&(c=["1"],a=1),s[socheck].innerText.contains("s")&&(i=["1"],l=1),s[socheck].innerText.contains("n")&&(d=["1"],r=1)}else if(document.querySelector("body").className.includes("Locale_en_UD"))t(e,"pəɹosuodS");else if(document.querySelector("body").className.includes("ja_KS"))t(e,"広告");else if(document.querySelector("body").className.includes("tz_MA"))t(e,"ⵉⴷⵍ");else if(document.querySelector("body").className.includes("sy_SY"))t(e,"ܒܘܕܩܐ ܡܡܘܘܢܐ");else if(document.querySelector("body").className.includes("cb_IQ"))t(e,"پاڵپشتیکراو");else if(document.querySelector("body").className.includes("ar_AR"))t(e,"مُموَّل");else if(document.querySelector("body").className.includes("sz_PL"))t(e,"Szpōnzorowane");else if(document.querySelector("body").className.includes("eo_EO"))t(e,"Reklamo");else if(document.querySelector("body").className.includes("es_LA"))n(e,"P","u","c","d");else if(n(e,"S","p","s","n"),0==o&&0==a&&0==l&&0==r){s=e.querySelectorAll('.userContentWrapper h5 + div[data-testid*="sub"] > span a > [class] [class]');for(socheck=0;socheck<s.length;socheck++)s[socheck].innerText.contains("S")&&(o=1),s[socheck].innerText.contains("p")&&(c=["1"],a=1),s[socheck].innerText.contains("s")&&(i=["1"],l=1),s[socheck].innerText.contains("n")&&(d=["1"],r=1)}}else"be"==h?t(e,"Рэклама"):"bg"==h?t(e,"Спонсорирано"):"mk"==h?t(e,"Спонзорирано"):"br"==h?t(e,"Paeroniet"):"ca"==h?t(e,"Patrocinat"):"gl"==h||"pt"==h?(t(e,"Patrocinado"),"0"==o&&n(e,"P","a","c","o")):"bn"==h?t(e,"সৌজন্যে"):"cb"==h?t(e,"پاڵپشتیکراو"):"cx"==h?n(e,"G","i","s","n"):"cy"==h?t(e,"Noddwyd"):"el"==h?t(e,"Χορηγούμενη"):"eo"==h?t(e,"Reklamo"):"es"==h?n(e,"P","u","c","d"):"eu"==h?t(e,"Babestua"):"fa"==h?t(e,"دارای پشتیبانی مالی"):"ff"==h?t(e,"Yoɓanaama"):"fi"==h?t(e,"Sponsoroitu"):"fo"==h?t(e,"Stuðlað"):"fr"==h?0<g.length?f[0].href.contains("fr_FR")?n(e,"S","p","s","n"):n(e,"C","o","m","n"):document.querySelector("body").className.includes("Locale_fr_FR")?n(e,"S","p","s","n"):n(e,"C","o","m","n"):"ga"==h?t(e,"Urraithe"):"gn"==h?t(e,"Oñepatrosinapyre"):"gu"==h?t(e,"પ્રાયોજિત"):"ha"==h?t(e,"Daukar Nauyi"):"he"==h?t(e,"ממומן"):"hr"==h?t(e,"Plaćeni oglas"):"ht"==h?t(e,"Peye"):"ne"==h||"mr"==h||"hi"==h?t(e,"प्रायोजित"):"hu"==h?n(e,"H","i","r","d"):"hy"==h?t(e,"Գովազդային"):"id"==h?n(e,"B","e","p","n"):"is"==h?t(e,"Kostað"):"ja"==h?t(e,"広告"):"ms"==h?t(e,"Ditaja"):"jv"==h?t(e,"Disponsori"):"ka"==h?t(e,"რეკლამა"):"kk"==h?t(e,"Демеушілік көрсеткен"):"km"==h?t(e,"បានឧបត្ថម្ភ"):"kn"==h?t(e,"ಪ್ರಾಯೋಜಿತ"):"ko"==h?t(e,"Sponsored"):"ky"==h?t(e,"Демөөрчүлөнгөн"):"lo"==h?t(e,"ຜູ້ສະໜັບສະໜູນ"):"lt"==h?t(e,"Remiama"):"lv"==h?t(e,"Apmaksāta reklāma"):"mg"==h?t(e,"Misy Mpiantoka"):"ml"==h?t(e,"സ്പോൺസർ ചെയ്തത്"):"mn"==h?t(e,"Ивээн тэтгэсэн"):"mt"==h?t(e,"Sponsorjat"):"my"==h?(t(e,"ပံ့ပိုးထားသည်"),"0"==o&&t(e,"အခပေးကြော်ငြာ")):"or"==h?t(e,"ପ୍ରଯୋଜିତ"):"pa"==h?t(e,"ਸਰਪ੍ਰਸਤੀ ਪ੍ਰਾਪਤ"):"ps"==h?t(e,"تمويل شوي"):"ro"==h?t(e,"Sponsorizat"):"ru"==h||"uk"==h?t(e,"Реклама"):"rw"==h?t(e,"Icyamamaza ndasukirwaho"):"sc"==h?t(e,"Patronadu de"):"si"==h?t(e,"අනුග්‍රාහක"):"sk"==h?t(e,"Sponzorované"):"sn"==h?t(e,"Zvabhadharirwa"):"so"==h?t(e,"La maalgeliyey"):"sr"==h?t(e,"Спонзорисано"):"sw"==h?t(e,"Imedhaminiwa"):"sy"==h?t(e,"ܒܘܕܩܐ ܡܡܘܘܢܐ"):"sz"==h?t(e,"Szpōnzorowane"):"ta"==h?t(e,"விளம்பரம்"):"te"==h?t(e,"ప్రాయోజితం చేయబడింది"):"tg"==h?t(e,"Бо сарпарастӣ"):"th"==h?t(e,"ได้รับการสนับสนุน"):"tl"==h?t(e,"May Sponsor"):"tr"==h?t(e,"Sponsorlu"):"tt"==h?t(e,"Хәйрияче"):"tz"==h?t(e,"ⵉⴷⵍ"):"ur"==h?t(e,"سپانسرڈ"):"uz"==h?t(e,"Reklama"):"vi"==h?t(e,"Được tài trợ"):"zh-Hans"==h?t(e,"赞助内容"):"zh-Hant"==h&&t(e,"贊助");if(0<s.length&&0<c.length&&0<i.length&&0<d.length){for(cont=0;cont<s.length;cont++)0<s[cont].offsetHeight&&(cont=s.length,o=1);for(cont1=0;cont1<c.length;cont1++)0<c[cont1].offsetHeight&&(cont1=c.length,a=1);for(cont2=0;cont2<i.length;cont2++)0<i[cont2].offsetHeight&&(cont2=i.length,l=1);for(cont3=0;cont3<d.length;cont3++)0<d[cont3].offsetHeight&&(cont3=d.length,r=1);if(1==o&&1==a&&1==l&&1==r){if(0<g.length){if(""==(S=e.querySelectorAll("a[href]")[1].innerText))S=e.querySelectorAll("a[href]")[2].innerText}else S=e.querySelectorAll("a[href]")[2].innerText;m+=1,console.log("--------"),console.log("Ad hidden from: "+S),console.log("Total ads hidden: "+m),console.log("--------"),e.style="display:none!important;"}}}})}),m=0;e.observe(document,{childList:!0,subtree:!0,characterData:!0,attributes:!0})}();
In case someone wonders why I filter according to selected language instead of just running every language element: To avoid false positives.

Some technical information: Facebook is not always setting html attribute "lang" on new interface. On old interface they set attribute "lang" to "eng" for English, therefore additional languages are in section of "en".
 
Top