feedkeeper 0.38.4 → 0.38.5
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 +1 -1
- package/server/dist/feeds/content/embeds/video.js +25 -3
- package/server/dist/feeds/content/patterns/datelines/de.js +7 -0
- package/server/dist/feeds/content/patterns/datelines/en.js +12 -0
- package/server/dist/feeds/content/patterns/datelines/index.js +13 -0
- package/server/dist/feeds/content/patterns/datelines/ja.js +7 -0
- package/server/dist/feeds/content/patterns/play-labels/de.js +2 -0
- package/server/dist/feeds/content/patterns/play-labels/en.js +2 -0
- package/server/dist/feeds/content/patterns/play-labels/index.js +5 -3
- package/server/dist/feeds/content/patterns/play-labels/ja.js +2 -0
- package/server/dist/feeds/content/patterns/sidebars/selectors.js +1 -1
- package/server/dist/feeds/content/patterns/tag-headings/de.js +3 -0
- package/server/dist/feeds/content/patterns/tag-headings/en.js +6 -0
- package/server/dist/feeds/content/patterns/tag-headings/index.js +6 -0
- package/server/dist/feeds/content/patterns/tag-headings/ja.js +3 -0
- package/server/dist/feeds/contentNoise.js +39 -2
- package/server/package.json +1 -1
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PLAY_LABEL } from "../patterns/play-labels/index.js";
|
|
1
|
+
import { PLAY_LABEL, PLAYER_TITLES } from "../patterns/play-labels/index.js";
|
|
2
2
|
import { flat, linkParagraph, parseAddress, pruneEmpty } from "../shared.js";
|
|
3
3
|
const PLAY_SOURCE = /(?:^|[/_.-])play[-_]?(?:icon|button|btn)?\.(?:svg|png|webp|gif)(?:[?#]|$)/i;
|
|
4
4
|
const DURATION = /^\d{1,2}:\d{2}(:\d{2})?$/;
|
|
@@ -31,6 +31,17 @@ export function embedTarget(source) {
|
|
|
31
31
|
}
|
|
32
32
|
return null;
|
|
33
33
|
}
|
|
34
|
+
/** The name of the video site a watch-page address belongs to, for the labels of links that were saved without a title. */
|
|
35
|
+
function videoSiteName(source) {
|
|
36
|
+
const host = parseAddress(source)?.hostname.replace(/^(?:www|m)\./, "") ?? "";
|
|
37
|
+
if (/^(?:youtube(?:-nocookie)?\.com|youtu\.be)$/.test(host))
|
|
38
|
+
return "YouTube";
|
|
39
|
+
if (/^(?:player\.)?vimeo\.com$/.test(host))
|
|
40
|
+
return "Vimeo";
|
|
41
|
+
if (/^dailymotion\.com$/.test(host))
|
|
42
|
+
return "Dailymotion";
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
34
45
|
/**
|
|
35
46
|
* Players need the publisher's script: a reader without it shows their play-button picture as a broken image and
|
|
36
47
|
* leaves a dead block. What can be reached stays as one plain link to the video (`data-media="video"` tells a client
|
|
@@ -83,7 +94,8 @@ function resolveVideoPlayers(root, stats) {
|
|
|
83
94
|
if (!target)
|
|
84
95
|
continue;
|
|
85
96
|
const parent = frame.parentNode;
|
|
86
|
-
const
|
|
97
|
+
const title = flat(frame.getAttribute("title"));
|
|
98
|
+
const replacement = linkParagraph(frame.ownerDocument, target.url, title && !PLAYER_TITLES.some(pattern => pattern.test(title)) ? title : target.name);
|
|
87
99
|
frame.replaceWith(replacement);
|
|
88
100
|
pruneEmpty(parent);
|
|
89
101
|
links.push(replacement.querySelector("a"));
|
|
@@ -107,7 +119,17 @@ export const videoPlayers = {
|
|
|
107
119
|
apply(root, stats) {
|
|
108
120
|
const { changed, links } = resolveVideoPlayers(root, stats);
|
|
109
121
|
links.forEach(link => link.setAttribute("data-media", "video"));
|
|
110
|
-
|
|
122
|
+
// A video link already saved with the player's technical name as its label ("vimeo-player") shows the platform instead.
|
|
123
|
+
let renamed = false;
|
|
124
|
+
for (const link of root.querySelectorAll("a[data-media='video'][href]")) {
|
|
125
|
+
const name = videoSiteName(link.getAttribute("href") ?? "");
|
|
126
|
+
const label = flat(link.textContent);
|
|
127
|
+
if (name && label && PLAYER_TITLES.some(pattern => pattern.test(label))) {
|
|
128
|
+
link.textContent = name;
|
|
129
|
+
renamed = true;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return changed || renamed;
|
|
111
133
|
},
|
|
112
134
|
};
|
|
113
135
|
//# sourceMappingURL=video.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Lines that only restate what a reader's head already shows, in German. See `en.ts`. */
|
|
2
|
+
export default {
|
|
3
|
+
weekdays: ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"],
|
|
4
|
+
relativeAges: [/^vor\s+(?:\d{1,3}|einer|einem)\s*(?:Sekunden?|Sek\.|Minuten?|Min\.|Stunden?|Std\.|Tagen?|Wochen?)$/i, /^(?:gerade eben|soeben|eben erst)$/i],
|
|
5
|
+
kickers: [/^(?:NEWS|News|Nachrichten|Meldung|Kolumne|Rezension|Interview)\s*[||//·•]\s*[^.!?。!?]{1,40}$/],
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=de.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lines that only restate what a reader's head already shows, in English. A line counts only whole and only near the
|
|
3
|
+
* start of the text; a sentence that merely contains a weekday or "ago" is never matched.
|
|
4
|
+
*/
|
|
5
|
+
export default {
|
|
6
|
+
weekdays: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
|
7
|
+
/** How long ago the page was published: `4 minutes ago`, `just now`. */
|
|
8
|
+
relativeAges: [/^\d{1,3}\s*(?:seconds?|secs?|minutes?|mins?|hours?|hrs?|days?|weeks?)\s+ago$/i, /^(?:just now|moments? ago)$/i],
|
|
9
|
+
/** A section label in front of the story: `NEWS | Sound / Exhibition`. */
|
|
10
|
+
kickers: [/^(?:NEWS|News|Feature|Column|Review|Opinion|Interview)\s*[||//·•]\s*[^.!?。!?]{1,40}$/],
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=en.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import de from "./de.js";
|
|
2
|
+
import en from "./en.js";
|
|
3
|
+
import ja from "./ja.js";
|
|
4
|
+
const LANGUAGES = [de, en, ja];
|
|
5
|
+
const escape = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
6
|
+
/** One file per language, searched all at once. To add a language, add a file next to these and list it here. */
|
|
7
|
+
export const RELATIVE_AGES = LANGUAGES.flatMap(language => language.relativeAges);
|
|
8
|
+
export const SECTION_KICKERS = LANGUAGES.flatMap(language => language.kickers);
|
|
9
|
+
const WEEKDAY = `(?:${LANGUAGES.flatMap(language => language.weekdays).map(escape).join("|")})`;
|
|
10
|
+
/** `2026-11-17`, `2026.11.17 Tue`, `17.11.2026 Di`, `2026年11月17日 17時54分`, repeated as some pages print it twice: a date a reader's head already shows. */
|
|
11
|
+
const NUMERIC_DATE = `(?:\\d{4}[-./年]\\d{1,2}[-./月]\\d{1,2}日?|\\d{1,2}\\.\\s?\\d{1,2}\\.\\s?\\d{2,4})(?:\\s*[((]?${WEEKDAY}[))]?)?(?:\\s+\\d{1,2}(?::|時)\\d{2}分?)?`;
|
|
12
|
+
export const NUMERIC_DATELINE = new RegExp(`^${NUMERIC_DATE}(?:\\s+${NUMERIC_DATE}){0,2}$`, "u");
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Lines that only restate what a reader's head already shows, in Japanese. See `en.ts`. */
|
|
2
|
+
export default {
|
|
3
|
+
weekdays: ["月", "火", "水", "木", "金", "土", "日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日", "日曜日"],
|
|
4
|
+
relativeAges: [/^\d{1,3}\s*(?:秒|分|時間|日|週間|か月|ヶ月)前$/, /^(?:たった今|今さっき|数分前)$/],
|
|
5
|
+
kickers: [/^(?:NEWS|ニュース|コラム|レポート|インタビュー|特集|レビュー)\s*[||//・·•]\s*[^.!?。!?]{1,40}$/],
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=ja.js.map
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
/** Labels, in German, that a player's play-button picture carries as its alt text. See `en.ts`. */
|
|
2
2
|
export default ["video starten", "video abspielen", "abspielen", "wiedergabe", "wiedergabe starten"];
|
|
3
|
+
/** Technical frame titles, in German. See `en.ts`. */
|
|
4
|
+
export const PLAYER_TITLES = [/^[\w. -]{0,30}[ -]?(?:video-?)?player$/i, /^(?:Video-?)?Wiedergabe$/i];
|
|
3
5
|
//# sourceMappingURL=de.js.map
|
|
@@ -3,4 +3,6 @@
|
|
|
3
3
|
* with the player. Whole texts only: a sentence that merely contains "play" is never a label.
|
|
4
4
|
*/
|
|
5
5
|
export default ["play", "play video", "watch", "watch video", "start video"];
|
|
6
|
+
/** Titles a player's frame carries as a technical name, not as the name of the video: `vimeo-player`, `YouTube video player`. */
|
|
7
|
+
export const PLAYER_TITLES = [/^[\w. -]{0,30}[ -]?player$/i];
|
|
6
8
|
//# sourceMappingURL=en.js.map
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import de from "./de.js";
|
|
2
|
-
import en from "./en.js";
|
|
3
|
-
import ja from "./ja.js";
|
|
1
|
+
import de, { PLAYER_TITLES as deTitles } from "./de.js";
|
|
2
|
+
import en, { PLAYER_TITLES as enTitles } from "./en.js";
|
|
3
|
+
import ja, { PLAYER_TITLES as jaTitles } 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 PLAY_LABEL = new RegExp(`^(?:${[de, en, ja].flat().map(label => label.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})$`, "i");
|
|
6
|
+
/** A frame title that names the player technology rather than the video: the platform name is the better label then. */
|
|
7
|
+
export const PLAYER_TITLES = [...deTitles, ...enTitles, ...jaTitles];
|
|
6
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
/** Labels, in Japanese, that a player's play-button picture carries as its alt text. See `en.ts`. */
|
|
2
2
|
export default ["動画を再生", "動画を再生する", "動画を見る", "再生", "再生する", "動画再生"];
|
|
3
|
+
/** Technical frame titles, in Japanese. See `en.ts`. */
|
|
4
|
+
export const PLAYER_TITLES = [/^[\w. -]{0,30}(?:動画)?プレ[ーイ]ヤー$/];
|
|
3
5
|
//# sourceMappingURL=ja.js.map
|
|
@@ -8,7 +8,7 @@ export const SIDEBAR_SELECTORS = [
|
|
|
8
8
|
".yarpp-related", "#jp-relatedposts", ".jp-relatedposts", ".related-posts", ".related_posts", ".relatedposts",
|
|
9
9
|
".wp-block-latest-posts", ".post-navigation", ".crp_related",
|
|
10
10
|
// Sites that mark the block with an analytics label.
|
|
11
|
-
"[data-track='popular-stories']", "[data-track='related-stories']", "[data-track='related-articles']",
|
|
11
|
+
"[data-track='popular-stories']", "[data-track='related-stories']", "[data-track='related-articles']", "[data-track*='ranking' i]",
|
|
12
12
|
// Broadcasters' "this topic in our programme" teasers.
|
|
13
13
|
".relatedbroadcast",
|
|
14
14
|
];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headings that start the tag cloud at the foot of a page. Whole headings only; what follows in the tail of the text is
|
|
3
|
+
* a list of tags and the page's own navigation, never the story.
|
|
4
|
+
*/
|
|
5
|
+
export default [/^(?:Tags|Keywords|Related topics|Featured topics)$/i];
|
|
6
|
+
//# sourceMappingURL=en.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import de from "./de.js";
|
|
2
|
+
import en from "./en.js";
|
|
3
|
+
import ja from "./ja.js";
|
|
4
|
+
/** One file per language, searched all at once. To add a language, add a file next to these and list it here. */
|
|
5
|
+
export const TAG_HEADINGS = [de, en, ja].flat();
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -5,6 +5,8 @@ import { SNIPPET_BYLINES, SNIPPET_IMAGE_METADATA } from "./content/patterns/snip
|
|
|
5
5
|
import { BOILERPLATE_NEWSLETTER, BOILERPLATE_ORPHAN_HEADINGS } from "./content/patterns/boilerplate/index.js";
|
|
6
6
|
import { CONSENT_ANCHORS, CONSENT_COMPANIONS } from "./content/patterns/consent/index.js";
|
|
7
7
|
import { SIDEBAR_HEADINGS } from "./content/patterns/sidebars/index.js";
|
|
8
|
+
import { NUMERIC_DATELINE, RELATIVE_AGES, SECTION_KICKERS } from "./content/patterns/datelines/index.js";
|
|
9
|
+
import { TAG_HEADINGS } from "./content/patterns/tag-headings/index.js";
|
|
8
10
|
import { resolveEmbeds } from "./content/embeds/index.js";
|
|
9
11
|
import { embedTarget } from "./content/embeds/video.js";
|
|
10
12
|
import { socialFrameTarget } from "./content/embeds/social.js";
|
|
@@ -329,7 +331,7 @@ function removeReaderNoise(root, title, stats, author) {
|
|
|
329
331
|
continue;
|
|
330
332
|
}
|
|
331
333
|
if (text.length <= 60) {
|
|
332
|
-
if (DATE_ONLY.test(text)) {
|
|
334
|
+
if (DATE_ONLY.test(text) || NUMERIC_DATELINE.test(text) || RELATIVE_AGES.some(pattern => pattern.test(text))) {
|
|
333
335
|
drop(block, "dateline");
|
|
334
336
|
continue;
|
|
335
337
|
}
|
|
@@ -337,6 +339,15 @@ function removeReaderNoise(root, title, stats, author) {
|
|
|
337
339
|
drop(block, "reading-time");
|
|
338
340
|
continue;
|
|
339
341
|
}
|
|
342
|
+
if (SECTION_KICKERS.some(pattern => pattern.test(text))) {
|
|
343
|
+
drop(block, "section-kicker");
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
// The page number of a one-page article ("1 / 1") belongs to the publisher's pager, not to the story.
|
|
347
|
+
if (/^\d{1,3}\s*[//]\s*\d{1,3}$/.test(text)) {
|
|
348
|
+
drop(block, "pager");
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
340
351
|
// When the feed names the author, the reader shows the name in its head: a byline that only says that goes.
|
|
341
352
|
cleanByline(block, text);
|
|
342
353
|
if (!root.contains(block))
|
|
@@ -349,6 +360,14 @@ function removeReaderNoise(root, title, stats, author) {
|
|
|
349
360
|
drop(block, "title-repeat");
|
|
350
361
|
continue;
|
|
351
362
|
}
|
|
363
|
+
// A link to the story itself at the very start ("JUST IN <headline> (12:21)"): the headline plus a short label or time.
|
|
364
|
+
if (headline.length >= 8 && position < 4 && block.querySelector("a[href]") && !block.querySelector("img, picture, video") && charsBefore(root, block) <= 300) {
|
|
365
|
+
const own = normalized(text);
|
|
366
|
+
if (own !== headline && own.includes(headline) && own.length <= headline.length + 24) {
|
|
367
|
+
drop(block, "title-repeat");
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
352
371
|
if (position < 14 && /^(Audiobeitrag|Videobeitrag)\s*>/.test(text) && headline && normalized(text).endsWith(headline)) {
|
|
353
372
|
drop(block, "title-repeat");
|
|
354
373
|
continue;
|
|
@@ -367,7 +386,10 @@ function removeReaderNoise(root, title, stats, author) {
|
|
|
367
386
|
}
|
|
368
387
|
if (!pastStart && text.length <= 70 && block.querySelector("time") && charsBefore(root, block) <= 600) {
|
|
369
388
|
const rest = flat(text.replace(flat(block.querySelector("time")?.textContent), ""));
|
|
370
|
-
|
|
389
|
+
// A short category link next to the date ("2026年11月17日 17時54分 AI") is the section chip of the dateline.
|
|
390
|
+
const chips = [...block.querySelectorAll("a")].map(anchor => flat(anchor.textContent));
|
|
391
|
+
const unlinked = chips.length > 0 && chips.every(chip => chip.length <= 30) ? flat(chips.reduce((left, chip) => (chip ? left.replace(chip, "") : left), rest)) : rest;
|
|
392
|
+
if (/^(news|ニュース|nachrichten|stand|zuletzt aktualisiert|aktualisiert|ver(ö|oe)ffentlicht|updated|published|posted)?\s*[:·|•-]*\s*$/i.test(unlinked)) {
|
|
371
393
|
drop(block, "dateline");
|
|
372
394
|
continue;
|
|
373
395
|
}
|
|
@@ -424,6 +446,21 @@ function removeReaderNoise(root, title, stats, author) {
|
|
|
424
446
|
drop(block, "consent-wall");
|
|
425
447
|
break;
|
|
426
448
|
}
|
|
449
|
+
// The tag cloud at the foot of a page ("Tags", "注目ワード") and the page navigation below it: heading and everything after go.
|
|
450
|
+
for (const block of [...root.querySelectorAll("h2, h3, h4, h5, h6")]) {
|
|
451
|
+
if (!block.parentNode || !TAG_HEADINGS.some(pattern => pattern.test(flat(block.textContent))))
|
|
452
|
+
continue;
|
|
453
|
+
if (total - charsBefore(root, block) > TAIL_CHARACTERS)
|
|
454
|
+
continue;
|
|
455
|
+
let node = block;
|
|
456
|
+
while (node.parentNode && node !== root) {
|
|
457
|
+
while (node.nextSibling)
|
|
458
|
+
node.nextSibling.remove();
|
|
459
|
+
node = node.parentNode;
|
|
460
|
+
}
|
|
461
|
+
drop(block, "tag-cloud");
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
427
464
|
// An orphan recommendation heading left without subsequent links or content.
|
|
428
465
|
for (const block of leafBlocks(root)) {
|
|
429
466
|
if (!block.parentNode)
|