From a51e8edcafc4fbc995c366015c4a63c6b269c525 Mon Sep 17 00:00:00 2001 From: NopeCharon <115794254+NopeCharon@users.noreply.github.com> Date: Sun, 15 Nov 2026 11:24:48 +0000 Subject: [PATCH] [ReadingTime] Do not estimate a reading time for YouTube videos YouTube feeds do not provide the duration of their videos, only their description. The reading time estimated from that description, usually "<1 m", says nothing about how long it takes to watch the video and is misleading next to the reading times of the other articles. As agreed in the issue, no reading time is shown any longer for articles linking to a YouTube video (youtube.com/watch, /shorts/ and /live/, on www., m., music. or no subdomain, and youtu.be). The link is read from the `data-link` attribute of the article, with a fallback to the link of its title for FreshRSS versions older than 1.28. The cell of the reading time is kept empty, so that the columns of the list of articles stay aligned. Document it in the README, and bump the extension to 1.7.0. Fixes #35 --- xExtension-ReadingTime/README.md | 6 +++-- xExtension-ReadingTime/metadata.json | 2 +- xExtension-ReadingTime/static/readingtime.js | 25 +++++++++++++++----- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/xExtension-ReadingTime/README.md b/xExtension-ReadingTime/README.md index 24fba010..f30517f7 100644 --- a/xExtension-ReadingTime/README.md +++ b/xExtension-ReadingTime/README.md @@ -1,6 +1,6 @@ Extension pour FreshRSS () -> **v1.6** +> **v1.7** Ajoute une estimation du temps de lecture à côté de chaque article. Fonctionne sur les affichages de bureau et mobile. @@ -10,12 +10,13 @@ Aucune module externe. Une fois activée dans les préférences, l'extension doi Un indicateur du temps de lecture doit s'afficher dans le nom du flux de chaque article. Vous pouvez définir la vitesse de lecture et la méthode de mesure du temps de lecture. +Aucun temps de lecture n'est affiché pour les vidéos YouTube, car leur durée n'est pas fournie par le flux. --- Extension for FressRSS () -> **v1.6** +> **v1.7** Add a reading time estimation next to each article. Works on both desktop and mobile displays. @@ -24,3 +25,4 @@ Install it the same way as any other extension, with the integrated tool in the No external module. Once activated in the preferences, this extension should be working after reloading the page. You can set reading speed and source metrics to estimate reading time. +No reading time is shown for YouTube videos, as their duration is not provided by the feed. diff --git a/xExtension-ReadingTime/metadata.json b/xExtension-ReadingTime/metadata.json index f4db9143..d49c5d7a 100644 --- a/xExtension-ReadingTime/metadata.json +++ b/xExtension-ReadingTime/metadata.json @@ -2,7 +2,7 @@ "name": "ReadingTime", "author": "Lapineige, hkcomori", "description": "Add a reading time estimation next to each article", - "version": "1.6.3", + "version": "1.7.0", "entrypoint": "ReadingTime", "type": "user" } diff --git a/xExtension-ReadingTime/static/readingtime.js b/xExtension-ReadingTime/static/readingtime.js index bd4e029d..7b6aa842 100644 --- a/xExtension-ReadingTime/static/readingtime.js +++ b/xExtension-ReadingTime/static/readingtime.js @@ -22,12 +22,17 @@ reading_time.flux = flux_list[i]; - if (metrics == 'letters') { - reading_time.count = reading_time.flux_letters_count(flux_list[i], language); - } else { // words - reading_time.count = reading_time.flux_words_count(flux_list[i]); + if (reading_time.is_youtube_video(flux_list[i])) { + // YouTube feeds provide only the description of the video, which says nothing about how long it takes to watch it + reading_time.reading_time = ''; + } else { + if (metrics == 'letters') { + reading_time.count = reading_time.flux_letters_count(flux_list[i], language); + } else { // words + reading_time.count = reading_time.flux_words_count(flux_list[i]); + } + reading_time.reading_time = reading_time.calc_read_time(reading_time.count, speed); } - reading_time.reading_time = reading_time.calc_read_time(reading_time.count, speed); flux_list[i].dataset.readingTime = reading_time.reading_time; @@ -37,13 +42,21 @@ li.style.overflow = 'hidden'; li.style.textAlign = 'right'; li.style.display = 'table-cell'; - li.textContent = reading_time.reading_time + '\u2009m'; + if (reading_time.reading_time !== '') { // Keep the empty cell of videos, to align the columns of the articles + li.textContent = reading_time.reading_time + '\u2009m'; + } const ul = document.querySelector('#' + reading_time.flux.id + ' ul.horizontal-list'); ul.insertBefore(li, ul.children[ul.children.length - 1]); } }, + is_youtube_video: function is_youtube_video(flux) { + // `data-link` is only available since FreshRSS 1.28 + const link = flux.dataset.link || flux.querySelector('.flux_content .go_website')?.getAttribute('href') || ''; + return /^https?:\/\/(?:(?:(?:www|m|music)\.)?youtube\.com\/(?:watch\?|shorts\/|live\/)|youtu\.be\/)/i.test(link); + }, + flux_words_count: function flux_words_count(flux) { // get textContent, from the article itself (not the header, not the bottom line): reading_time.textContent = flux.querySelector('.flux_content .content').textContent;