#41 Display NOSCRIPT elements when scripts are blocked or the data-librejs-display attribute is present.
Merged by quidam. Opened by gioma1.
gioma1/librejs feature/conditional-display  into  master

Download 41.patch

This branch implements the feature by which NOSCRIPT elements are forced to be displayed (with the same method used by NoScript and uBlock) whenever script elements have been blocked by LibreJS (except NOSCRIPT elements having the data-librejs-nodisplay attribute), doing the same also on any (non whitelisted) page for any element with the data-librejs-display attribute.
Automated regression tests included.

How does it check if scripts have been blocked? For reference, the logic is:

Show all noscripts if one or more scripts were blocked by librejs
Show all noscripts with attribute data-librejs-display regardless of previous rule
Do not show noscripts with attribute data-librejs-nodisplay regardless of previous rules

How does it check if scripts have been blocked? For reference, the logic is:
Show all noscripts if one or more scripts were blocked by librejs

The forceNoscriptElements() function gets called if and only if libreJS erased some scripts ("if (modifiedInline)"), see https://pagure.io/librejs/pull-request/41#_1__75

Show all noscripts with attribute data-librejs-display regardless of previous rule

The showConditionalElements() function, which shows all the elements (noscript or other, like in your previous patch) with the data-librejs-display attribute, is called regardless every time the document gets processed (https://pagure.io/librejs/pull-request/41#_1__70). It does not happen if the page has been whitelisted, though, because in this case we skip processing outright as an optimization: if you want this to happen on whitelisted pages as well, we will need to remove this optimization.

Do not show noscripts with attribute data-librejs-nodisplay regardless of previous rules
This happens in forceNoscriptElements(), see above.

Excellent, thank you!

Pull-Request has been merged by quidam

Metadata