diff --git a/xExtension-ReadingTime/static/readingtime.js b/xExtension-ReadingTime/static/readingtime.js index f2e2320..7079952 100644 --- a/xExtension-ReadingTime/static/readingtime.js +++ b/xExtension-ReadingTime/static/readingtime.js @@ -13,7 +13,7 @@ init: function() { var flux_list = document.querySelectorAll('[id^="flux_"]'); - console.log(flux_list) + // console.log(flux_list) for (var i = 0; i < flux_list.length; i++) { //console.log($("div[id^='flux']")[i], "Length (words): ", reading_time.flux_words_count($("div[id^='flux']")[i])) @@ -23,15 +23,15 @@ reading_time.words_count = reading_time.flux_words_count(flux_list[i]); // count the words reading_time.reading_time = reading_time.calc_read_time(reading_time.words_count, 300); // change this number (in words) to your prefered reading speed + if (document.body.clientWidth <= 840) { // in mobile mode, the feed name is not visible (there is only the favicon) // add the reading time right before article's title // in that case, [Time] - [Title] format is used instead of a "|" (as it looks better and doesn't take much more space) - if ( document.querySelector("#" + reading_time.flux.id + " ul.horizontal-list li.item.title a").textContent.substring(0,(reading_time.reading_time + 'm - ').length) != reading_time.reading_time + 'm - ' ) { - document.querySelector("#" + reading_time.flux.id + " ul.horizontal-list li.item.title a").textContent = reading_time.reading_time + 'm - ' + document.querySelector("#" + reading_time.flux.id + " ul.horizontal-list li.item.title a").textContent; + if ( $("#" + reading_time.flux.id + " ul.horizontal-list li.item.title a")[0].textContent.substring(0,(reading_time.reading_time + 'm - ').length) != reading_time.reading_time + 'm - ' ) { + $("#" + reading_time.flux.id + " ul.horizontal-list li.item.title a")[0].textContent = reading_time.reading_time + 'm - ' + $("#" + reading_time.flux.id + " ul.horizontal-list li.item.title a")[0].textContent; } } else { // add the reading time just after the feed name - console.log(document.querySelector("#" + reading_time.flux.id + " ul.horizontal-list li.item.website")) if ( document.querySelector("#" + reading_time.flux.id + " ul.horizontal-list li.item.website").textContent.substring(1, (reading_time.reading_time + 'm|').length + 1) != reading_time.reading_time + 'm|' ) { document.querySelector("#" + reading_time.flux.id + " ul.horizontal-list li.item.website").childNodes[0].childNodes[2].textContent = reading_time.reading_time + 'm| ' + document.querySelector("#" + reading_time.flux.id + " ul.horizontal-list li.item.website").childNodes[0].childNodes[2].textContent; } @@ -42,18 +42,20 @@ flux_words_count: function flux_words_count(flux) { - reading_time.textContent = flux.textContent; // get textContent + reading_time.textContent = flux.childNodes[2].childNodes[1].textContent; // get textContent, from the article itself (not the header, not the bottom line). `childNodes[2].childNodes[1]` gives : `