feedkeeper 0.38.1 → 0.38.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "feedkeeper",
3
- "version": "0.38.1",
3
+ "version": "0.38.3",
4
4
  "description": "A lightweight, self-hosted RSS reader and remote MCP server for your news, blogs, and AI workflows.",
5
5
  "keywords": [
6
6
  "rss",
@@ -49,9 +49,9 @@
49
49
  "fast-xml-parser": "^5.12.0",
50
50
  "helmet": "^8.3.0",
51
51
  "ipaddr.js": "^2.5.0",
52
- "jsdom": "^30.1.3",
52
+ "jsdom": "^31.0.1",
53
53
  "node-cron": "^4.6.0",
54
- "otpauth": "^9.5.2",
54
+ "otpauth": "^9.6.0",
55
55
  "rss-parser": "^3.13.0",
56
56
  "undici": "^8.12.3",
57
57
  "web-push": "^3.6.7",
@@ -1,4 +1,4 @@
1
- import { BOILERPLATE_ANYWHERE, BOILERPLATE_TRAILING } from "../patterns/boilerplate/index.js";
1
+ import { BOILERPLATE_ANYWHERE, BOILERPLATE_NEWSLETTER, BOILERPLATE_TRAILING } from "../patterns/boilerplate/index.js";
2
2
  import { count, flat, pruneEmpty } from "../shared.js";
3
3
  const BLOCKS = "p, div, li, h2, h3, h4, h5, h6, span";
4
4
  const NESTED = "p, div, li, ul, ol, h2, h3, h4, h5, h6";
@@ -48,8 +48,24 @@ export const boilerplate = {
48
48
  let changed = false;
49
49
  const total = flat(root.textContent).length;
50
50
  for (const block of [...root.querySelectorAll(BLOCKS)]) {
51
- if (!root.contains(block) || block.querySelector("img, picture, video, audio, iframe") || block.querySelector(NESTED))
51
+ if (!root.contains(block) || block.querySelector("video, audio, iframe") || block.querySelector(NESTED))
52
52
  continue;
53
+ const images = block.querySelectorAll("img");
54
+ if (images.length > 1)
55
+ continue;
56
+ if (images.length === 1) {
57
+ if (flat(block.textContent) !== "")
58
+ continue;
59
+ const alt = flat(images[0].getAttribute("alt"));
60
+ if (!alt || alt.length > 200 || !BOILERPLATE_ANYWHERE.some(pattern => pattern.test(alt)))
61
+ continue;
62
+ const parent = block.parentNode;
63
+ block.remove();
64
+ pruneEmpty(parent);
65
+ count(stats, "boilerplate");
66
+ changed = true;
67
+ continue;
68
+ }
53
69
  const text = flat(block.textContent);
54
70
  if (text === "" || text.length > 400)
55
71
  continue;
@@ -66,9 +82,33 @@ export const boilerplate = {
66
82
  }
67
83
  if (inlineCalls(root, stats))
68
84
  changed = true;
85
+ if (newsletterBoxes(root, stats))
86
+ changed = true;
69
87
  return lineFooters(root, stats, total) || changed;
70
88
  },
71
89
  };
90
+ /**
91
+ * Signup boxes ("Subscribe to our newsletter") hold a `<form>` or email field that Readability later strips,
92
+ * leaving only the promotional copy behind. Removing the whole short container before Readability keeps the copy out too.
93
+ */
94
+ function newsletterBoxes(root, stats) {
95
+ let changed = false;
96
+ for (const box of [...root.querySelectorAll("section, aside, div")]) {
97
+ if (!root.contains(box) || box.querySelector("article, main"))
98
+ continue;
99
+ if (!box.querySelector("form, input[type='email']"))
100
+ continue;
101
+ const text = flat(box.textContent);
102
+ if (text === "" || text.length > 500 || !BOILERPLATE_NEWSLETTER.some(pattern => pattern.test(text)))
103
+ continue;
104
+ const parent = box.parentNode;
105
+ box.remove();
106
+ pruneEmpty(parent);
107
+ count(stats, "boilerplate");
108
+ changed = true;
109
+ }
110
+ return changed;
111
+ }
72
112
  /** A short line holds more than the call ("November 12, 2026 · Add as a preferred source on Google"): longer text is prose and is left alone. */
73
113
  const SHORT_LINE = 200;
74
114
  /**
@@ -4,17 +4,21 @@
4
4
  */
5
5
  export const ANYWHERE = [
6
6
  // Aufrufe, der Seite bei Google oder in anderen Diensten zu folgen.
7
- /^(?:Uns|Folge uns|Folgen Sie uns) (?:auf|bei) Google(?: News| Discover)? folgen$/i,
8
- /^(?:Wähle|Wählen Sie|Füge|Fügen Sie) [^.!?]{2,50} (?:als )?(?:bevorzugte|bevorzugten|bevorzugter)\b[^.!?]{0,30}$/i,
7
+ /^(?:Uns|Folge uns|Folgen Sie uns|[^.!?]{2,40}) (?:auf|bei) Google(?: News| Discover)? folgen$/i,
8
+ /^(?:Wähle|Wählen Sie|Füge|Fügen Sie) [^.!?]{2,50} (?:als |bei Google als )?(?:bevorzugte|bevorzugten|bevorzugter)\b[^.!?]{0,80}\.?$/i,
9
9
  // „Als bevorzugte Quelle bei Google hinzufügen“, ohne den Namen der Seite.
10
10
  /^Als bevorzugte[nr]? (?:Google-)?Quelle (?:bei Google )?(?:hinzufügen|auswählen|wählen)$/i,
11
11
  // „★ ifun.de bei Google bevorzugen ★“ und ähnliche Bitten, die Seite als bevorzugte Quelle zu wählen.
12
12
  /^★?\s*[^★!?]{2,40} bei Google bevorzugen\s*★?$/i,
13
13
  // Texte von Download-Schaltflächen, deren Grafik nicht mehr da ist.
14
- /^(?:Laden im (?:App|Mac App|Google Play) Store|Im (?:App|Mac App) Store laden|Jetzt bei Google Play|Bei Google Play herunterladen|Laden bei Google Play)$/i,
14
+ /^(?:Laden im (?:App|Mac App|Google Play) Store|Im (?:App|Mac App) Store laden|Jetzt bei Google Play|Bei Google Play herunterladen|Laden bei Google Play|[^.!?]{2,40} für (?:Android|iOS|iPhone|iPad) bei Google Play)$/i,
15
15
  // Der Dateiname eines Bildes, den ein Link oder eine Beschriftung als Text zeigt.
16
16
  /^[\w\-. ]{3,120}\.(?:jpe?g|png|webp|gif|avif)$/i,
17
17
  ];
18
+ /** Verwaiste Empfehlungs-/Rubrik-Überschriften ohne nachfolgende Liste. */
19
+ export const ORPHAN_HEADINGS = [
20
+ /^(?:Topaktuell|Mehr zum Thema|Weitere (?:Artikel|Meldungen)|Ähnliche Artikel|Verwandte Artikel|Auch interessant|Meistgelesen(?:e Artikel)?|Beliebte Artikel)$/i,
21
+ ];
18
22
  /** Fußzeilen am Ende des Textes; sie zählen nur in der zweiten Hälfte. */
19
23
  export const TRAILING = [
20
24
  /^(?:Der Beitrag|Dieser Beitrag|Der Artikel|Dieser Artikel) .{3,200} (?:erschien|erschien zuerst|erschien erstmals) (?:zuerst )?(?:auf|bei) .{2,60}$/i,
@@ -22,7 +26,12 @@ export const TRAILING = [
22
26
  /^Diskutiere (?:diesen|den) (?:Artikel|Beitrag) .{0,40}$/i,
23
27
  // Autoren-Follow-Zeilen am Artikelende.
24
28
  /^(?:Folge|Folgen Sie)\s+[^.!?]{1,60}:\s*(?:X(?:\s*\/\s*Twitter)?|Twitter|Bluesky|Mastodon|Threads|Instagram|Facebook|YouTube|LinkedIn|TikTok|RSS)\b.{0,120}$/i,
25
- // Verwaiste Empfehlungs-/Rubrik-Überschriften am Artikelende ohne nachfolgende Liste.
26
- /^(?:Topaktuell|Mehr zum Thema|Weitere (?:Artikel|Meldungen)|Ähnliche Artikel|Verwandte Artikel|Auch interessant|Meistgelesen(?:e Artikel)?|Beliebte Artikel)$/i,
29
+ ...ORPHAN_HEADINGS,
30
+ // Aufrufe am Artikelende, der Seite bei Google News zu folgen oder die App herunterzuladen.
31
+ /^(?:Noch mehr [^.!?]{2,50}\?\s*)?(?:Dann\s+)?(?:folge|folgen Sie)\s+[^.!?]{2,50}\s+(?:bei|auf)\s+Google(?:\s+News|\s+Discover)?(?:\s+oder\s+(?:hol|holen Sie)\s+(?:dir|sich)\s+unsere\s+App)?\.?$/i,
32
+ ];
33
+ /** Hinweise einer Newsletter-Anmeldebox (Container mit Formular vor Readability oder verwaiste Box danach). */
34
+ export const NEWSLETTER_BOX = [
35
+ /(?:\b(?:täglicher?|wöchentlicher?|monatlicher?|kostenloser?)\b.{0,30}Newsletter|\bNewsletter.{0,120}(?:Postfach|E-Mail|anmelden|abonnieren|kostenlos))/i,
27
36
  ];
28
37
  //# sourceMappingURL=de.js.map
@@ -4,9 +4,16 @@
4
4
  */
5
5
  export const ANYWHERE = [
6
6
  // Calls to follow the site on Google or elsewhere.
7
- /^(?:Follow us on Google(?: News| Discover)?|Add(?: [^.!?]{2,50})? as a preferred (?:source|publisher)(?: on Google)?)$/i,
7
+ /^(?:Follow us|Follow [^.!?]{2,40}) on Google(?: News| Discover)?$/i,
8
+ /^Add(?: [^.!?]{2,50})? as a preferred (?:source|publisher)(?: on Google)?[^.!?]{0,80}\.?$/i,
8
9
  // The text of download buttons whose picture is gone.
9
- /^(?:Download on the (?:App|Mac App) Store|Get it on Google Play|Available on Google Play)$/i,
10
+ /^(?:Download on the (?:App|Mac App) Store|Get it on Google Play|Available on Google Play|[^.!?]{2,40} (?:for Android )?on Google Play)$/i,
11
+ // A picture's filename shown as text.
12
+ /^[\w\-. ]{3,120}\.(?:jpe?g|png|webp|gif|avif)$/i,
13
+ ];
14
+ /** Orphaned recommendation headings without a following list. */
15
+ export const ORPHAN_HEADINGS = [
16
+ /^(?:Top Stories|Trending(?: Now| Stories)?|More (?:Stories|Articles)|Related (?:Articles|Stories|Posts)|Most (?:Read|Popular)|Recommended(?: for you)?)$/i,
10
17
  ];
11
18
  /** Footers at the end of the text; they count only in the second half. */
12
19
  export const TRAILING = [
@@ -19,7 +26,12 @@ export const TRAILING = [
19
26
  /^Follow topics and authors from this story\b.{0,200}$/i,
20
27
  // Author social follow lines at the end of an article.
21
28
  /^Follow [^.!?]{1,60}:\s*(?:X(?:\s*\/\s*Twitter)?|Twitter|Bluesky|Mastodon|Threads|Instagram|Facebook|YouTube|LinkedIn|TikTok|RSS)\b.{0,120}$/i,
22
- // Orphaned recommendation headings at the end of an article when the list itself was stripped or empty.
23
- /^(?:Top Stories|Trending(?: Now| Stories)?|More (?:Stories|Articles)|Related (?:Articles|Stories|Posts)|Most (?:Read|Popular)|Recommended(?: for you)?)$/i,
29
+ ...ORPHAN_HEADINGS,
30
+ // Calls at the end of an article to follow on Google News or download the app.
31
+ /^(?:Want more [^.!?]{2,50}\?\s*)?(?:Then\s+)?follow\s+[^.!?]{2,50}\s+on\s+Google(?:\s+News|\s+Discover)?(?:\s+or\s+(?:get|download)\s+our\s+app)?\.?$/i,
32
+ ];
33
+ /** Copy of a newsletter signup box (container with a form before Readability, or orphaned box afterwards). */
34
+ export const NEWSLETTER_BOX = [
35
+ /(?:\b(?:daily|weekly|monthly|free)\b.{0,30}newsletter|\bnewsletter.{0,120}(?:inbox|e-?mail|subscribe|sign up|free))/i,
24
36
  ];
25
37
  //# sourceMappingURL=en.js.map
@@ -4,4 +4,6 @@ import * as ja from "./ja.js";
4
4
  /** One file per language, searched all at once. To add a language, add a file next to these and list it here. */
5
5
  export const BOILERPLATE_ANYWHERE = [de.ANYWHERE, en.ANYWHERE, ja.ANYWHERE].flat();
6
6
  export const BOILERPLATE_TRAILING = [de.TRAILING, en.TRAILING, ja.TRAILING].flat();
7
+ export const BOILERPLATE_NEWSLETTER = [de.NEWSLETTER_BOX, en.NEWSLETTER_BOX, ja.NEWSLETTER_BOX].flat();
8
+ export const BOILERPLATE_ORPHAN_HEADINGS = [de.ORPHAN_HEADINGS, en.ORPHAN_HEADINGS, ja.ORPHAN_HEADINGS].flat();
7
9
  //# sourceMappingURL=index.js.map
@@ -4,13 +4,17 @@
4
4
  */
5
5
  export const ANYWHERE = [
6
6
  // Calls to follow the site on Google or elsewhere.
7
- /^(?:Google(?: ニュース)?でフォロー(?:する)?|Google ニュースで[^.!?]{2,40}をフォロー)$/i,
8
- /^(?:Googleで)?優先(?:ソース|的なソース)(?:として|に)(?:追加|設定)(?:する)?$/i,
7
+ /^(?:Google(?: ニュース)?でフォロー(?:する)?|Google ニュースで[^.!?。]{2,40}をフォロー)$/i,
8
+ /^(?:Googleで)?[^.!?。]{0,40}優先(?:ソース|的なソース)(?:として|に)(?:追加|設定)(?:する)?[^.!?。]{0,60}[。.]?$/i,
9
9
  // The text of download buttons whose picture is gone.
10
- /^(?:App Storeからダウンロード|Google Playで手に入れよう|Google Playで入手|App Storeでダウンロード)$/i,
10
+ /^(?:App Storeからダウンロード|Google Playで手に入れよう|Google Playで入手|App Storeでダウンロード|Google Playで[^.!?。]{2,40}を入手)$/i,
11
11
  // A picture's filename shown as text.
12
12
  /^[\w\-. ]{3,120}\.(?:jpe?g|png|webp|gif|avif)$/i,
13
13
  ];
14
+ /** Orphaned recommendation headings without a following list. */
15
+ export const ORPHAN_HEADINGS = [
16
+ /^(?:関連記事|おすすめ記事|オススメ記事|人気の記事|人気記事|最新記事|新着記事|注目の記事)$/i,
17
+ ];
14
18
  /** Footers at the end of the text; they count only in the second half. */
15
19
  export const TRAILING = [
16
20
  /^(?:この記事|本記事|本稿).{3,120}(?:で初出|に初出|で公開|に掲載|転載).*$/i,
@@ -18,7 +22,12 @@ export const TRAILING = [
18
22
  /^(?:関連記事|トピック|タグ|関連タグ):.{0,200}$/i,
19
23
  // Author social follow lines at the end of an article.
20
24
  /^[^.!?。]{1,40}(?:をフォロー|のSNS)\s*[::]\s*(?:X(?:\s*\/\s*Twitter)?|Twitter|Bluesky|Mastodon|Threads|Instagram|Facebook|YouTube|LinkedIn|TikTok|RSS)\b.{0,120}$/i,
21
- // Orphaned recommendation headings at the end of an article when the list itself was stripped or empty.
22
- /^(?:関連記事|おすすめ記事|オススメ記事|人気の記事|人気記事|最新記事|新着記事|注目の記事)$/i,
25
+ ...ORPHAN_HEADINGS,
26
+ // Calls at the end of an article to follow on Google News or download the app.
27
+ /^(?:さらに[^.!?。]{2,40}[??]\s*)?(?:Google(?:ニュース|ディスカバー)?で[^.!?。]{2,40}をフォロー(?:するか、公式アプリを入手)?|公式アプリを入手)[。.]?$/i,
28
+ ];
29
+ /** Copy of a newsletter signup box (container with a form before Readability, or orphaned box afterwards). */
30
+ export const NEWSLETTER_BOX = [
31
+ /(?:(?:日刊|週刊|月刊|無料).{0,20}(?:ニュースレター|メルマガ)|(?:ニュースレター|メルマガ).{0,60}(?:登録|購読|受信|メールボックス|無料))/,
23
32
  ];
24
33
  //# sourceMappingURL=ja.js.map
@@ -11,17 +11,18 @@ export default {
11
11
  /Hier findest du externe Inhalte von/i,
12
12
  /An dieser Stelle findest du einen externen Inhalt/i,
13
13
  /Du kannst ihn dir mit einem Klick anzeigen lassen/i,
14
+ /Mit (?:Ihrer|deiner) Zustimmung wird (?:hier )?ein externes? .{0,60} geladen/i,
14
15
  ],
15
16
  companions: [
16
17
  /\bInhalte? (von \S+ )?erlauben\b/i,
17
18
  /-Inhalte erlauben\b/i,
18
- /^Ich bin damit einverstanden, dass mir .+ angezeigt (?:wird|werden)/i,
19
+ /Ich bin damit einverstanden, dass mir .{0,80} angezeigt (?:wird|werden)/i,
19
20
  /Erst wenn Sie (?:hier )?klicken, werden .{0,60}nachgeladen/i,
20
21
  /^Externen? Inhalt(?:e)? anzeigen$/i,
21
22
  /^Inhalte? (?:ansehen|anzeigen)$/i,
22
- /Personenbezogene Daten können an Drittplattformen/i,
23
+ /Personenbezogene Daten (?:können|werden) an Drittplattformen/i,
23
24
  /^Link zum .+-Inhalt$/i,
24
- /^Mehr dazu in unserer Datenschutzerklärung/i,
25
+ /Mehr dazu in unserer Datenschutzerklärung/i,
25
26
  ],
26
27
  };
27
28
  //# sourceMappingURL=de.js.map
@@ -1,15 +1,18 @@
1
1
  /** Consent notices that sit where an embed would be, in English. See `de.ts` for what the two lists mean. */
2
2
  export default {
3
3
  anchors: [
4
- /^(?:Recommended|Featured) editorial content$/i,
4
+ /^(?:Recommended|Featured) editorial content\b/i,
5
5
  /^External content$/i,
6
- /^Content from (?:YouTube|Vimeo|Instagram|X|Twitter|TikTok|Spotify|Facebook)$/i,
6
+ /^Content from (?:YouTube|Vimeo|Instagram|X|Twitter|TikTok|Spotify|Facebook)\b/i,
7
7
  /^(?:Show|Load|Allow) external content$/i,
8
+ /Here you can find external content from/i,
9
+ /With your consent,?\s+(?:an? )?external .{0,60}(?:will be|is) loaded/i,
8
10
  ],
9
11
  companions: [
10
- /^I agree (?:to|that) .{0,80}(?:external|third[- ]party) content/i,
11
- /^Personal data (?:may|can) be (?:transmitted|transferred|shared) to third[- ]party/i,
12
+ /\bI agree (?:to|that) .{0,80}(?:external|third[- ]party) content/i,
13
+ /\bPersonal data (?:may|can|will) be (?:transmitted|transferred|shared) to third[- ]part/i,
12
14
  /^(?:Show|Load|Allow|Display) content$/i,
15
+ /\bMore information in our privacy policy/i,
13
16
  ],
14
17
  };
15
18
  //# sourceMappingURL=en.js.map
@@ -1,12 +1,13 @@
1
1
  /** Consent notices that sit where an embed would be, in Japanese. See `de.ts` for what the two lists mean. */
2
2
  export default {
3
3
  anchors: [
4
- /^(?:外部コンテンツ|おすすめの外部コンテンツ|埋め込みコンテンツ)$/i,
5
- /^(?:YouTube|Vimeo|Instagram|X|Twitter|TikTok|Spotify|Facebook)のコンテンツ$/i,
4
+ /^(?:外部コンテンツ|おすすめの外部コンテンツ|埋め込みコンテンツ)(?:$|\s|。)/i,
5
+ /^(?:YouTube|Vimeo|Instagram|X|Twitter|TikTok|Spotify|Facebook)のコンテンツ/i,
6
6
  /^(?:外部コンテンツを表示|コンテンツを表示|外部コンテンツを読み込む)$/i,
7
+ /同意すると.{0,40}外部.{0,30}読み込まれます/,
7
8
  ],
8
9
  companions: [
9
- /^(?:外部コンテンツの読み込みに同意する|同意して表示|コンテンツを表示する)$/i,
10
+ /(?:外部コンテンツの読み込みに同意する|外部コンテンツの表示に同意|同意して表示|コンテンツを表示する)/i,
10
11
  /個人データが(?:外部|サードパーティ)/i,
11
12
  /プライバシーポリシー/i,
12
13
  ],
@@ -1,4 +1,4 @@
1
1
  /** Wrappers of the consent plugins that hold back an embed until the reader agrees. The embed itself sits inside, escaped. */
2
2
  export const CONSENT_WRAPPER = ".embed-privacy-container, [data-embed-provider], .cmplz-blocked-content-container, .borlabs-cookie, " +
3
- "[data-borlabs-cookie-content], .rcb-content-blocker, [data-rcb-blocker-id]";
3
+ "[data-borlabs-cookie-content], .rcb-content-blocker, [data-rcb-blocker-id], a-opt-in";
4
4
  //# sourceMappingURL=wrappers.js.map
@@ -2,9 +2,12 @@ import { cleanVideoPage } from "./content/noise/videoPages.js";
2
2
  import { lazyImages } from "./content/noise/lazyImages.js";
3
3
  import { JSDOM } from "jsdom";
4
4
  import { SNIPPET_BYLINES, SNIPPET_IMAGE_METADATA } from "./content/patterns/snippet-metadata/index.js";
5
+ import { BOILERPLATE_NEWSLETTER, BOILERPLATE_ORPHAN_HEADINGS } from "./content/patterns/boilerplate/index.js";
5
6
  import { CONSENT_ANCHORS, CONSENT_COMPANIONS } from "./content/patterns/consent/index.js";
6
7
  import { SIDEBAR_HEADINGS } from "./content/patterns/sidebars/index.js";
7
8
  import { resolveEmbeds } from "./content/embeds/index.js";
9
+ import { embedTarget } from "./content/embeds/video.js";
10
+ import { socialFrameTarget } from "./content/embeds/social.js";
8
11
  import { loadingPlaceholders } from "./content/noise/loading.js";
9
12
  import { trackingPixels } from "./content/noise/pixels.js";
10
13
  import { emptyContents } from "./content/noise/emptyContents.js";
@@ -13,7 +16,7 @@ import { permalinkGlyphs } from "./content/noise/permalinkGlyphs.js";
13
16
  import { stateHidden } from "./content/noise/stateHidden.js";
14
17
  import { teaserLinks } from "./content/noise/teaserLinks.js";
15
18
  import { markVideoTeasers } from "./content/noise/videoTeasers.js";
16
- import { flat, pruneEmpty } from "./content/shared.js";
19
+ import { flat, linkParagraph, pruneEmpty } from "./content/shared.js";
17
20
  /**
18
21
  * Publisher pages carry page chrome inside the article body: breadcrumbs, dateline repeats, player leftovers,
19
22
  * recommendation lists, follow prompts. This module removes it in two layers that follow one principle:
@@ -38,7 +41,7 @@ function charsBefore(root, element) {
38
41
  const range = root.ownerDocument.createRange();
39
42
  range.setStart(root, 0);
40
43
  range.setEndBefore(element);
41
- return range.toString().length;
44
+ return flat(range.toString()).length;
42
45
  }
43
46
  const BREADCRUMB_MARKERS = [
44
47
  "[aria-label*='breadcrumb' i]",
@@ -215,6 +218,7 @@ function removeReaderNoise(root, title, stats, author) {
215
218
  }
216
219
  const headline = normalized(title ?? "");
217
220
  const seen = new Set();
221
+ const authorHref = /\/(?:authors?|autoren?|korrespondenten?|correspondents?|redaktion|journalists?|writers?|contributors?|staff|team|profiles?|people|著者)\//i;
218
222
  const authorKeys = (author ?? "").split(",").map(name => normalized(name)).filter(Boolean);
219
223
  if (authorKeys.length > 0) {
220
224
  for (const box of [...root.querySelectorAll("div, section, aside")]) {
@@ -228,12 +232,12 @@ function removeReaderNoise(root, title, stats, author) {
228
232
  const images = [...box.querySelectorAll("img")];
229
233
  if (images.length > 1)
230
234
  continue;
235
+ const hasAuthorLink = [...box.querySelectorAll("a[href]")].some(a => authorHref.test(a.getAttribute("href") ?? ""));
231
236
  const hasSmallAvatar = images.length === 1 && (() => {
232
237
  const w = Number(images[0].getAttribute("width") ?? 0);
233
238
  const h = Number(images[0].getAttribute("height") ?? 0);
234
- return (w > 0 && w <= 96 && h > 0 && h <= 96) || Boolean(box.querySelector('a[href*="/author/"], a[href*="/authors/"]'));
239
+ return (w > 0 && w <= 96 && h > 0 && h <= 96) || hasAuthorLink;
235
240
  })();
236
- const hasAuthorLink = Boolean(box.querySelector('a[href*="/author/"], a[href*="/authors/"]'));
237
241
  const hasAuthorNameBlock = [...box.querySelectorAll("p, span, div, a, strong")].some(el => {
238
242
  const t = normalized(flat(el.textContent));
239
243
  return t.length > 0 && authorKeys.includes(t);
@@ -243,6 +247,26 @@ function removeReaderNoise(root, title, stats, author) {
243
247
  }
244
248
  }
245
249
  }
250
+ // Standalone author avatar near the start (linked to an author/correspondent profile, no caption or prose).
251
+ for (const block of [...root.querySelectorAll("p, div")]) {
252
+ if (!root.contains(block) || charsBefore(root, block) > 600)
253
+ continue;
254
+ if (block.querySelector("p, div, figcaption, h1, h2, h3, h4, h5, h6"))
255
+ continue;
256
+ if (flat(block.textContent) !== "")
257
+ continue;
258
+ const images = [...block.querySelectorAll("img")];
259
+ if (images.length !== 1)
260
+ continue;
261
+ const link = images[0].closest("a[href]");
262
+ if (!link || !authorHref.test(link.getAttribute("href") ?? ""))
263
+ continue;
264
+ const alt = flat(images[0].getAttribute("alt"));
265
+ const w = Number(images[0].getAttribute("width") ?? 0);
266
+ const isShortName = alt.length >= 2 && alt.length <= 50 && !/[.!?。]/.test(alt) && alt.split(" ").length <= 5;
267
+ if (isShortName || (w > 0 && w <= 160))
268
+ drop(block, "author-avatar");
269
+ }
246
270
  const cleanByline = (block, text) => {
247
271
  if (!BYLINE.test(text))
248
272
  return;
@@ -333,10 +357,14 @@ function removeReaderNoise(root, title, stats, author) {
333
357
  drop(block, "separator");
334
358
  continue;
335
359
  }
336
- if (/^(Audiobeitrag|Videobeitrag|Autoplay)$/i.test(text) || (position < 8 && /^Bild$/.test(text))) {
360
+ if (/^(Audiobeitrag|Videobeitrag|Bildbeitrag|Autoplay)$/i.test(text) || (position < 8 && /^(Bild|Photo|写真)$/i.test(text))) {
337
361
  drop(block, "player");
338
362
  continue;
339
363
  }
364
+ if (!block.querySelector("img, picture, video, audio, iframe") && /^[\w\-. ]{3,120}\.(?:jpe?g|png|webp|gif|avif)$/i.test(text)) {
365
+ drop(block, "filename");
366
+ continue;
367
+ }
340
368
  if (!pastStart && text.length <= 70 && block.querySelector("time") && charsBefore(root, block) <= 600) {
341
369
  const rest = flat(text.replace(flat(block.querySelector("time")?.textContent), ""));
342
370
  if (/^(news|ニュース|nachrichten|stand|zuletzt aktualisiert|aktualisiert|ver(ö|oe)ffentlicht|updated|published|posted)?\s*[:·|•-]*\s*$/i.test(rest)) {
@@ -426,12 +454,50 @@ function removeReaderNoise(root, title, stats, author) {
426
454
  // Readability may remove the empty slot, leaving only its enclosing block and label paragraph.
427
455
  const isolated = container.matches("div, aside, section") && container.querySelector("p") &&
428
456
  (product || AD_SLOT_LABEL.test(text));
457
+ const standaloneBox = container.matches("aside, section") && AD_SLOT_LABEL.test(text) && !product;
429
458
  const next = container.nextElementSibling;
430
459
  const nextHasMedia = next && (next.matches("img, picture, iframe, video, audio, a[href]") ||
431
460
  next.querySelector("img, picture, iframe, video, audio, a[href]"));
432
- if (emptySlot || (isolated && !nextHasMedia))
461
+ if (emptySlot || standaloneBox || (isolated && !nextHasMedia))
433
462
  drop(container, product ? "empty-product-label" : "empty-ad-label");
434
463
  }
464
+ // Orphaned newsletter signup boxes in the second half whose `<form>` was already stripped during extraction.
465
+ if (total > 0) {
466
+ for (const box of [...root.querySelectorAll("section, aside, div")]) {
467
+ if (!box.parentNode || box.querySelector("article, main, img, picture, video, audio, iframe"))
468
+ continue;
469
+ if (box.querySelectorAll("p, h2, h3, h4").length < 2)
470
+ continue;
471
+ const text = flat(box.textContent);
472
+ if (text === "" || text.length > 400 || charsBefore(root, box) / total < 0.5)
473
+ continue;
474
+ if (BOILERPLATE_NEWSLETTER.some(pattern => pattern.test(text)))
475
+ drop(box, "newsletter-box");
476
+ }
477
+ }
478
+ // Orphaned recommendation headings in the second half (left behind when an embed/related-links widget was empty).
479
+ if (total > 0) {
480
+ for (const block of [...root.querySelectorAll("p, h2, h3, h4")]) {
481
+ if (!block.parentNode || block.querySelector("img, picture, video, audio, iframe, a[href]"))
482
+ continue;
483
+ const text = flat(block.textContent);
484
+ if (!text || charsBefore(root, block) / total < 0.5 || !BOILERPLATE_ORPHAN_HEADINGS.some(p => p.test(text)))
485
+ continue;
486
+ let after = block.nextElementSibling;
487
+ while (after?.tagName === "HR")
488
+ after = after.nextElementSibling;
489
+ const hasList = after && (after.matches("ul, ol") || Boolean(after.querySelector("ul, ol, a[href]")) && flat(after.textContent).length < 240 && !after.matches("h1, h2, h3, h4, h5, h6, p"));
490
+ if (hasList)
491
+ continue;
492
+ const prev = block.previousElementSibling;
493
+ const next = block.nextElementSibling;
494
+ if (prev?.tagName === "HR")
495
+ prev.remove();
496
+ if (next?.tagName === "HR")
497
+ next.remove();
498
+ drop(block, "orphan-heading");
499
+ }
500
+ }
435
501
  // An ad label whose ad is not there (a script fills it): sponsored content itself stays, the label above nothing goes.
436
502
  const labelled = leafBlocks(root);
437
503
  labelled.forEach((block, index) => {
@@ -445,17 +511,63 @@ function removeReaderNoise(root, title, stats, author) {
445
511
  drop(block, "empty-ad-label");
446
512
  });
447
513
  // Consent placeholders of embedded third-party content: only the neighbours of a known anchor phrase go.
514
+ // A single block may hold the whole notice (up to 800 chars) when both an anchor and a companion phrase match;
515
+ // if it also carries a known video or social link, keep that as a marked media card.
448
516
  const blocks = leafBlocks(root);
449
517
  blocks.forEach((block, index) => {
450
- if (!block.parentNode || flat(block.textContent).length > 400 || !CONSENT_ANCHORS.some(pattern => pattern.test(flat(block.textContent))))
518
+ if (!block.parentNode)
519
+ return;
520
+ const blockText = flat(block.textContent);
521
+ const hasAnchor = CONSENT_ANCHORS.some(pattern => pattern.test(blockText));
522
+ if (!hasAnchor)
451
523
  return;
452
- drop(block, "consent-placeholder");
524
+ if (blockText.length > 800)
525
+ return;
526
+ if (blockText.length > 400 && !CONSENT_COMPANIONS.some(pattern => pattern.test(blockText)))
527
+ return;
528
+ const matched = [block];
453
529
  for (const next of blocks.slice(index + 1, index + 7)) {
454
530
  const text = flat(next.textContent);
455
531
  if (!next.parentNode || text.length > 220)
456
532
  break;
457
- if (CONSENT_ANCHORS.some(pattern => pattern.test(text)) || CONSENT_COMPANIONS.some(pattern => pattern.test(text)))
458
- drop(next, "consent-placeholder");
533
+ if (CONSENT_ANCHORS.some(pattern => pattern.test(text)) || CONSENT_COMPANIONS.some(pattern => pattern.test(text))) {
534
+ matched.push(next);
535
+ }
536
+ }
537
+ let media = null;
538
+ for (const element of matched) {
539
+ for (const link of element.querySelectorAll("a[href]")) {
540
+ const href = link.getAttribute("href") ?? "";
541
+ const video = embedTarget(href);
542
+ if (video) {
543
+ media = { url: video.url, name: video.name, kind: "video", source: video.name };
544
+ break;
545
+ }
546
+ const post = socialFrameTarget(href);
547
+ if (post) {
548
+ media = { url: post.url, name: post.platform.name, kind: post.platform.kind, source: post.platform.name };
549
+ break;
550
+ }
551
+ }
552
+ if (media)
553
+ break;
554
+ }
555
+ if (media) {
556
+ const replacement = linkParagraph(block.ownerDocument, media.url, media.name);
557
+ const anchor = replacement.querySelector("a");
558
+ if (anchor) {
559
+ anchor.setAttribute("data-media", media.kind);
560
+ anchor.setAttribute("data-source", media.source);
561
+ }
562
+ block.replaceWith(replacement);
563
+ stats["consent-placeholder"] = (stats["consent-placeholder"] ?? 0) + 1;
564
+ changed = true;
565
+ for (const rest of matched.slice(1))
566
+ drop(rest, "consent-placeholder");
567
+ }
568
+ else {
569
+ for (const item of matched)
570
+ drop(item, "consent-placeholder");
459
571
  }
460
572
  });
461
573
  // Last, so that nothing above takes the card for a repeated headline.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feedkeeper/server",
3
- "version": "0.38.1",
3
+ "version": "0.38.3",
4
4
  "private": true,
5
5
  "type": "module"
6
6
  }