LNReader / lnreader

Light novel reader for Android.
https://lnreader.github.io
MIT License
1.79k stars 192 forks source link

CustomJS into exported EPUB applies to epub code making the whole JS script not apply #740

Open Palloxin opened 1 year ago

Palloxin commented 1 year ago

Steps to reproduce

  1. Apply this js in the js editor: https://cdn.discordapp.com/attachments/1055525753325883403/1149714510836408502/script.js
  2. Go to the source Panda Machine translation, Into the creations
  3. Download the first 10 chaps
  4. export the EPUB applying the JS
  5. Test the EPUB with an android reader app like "Lithium", "Aldiko" and "Reasily"

Expected behavior

IMG_20230817_142210

With JS applied this should be the result. It comes directly from the lnreader reader.

Actual behavior

I tested three apps that allow JS on epubs: "Lithium", "Aldiko" and "Reasily";

Lithium: JS applied.. IMG_20230816_140238 JS not applied (upon exporting).. IMG_20230816_132912

Aldiko: JS applied.. IMG_20230817_142757

Reasily: JS applied.. IMG_20230817_132914

You can notice if the js is applied by the presence of 11:00 in the screenshot. When the js is not applied it should be 11 am

LNReader version

1.1.16

Android version

Android 8 miui 8

Device

Huawei p8 lite 2017

Other details

Seems that the JS is not applied as well as lnreader reader.

Acknowledgements

Palloxin commented 1 year ago

Without wasting time in testing i did it and these two pieces of code (together and indipendently) are the cause:

.replace(/(>(\s)?([\'’‘])?|[\!\?\…] ?|[\"”“]|[^\.]\. )([a-z])\B/g, (_,a,b,c,d)=>`${a}${d.toUpperCase()}`)
.replace(/([a-zA-Z])\.\+?([a-z])/g, "$1$2")

The problem with the whole thing is that i can't export JS code that applies properly on lnreader but doesnt outside of it. And if it doesnt, one has to check the JS code like i did and it is very annoying to fix and make sure it is applied properly on the export too.

This is the script file (inside the extracted epub) cleaned https://cdn.discordapp.com/attachments/1055525753325883403/1149713346577322045/script-clean.js

IMG_20230908_162627

ai4hub commented 1 year ago

Hi, how did u apply the js editor

Palloxin commented 1 year ago

@ai4hub If you are asking how i applied it outside lnreader i simply imported the epub created by lnreader (js included) into the three apps i mentioned in the issue