kiwix / kiwix-js

Fully portable & lightweight ZIM reader in Javascript
https://www.kiwix.org/
GNU General Public License v3.0
310 stars 135 forks source link

Display of main article sections broken in Restricted mode for new mobile html endpoint Wikimedia ZIMs #1275

Open Jaifroid opened 3 months ago

Jaifroid commented 3 months ago

For upstream issue, see https://github.com/openzim/mwoffliner/issues/2074. The problem here is that in the source HTML the main article sections other than the first have the display: none; CSS style hard-coded into each <section> tag's style attribute. In ServiceWorker mode, some JS is run to remove that attribute after article load. However, in Restricted mode, no JS runs (it cannot), so the sections remain hidden and cannot be opened.

While this should be fixed upstream (in mwOffliner), we may be forced to deal with it ourselves before the next release if the issue isn't fixed in time.

Cibiyanna26 commented 1 month ago

Hello @Jaifroid,

I have doubts regarding this issue, rather than putting the inline CSS display:none;, will the issue gets resolved if we have a separate css file which targets the section and make it visible which don't rely on javascript.

section {
    display: block !important;
}
Jaifroid commented 1 month ago

@Cibiyanna26 Yes, that could work, but the issue is that however we do it, we would need to inject it into the page somewhere. Note that Kiwix JS is a JavaScript reader, so the app simply won't work if users don't allow JS to run in their browsers. So unhiding the sections in the app by manipulating the DOM content once it is loaded into the iframe would also be viable. I rather think this should be fixed upstream (so that the sections are not unhidden using JS, but those styles are simply removed from the pages scraped in mwOffliner).