Weird logic of js on Android "replace "vs "audio"

I have block A
– which replaces br to hr
– which also replaces text in “[” “]” to nothing (on screenshot this code temporarily disabled)

I have block B
– which plays audio


So, on android only one situation works:

SITUATION 1: I delete code with audio (block B), and I see formatted text as I want, with hr, and without text in “[” “]”, but no sound

SITUATION 2:
I have blocks A+B, I hear the sound, but I don’t see text it is disappeared

Why whole text disappear, I don’t understand but this bug is related to commented line (and I get this bug, even if this line commented!)
// exEl.innerHTML = exEl.innerHTML.replace(/\[.*?\]/g, '');

with this line (no problems)
exEl.innerHTML = exEl.innerHTML.replace(/<br\s*\/?>/g, '<hr>');


debug info
AnkiDroid Version = 2.20.0 (d41d16a45c00b0bdbd3b13ac988143db5ef8ae90)

Backend Version = 0.1.48-anki24.11 (24.11 c47638ca36f99dd4f3b81ae82d964aec66e392e0)

Android Version = 10 (SDK 29)

ProductFlavor = play

Manufacturer = Xiaomi

Model = MI 8 Lite

Hardware = qcom

Webview User Agent = Mozilla/5.0 (Linux; Android 10; MI 8 Lite Build/QKQ1.190910.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/131.0.6778.39 Mobile Safari/537.36

ACRA UUID = 1b5403ab-3648-44be-b4ac-e7673657476f

FSRS = 1.4.3 (Enabled: true)

Crash Reports Enabled = true

1 Like

What the solution i found for myself

  1. Firstly I tried to use replacing of content in (…)
    element.innerHTML.replace(/\(.*?\)/g, '');

  2. I tried to replace text in […] with
    exEl.innerHTML.replace(/\[(.*?)\]/g, '');

  3. But WebStorm told me that \] is redundant and better to replace with]
    so I applied:
    exEl.innerHTML.replace(/\[(.*?)]/g, '');

And finally, it helped to format text as I wanted and the audio script works too

But still curious about why don’t work on AnkiDroid
element.innerHTML.replace(/\(.*?\)/g, '');

1 Like