From 7374edc0773988ac3de4d0480a1005d5d1c8cd6d Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Fri, 13 Nov 2026 19:56:19 +0000 Subject: Take the giant Google badge out of the reader "Remove giant Google icon", reported on a West Hawaii Today article. It is the "Add as a preferred source on Google" badge that sits beside the byline. Giant because the page caps it at 120px with its own stylesheet and the reader drops the page's CSS, so a small badge on the site becomes a full-width image above the first paragraph. Matched on the link's address rather than the class, and that is forced rather than preferred: running the vendored Readability.js over the real page shows the wrapper's preferred_source_badge class does not survive extraction at all, so a class rule would match nothing. The anchor does survive, and its address is Google's own and identical for every publisher in the programme -- where the badge's image filename sits under this newspaper's theme directory and is not. So the address is both the only signal left and the one that generalises. A link with words in it is never touched. An article may discuss the programme and link to it in a sentence, and that sentence is the author's. Both cleaners now run from one entry point. There are two places a body is cleaned -- a fresh extraction on the way out, a cached one on the way back in -- and a cached article is cleaned in place rather than discarded, so a cleaner wired into only the fresh path would leave every already-read article carrying litter nothing would ever remove. Peter's report says the article was cached, which is exactly that case. Pinned against the real thing: the reported article, put through the real extractor, loses the badge and keeps its text and byline. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_018AwnALZL6bD4VBtATDVv3B --- .../terst/feedreader/readability/ArticleLitter.kt | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 app/src/main/java/org/terst/feedreader/readability/ArticleLitter.kt (limited to 'app/src/main/java/org/terst/feedreader/readability/ArticleLitter.kt') diff --git a/app/src/main/java/org/terst/feedreader/readability/ArticleLitter.kt b/app/src/main/java/org/terst/feedreader/readability/ArticleLitter.kt new file mode 100644 index 0000000..decddc6 --- /dev/null +++ b/app/src/main/java/org/terst/feedreader/readability/ArticleLitter.kt @@ -0,0 +1,24 @@ +package org.terst.feedreader.readability + +/** + * Everything that gets cleaned out of an extracted article body, in one call. + * + * There are two places a body is cleaned -- a fresh extraction on its way out of [EvalDecision], + * and a cached one on its way back in through `loadCachedExtraction` -- and they must stay in + * step. A cached article is cleaned in place rather than discarded, so a cleaner wired into only + * the fresh path would leave every already-read article carrying litter that nothing would ever + * remove: the body is good, so it is never re-fetched. + * + * Hence one entry point rather than a list of calls repeated at both sites. Adding a cleaner here + * reaches both; adding one to a call site reaches one, and which one it misses would depend on + * which file was open at the time. + * + * None of these discard an article. They remove things from inside it, which is why they sit + * apart from [ConsentNotice] and [UnrenderedTex] -- those two decide a body is not worth keeping. + */ +object ArticleLitter { + + /** [html] with the publisher's promo furniture removed. */ + fun strip(html: String?): String? = + PreferredSourceBadge.strip(RecirculationWidgets.strip(html)) +} -- cgit v1.2.3