lnreader icon indicating copy to clipboard operation
lnreader copied to clipboard

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

Open Palloxin opened this issue 2 years ago • 3 comments

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

  • [X] I have searched the existing issues and this is a new ticket, NOT a duplicate or related to another open or closed issue.
  • [X] I have written a short but informative title.
  • [X] If this is an issue with a source, I should be opening an issue in the sources repository.
  • [X] I have updated the app to version 1.1.17.
  • [X] I will fill out all of the requested information in this form.

Palloxin avatar Aug 17 '23 12:08 Palloxin

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

Palloxin avatar Sep 08 '23 13:09 Palloxin

Hi, how did u apply the js editor

ai4hub avatar Sep 19 '23 17:09 ai4hub

@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

Palloxin avatar Sep 19 '23 17:09 Palloxin