Are there any addons that can filter and rewrite the DOM before it get rendered by the browser?

Add-ons for Pale Moon and other applications
General discussion, compatibility, contributed extensions, themes, plugins, and more.

Moderators: FranklinDM, Lootyhoof

pmjack
Moongazer
Moongazer
Posts: 14
Joined: 2014-05-23, 00:37
Location: US

Are there any addons that can filter and rewrite the DOM before it get rendered by the browser?

Unread post by pmjack » 2019-03-27, 21:26

I want to filter out stuff on sites before the browser get to it.

Goodydino
Keeps coming back
Keeps coming back
Posts: 827
Joined: 2017-10-10, 21:20

Re: Are there any addons that can filter and rewrite the DOM before it get rendered by the browser?

Unread post by Goodydino » 2019-03-27, 22:54

You can hide some elements from a website, but I doubt that you can block them if they come from the first party. I use uBlock Origin to block annoying elements.

coffeebreak
Moon Magic practitioner
Moon Magic practitioner
Posts: 2986
Joined: 2015-09-26, 04:51
Location: U.S.

Re: Are there any addons that can filter and rewrite the DOM before it get rendered by the browser?

Unread post by coffeebreak » 2019-03-27, 23:13

uBlock Origin supports HTML filters.

Maybe that type of filter will accomplish what you want...?

JustOff

Re: Are there any addons that can filter and rewrite the DOM before it get rendered by the browser?

Unread post by JustOff » 2019-03-28, 10:28

Take a look at Modify HTTP Response, it allows you to change any kind of http response as you like.

coffeebreak wrote:uBlock Origin supports HTML filters.
Are you sure that HTML filters are supported in uB0 legacy? I always thought it was not.

coffeebreak
Moon Magic practitioner
Moon Magic practitioner
Posts: 2986
Joined: 2015-09-26, 04:51
Location: U.S.

Re: Are there any addons that can filter and rewrite the DOM before it get rendered by the browser?

Unread post by coffeebreak » 2019-03-28, 12:54

JustOff wrote:Are you sure that HTML filters are supported in uB0 legacy? I always thought it was not.

Apologies, you're right. I didn't read carefully enough.

pmjack
Moongazer
Moongazer
Posts: 14
Joined: 2014-05-23, 00:37
Location: US

Re: Are there any addons that can filter and rewrite the DOM before it get rendered by the browser?

Unread post by pmjack » 2019-03-30, 21:49

@JustOff
Thanks for this addon!

Is there any example of a working filter? I tried a simple one below, but doesn't seem to work:

Code: Select all

[["addons.palemoon.org",["/addon/modify-http-response/",["<h1>   Modify HTTP Response </h1>","<h1>TEST</h1>"]]]]
Doesn't change anything on that page. I also tried regex matching, but doesn't seem to work either.

JustOff

Re: Are there any addons that can filter and rewrite the DOM before it get rendered by the browser?

Unread post by JustOff » 2019-03-30, 22:33

You need to properly deal with regular expressions:

Code: Select all

[["addons.palemoon.org",["/^\\/addon\\/modify-http-response\\/$/",["/<h1>[\\s\\S]+?Modify HTTP Response[\\s\\S]+?<\\/h1>/","<h1>TEST</h1>"]]]]

pmjack
Moongazer
Moongazer
Posts: 14
Joined: 2014-05-23, 00:37
Location: US

Re: Are there any addons that can filter and rewrite the DOM before it get rendered by the browser?

Unread post by pmjack » 2019-04-17, 10:52

Thanks it works now. I haven't have time to play with it, but what's the performance hit? Does it stop after find the first match or does it keep running until the end of document text?

JustOff

Re: Are there any addons that can filter and rewrite the DOM before it get rendered by the browser?

Unread post by JustOff » 2019-04-17, 12:00

The extension itself has a fairly high performance, but the result depends on how well the filters you create are optimized, especially when using regular expressions.

User avatar
jars_
Lunatic
Lunatic
Posts: 398
Joined: 2016-12-27, 00:12

Re: Are there any addons that can filter and rewrite the DOM before it get rendered by the browser?

Unread post by jars_ » 2019-04-17, 12:29

Silent Block (on\off ext to reload rules)
Sample block rules: (# - comments)
[ contentblock-regex.txt ]

Code: Select all

(?:\W|_)ad(?!%)[sv]+(?:\W|_|\d+)
\Wad(?!%)(?:player|video|proxy\d*|sco|sense|services?|servone|sniper|supply|symptotic|system|trak|visor|wile|wise|wolf|xpansion)[\W_]
# ---------- шаблон ------------------------------------------------------ 
\W\w?(?:\d{0,3})?adserv(?:er|ices)?\W
# ---------- шаблон2 -----------------------------------------------------
(?:mix|\W)adv(?:ert(\w+)?|redirr|ombat|_out)[\W_]
\W\w+advert.com\W
# ---------- шаблон 3 -------------------------------------------------------
\Wt(?:ea|i)(?:s|z)ers?(?:net|bank|media|lady|\.ssl-services)?\W
#------------
\Wclick(?:ganic|under)\W
(?:\W|\d+)banners?(?:\d|\?id)?\W
# -----------
\Wmedia(?:land|metrics|networks?|traffic)\W
# ----- ютуб реклама в видео - видеореклама с желтой полоской --------
\Wyoutube.com\/\S+=adunit&
\Wyoutube.com\/annotations_invideo\?
\Wyoutube.com\/get_midroll_info\?

Sample whitelist rules:
[ contentblock-whitelist-regex.txt ]

Code: Select all

# чтобы работал ВКонтакт переход по секция Обновления, Новости ... верхние три вкладки
^https?:\/\/vk\.com\/al_feed\.php\?ads_section=
#
^https?:\/\/disk\.yandex\.
^https?:\/\/yandex\.(?:ru|ua|com)
=yandex_disk\/
# -------------------------
^http:\/\/whoer\.net\/
^http:\/\/www\.start\.me\/
# == для кнопки перевода ==
#api.microsofttranslator.com
#www.microsofttranslator.com/ajax/v2/widget.aspx?from=_en&toolbar=thin
#labs.microsofttranslator.com/bookmarklet/default.aspx?f=js&to=ru
(?:\w+\.)?microsofttranslator\.com
^https:\/\/addons\.mozilla\.org\/
# ------  флешплеер шобы работал -------------------------
^https?:\/\/jwp(?:ltx|cdn)\.com\/
\/kt_player\/
\/uppod_?\W
# ----------------------------------
# для http://www.adme.ru был там тест кокой-то
\.playbuzz\.com\/
^https:\/\/oauth\.yandex\.
^https?:\/\/addons\.palemoon\.org\/




Locked