Thread: Libra 2 kepub - running Javascript
View Single Post
Old 08-10-2025, 06:16 PM   #1
LPolder
Junior Member
LPolder began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Aug 2025
Device: Kobo Libra 2
kepub - running Javascript

Hi all,
I want to run the following script in my page, but it crashes because kobo sees the "<" sign as the start of a tag (i think)

Quote:
<script type="text/javascript">
function updateTimeText() {
const now = new Date();
const hour = now.getHours();
let greeting;

if (hour < 12) {
greeting = "Good morning!";
} else if (hour < 18) {
greeting = "Good afternoon!";
} else {
greeting = "Good night!";
}
document.getElementById("weathertime").textContent = greeting + " it is now " + now.toLocaleTimeString();
}
</script>
It does not seem to replace the text on my page with the correct greeting and time, what am i doing wrong? Adding the //<![CDATA[ tags doesn't seem to change anything.

it does work on an ereader in my browser
LPolder is offline   Reply With Quote