feedkeeper 0.36.10 → 0.36.11
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/index.js +3 -1
- package/server/dist/feeds/content/noise/boilerplate.js +26 -0
- package/server/dist/feeds/content/noise/emptyContents.js +42 -0
- package/server/dist/feeds/content/noise/stateHidden.js +49 -0
- package/server/dist/feeds/content/patterns/boilerplate/de.js +2 -0
- package/server/dist/feeds/content/patterns/boilerplate/en.js +1 -1
- package/server/dist/feeds/content/patterns/boilerplate/ja.js +1 -0
- package/server/dist/feeds/content/patterns/contents/de.js +5 -0
- package/server/dist/feeds/content/patterns/contents/en.js +8 -0
- package/server/dist/feeds/content/patterns/contents/index.js +6 -0
- package/server/dist/feeds/content/patterns/contents/ja.js +5 -0
- package/server/dist/feeds/content/patterns/loading/de.js +2 -0
- package/server/dist/feeds/content/patterns/loading/en.js +2 -0
- package/server/dist/feeds/content/patterns/loading/ja.js +2 -0
- package/server/dist/feeds/contentNoise.js +6 -0
- package/server/package.json +1 -1
package/package.json
CHANGED
|
@@ -2,18 +2,20 @@ import { lazyImages } from "./noise/lazyImages.js";
|
|
|
2
2
|
import { EMBED_RULES, resolveEmbeds } from "./embeds/index.js";
|
|
3
3
|
import { embedHeadings } from "./embeds/headings.js";
|
|
4
4
|
import { boilerplate } from "./noise/boilerplate.js";
|
|
5
|
+
import { emptyContents } from "./noise/emptyContents.js";
|
|
5
6
|
import { loadingPlaceholders } from "./noise/loading.js";
|
|
6
7
|
import { pageChrome } from "./noise/pageChrome.js";
|
|
7
8
|
import { trackingPixels } from "./noise/pixels.js";
|
|
8
9
|
import { permalinkGlyphs } from "./noise/permalinkGlyphs.js";
|
|
9
10
|
import { sidebars } from "./noise/sidebars.js";
|
|
11
|
+
import { stateHidden } from "./noise/stateHidden.js";
|
|
10
12
|
import { teaserLinks } from "./noise/teaserLinks.js";
|
|
11
13
|
/**
|
|
12
14
|
* Every rule of the content pipeline, in the order they run on a fetched page: embeds first (their address sits in
|
|
13
15
|
* tags that are removed next), then the clutter around the story. The tests check each rule against its fixtures in
|
|
14
16
|
* `test/fixtures/content/<rule name>` and that running it twice changes nothing. See `docs/content-rules.md`.
|
|
15
17
|
*/
|
|
16
|
-
export const PAGE_RULES = [lazyImages, ...EMBED_RULES, embedHeadings, pageChrome, sidebars, loadingPlaceholders, trackingPixels, boilerplate, teaserLinks, permalinkGlyphs];
|
|
18
|
+
export const PAGE_RULES = [lazyImages, ...EMBED_RULES, embedHeadings, pageChrome, stateHidden, sidebars, loadingPlaceholders, trackingPixels, boilerplate, emptyContents, teaserLinks, permalinkGlyphs];
|
|
17
19
|
export { resolveEmbeds };
|
|
18
20
|
/** What a fetched page goes through before its scripts, frames and `noscript` blocks are removed. */
|
|
19
21
|
export function cleanPage(root, stats = {}) {
|
|
@@ -64,9 +64,35 @@ export const boilerplate = {
|
|
|
64
64
|
count(stats, "boilerplate");
|
|
65
65
|
changed = true;
|
|
66
66
|
}
|
|
67
|
+
if (inlineCalls(root, stats))
|
|
68
|
+
changed = true;
|
|
67
69
|
return lineFooters(root, stats, total) || changed;
|
|
68
70
|
},
|
|
69
71
|
};
|
|
72
|
+
/** 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
|
+
const SHORT_LINE = 200;
|
|
74
|
+
/**
|
|
75
|
+
* The same calls as a link inside a short line of other words, or in front of a picture in the same paragraph: the link goes, the rest stays.
|
|
76
|
+
* A block that holds nothing else was dealt with above.
|
|
77
|
+
*/
|
|
78
|
+
function inlineCalls(root, stats) {
|
|
79
|
+
let changed = false;
|
|
80
|
+
for (const link of [...root.querySelectorAll("a[href]")]) {
|
|
81
|
+
const parent = link.parentElement;
|
|
82
|
+
if (!parent || !root.contains(link) || link.querySelector("img, picture, video, audio, iframe"))
|
|
83
|
+
continue;
|
|
84
|
+
const text = flat(link.textContent);
|
|
85
|
+
if (text === "" || text.length > 120 || !BOILERPLATE_ANYWHERE.some(pattern => pattern.test(text)))
|
|
86
|
+
continue;
|
|
87
|
+
const line = flat(parent.textContent);
|
|
88
|
+
if (line.length > SHORT_LINE)
|
|
89
|
+
continue;
|
|
90
|
+
link.remove();
|
|
91
|
+
count(stats, "boilerplate");
|
|
92
|
+
changed = true;
|
|
93
|
+
}
|
|
94
|
+
return changed;
|
|
95
|
+
}
|
|
70
96
|
/**
|
|
71
97
|
* Footers that stand as bare text between `<br>` ("This article … first appeared on …", "Discuss this article in our forums"), not in a block of
|
|
72
98
|
* their own. Each such line is checked like a block; the breaks left at the end of the container go with them.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CONTENTS_HEADINGS } from "../patterns/contents/index.js";
|
|
2
|
+
import { count, flat, pruneEmpty } from "../shared.js";
|
|
3
|
+
const LIST_LIKE = "ul, ol, nav, details, dl, table";
|
|
4
|
+
/** How far down a block's first children a list may start and still count as the list under the heading. */
|
|
5
|
+
const LIST_DEPTH = 3;
|
|
6
|
+
/** Whether an element is a list or opens with one (a wrapper around the table of contents). */
|
|
7
|
+
function startsWithList(element, depth = 0) {
|
|
8
|
+
if (element.matches(LIST_LIKE))
|
|
9
|
+
return true;
|
|
10
|
+
const first = element.firstElementChild;
|
|
11
|
+
return depth < LIST_DEPTH && first !== null && startsWithList(first, depth + 1);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The heading of a table of contents that a script fills: "Table of Contents", "Inhaltsverzeichnis", "目次". Without the script
|
|
15
|
+
* nothing follows it but the story. A heading goes only when the element after it neither is a list nor opens with one and holds no
|
|
16
|
+
* links within the page; a table of contents that is there stays with its heading.
|
|
17
|
+
*/
|
|
18
|
+
export const emptyContents = {
|
|
19
|
+
name: "empty-contents",
|
|
20
|
+
description: "A \"Table of Contents\" heading with no list of links after it (a script builds the list) is removed.",
|
|
21
|
+
apply(root, stats) {
|
|
22
|
+
let changed = false;
|
|
23
|
+
for (const heading of [...root.querySelectorAll("h1, h2, h3, h4, h5, h6")]) {
|
|
24
|
+
if (!root.contains(heading) || !CONTENTS_HEADINGS.some(pattern => pattern.test(flat(heading.textContent))))
|
|
25
|
+
continue;
|
|
26
|
+
// A wrapper that holds nothing but the heading belongs to it.
|
|
27
|
+
let target = heading;
|
|
28
|
+
while (target.parentElement && target.parentElement.children.length === 1 && flat(target.parentElement.textContent) === flat(heading.textContent))
|
|
29
|
+
target = target.parentElement;
|
|
30
|
+
const next = target.nextElementSibling;
|
|
31
|
+
if (next && (startsWithList(next) || next.querySelectorAll("a[href^='#']").length >= 2))
|
|
32
|
+
continue;
|
|
33
|
+
const parent = target.parentNode;
|
|
34
|
+
target.remove();
|
|
35
|
+
pruneEmpty(parent);
|
|
36
|
+
count(stats, "empty-contents");
|
|
37
|
+
changed = true;
|
|
38
|
+
}
|
|
39
|
+
return changed;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=emptyContents.js.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { count, pruneEmpty } from "../shared.js";
|
|
2
|
+
/** An expression that is nothing but the name of a state variable. */
|
|
3
|
+
const STATE_NAME = /^[A-Za-z_$][\w$]*$/;
|
|
4
|
+
/** Whether an `x-data` object declares the variable and starts it out as `false` (`{ open: false }`). */
|
|
5
|
+
function declaration(data, name) {
|
|
6
|
+
const escaped = name.replace(/\$/g, "\\$");
|
|
7
|
+
if (!new RegExp(`(?:^|[{,\\s])${escaped}\\s*:`).test(data))
|
|
8
|
+
return null;
|
|
9
|
+
return new RegExp(`(?:^|[{,\\s])${escaped}\\s*:\\s*false\\b`).test(data) ? "false" : "other";
|
|
10
|
+
}
|
|
11
|
+
/** Whether the state that an element's `x-show` names starts out as false in the nearest scope that declares it. */
|
|
12
|
+
function startsHidden(element) {
|
|
13
|
+
const name = (element.getAttribute("x-show") ?? "").trim();
|
|
14
|
+
if (!STATE_NAME.test(name))
|
|
15
|
+
return false;
|
|
16
|
+
for (let scope = element; scope; scope = scope.parentElement) {
|
|
17
|
+
const data = scope.getAttribute("x-data");
|
|
18
|
+
if (data === null)
|
|
19
|
+
continue;
|
|
20
|
+
const declared = declaration(data, name);
|
|
21
|
+
if (declared)
|
|
22
|
+
return declared === "false";
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Hover cards, menus and dialogs that a framework shows only after a click or a hover. Alpine writes it as `x-show="open"` with
|
|
28
|
+
* `x-data="{ open: false }"` on the wrapper: the card is hidden until a script flips the state. A reader runs no script, so the
|
|
29
|
+
* state never changes and what sits in the card (an author's biography, a menu of the site) would be read as part of the story.
|
|
30
|
+
* Only a bare state name that starts out `false` counts; any other expression is left alone.
|
|
31
|
+
*/
|
|
32
|
+
export const stateHidden = {
|
|
33
|
+
name: "state-hidden",
|
|
34
|
+
description: "Elements that Alpine shows only while a state that starts out false is true (hover cards, menus, dialogs) are removed.",
|
|
35
|
+
apply(root, stats) {
|
|
36
|
+
let changed = false;
|
|
37
|
+
for (const element of [...root.querySelectorAll("[x-show]")]) {
|
|
38
|
+
if (!root.contains(element) || !startsHidden(element))
|
|
39
|
+
continue;
|
|
40
|
+
const parent = element.parentNode;
|
|
41
|
+
element.remove();
|
|
42
|
+
pruneEmpty(parent);
|
|
43
|
+
count(stats, "state-hidden");
|
|
44
|
+
changed = true;
|
|
45
|
+
}
|
|
46
|
+
return changed;
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=stateHidden.js.map
|
|
@@ -6,6 +6,8 @@ export const ANYWHERE = [
|
|
|
6
6
|
// Aufrufe, der Seite bei Google oder in anderen Diensten zu folgen.
|
|
7
7
|
/^(?:Uns|Folge uns|Folgen Sie uns) (?:auf|bei) Google(?: News| Discover)? folgen$/i,
|
|
8
8
|
/^(?:Wähle|Wählen Sie|Füge|Fügen Sie) [^.!?]{2,50} (?:als )?(?:bevorzugte|bevorzugten|bevorzugter)\b[^.!?]{0,30}$/i,
|
|
9
|
+
// „Als bevorzugte Quelle bei Google hinzufügen“, ohne den Namen der Seite.
|
|
10
|
+
/^Als bevorzugte[nr]? (?:Google-)?Quelle (?:bei Google )?(?:hinzufügen|auswählen|wählen)$/i,
|
|
9
11
|
// „★ ifun.de bei Google bevorzugen ★“ und ähnliche Bitten, die Seite als bevorzugte Quelle zu wählen.
|
|
10
12
|
/^★?\s*[^★!?]{2,40} bei Google bevorzugen\s*★?$/i,
|
|
11
13
|
// Texte von Download-Schaltflächen, deren Grafik nicht mehr da ist.
|
|
@@ -4,7 +4,7 @@
|
|
|
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 on Google(?: News| Discover)?|Add(?: [^.!?]{2,50})? as a preferred (?:source|publisher)(?: on Google)?)$/i,
|
|
8
8
|
// The text of download buttons whose picture is gone.
|
|
9
9
|
/^(?:Download on the (?:App|Mac App) Store|Get it on Google Play|Available on Google Play)$/i,
|
|
10
10
|
];
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
export const ANYWHERE = [
|
|
6
6
|
// Calls to follow the site on Google or elsewhere.
|
|
7
7
|
/^(?:Google(?: ニュース)?でフォロー(?:する)?|Google ニュースで[^.!?]{2,40}をフォロー)$/i,
|
|
8
|
+
/^(?:Googleで)?優先(?:ソース|的なソース)(?:として|に)(?:追加|設定)(?:する)?$/i,
|
|
8
9
|
// The text of download buttons whose picture is gone.
|
|
9
10
|
/^(?:App Storeからダウンロード|Google Playで手に入れよう|Google Playで入手|App Storeでダウンロード)$/i,
|
|
10
11
|
// A picture's filename shown as text.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headings, in English, that introduce a table of contents. A script builds the list under such a heading on many sites; without the
|
|
3
|
+
* script only the heading is left. The whole text of the heading must be one of these (see `noise/emptyContents.ts`).
|
|
4
|
+
*/
|
|
5
|
+
export default [
|
|
6
|
+
/^(?:table of contents|contents|in this (?:article|guide|post|story)|on this page|jump to)\s*:?$/i,
|
|
7
|
+
];
|
|
8
|
+
//# 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 CONTENTS_HEADINGS = [de, en, ja].flat();
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** Placeholders, in German, that a script replaces with content. Without the script they stay in the text. See `en.ts`. */
|
|
2
2
|
export default [
|
|
3
3
|
/^(?:wird geladen|lädt|bitte warten)(?:\s*(?:\.{3}|…))?$/i,
|
|
4
|
+
// Die Überschrift eines Kommentarfelds, das ein Skript füllt.
|
|
5
|
+
/^(?:was (?:denkst|meinst) du(?: bisher)?|was denken sie(?: bisher)?|diskutieren sie mit|diskutiere mit)\??$/i,
|
|
4
6
|
];
|
|
5
7
|
//# sourceMappingURL=de.js.map
|
|
@@ -7,8 +7,10 @@ import { SIDEBAR_HEADINGS } from "./content/patterns/sidebars/index.js";
|
|
|
7
7
|
import { resolveEmbeds } from "./content/embeds/index.js";
|
|
8
8
|
import { loadingPlaceholders } from "./content/noise/loading.js";
|
|
9
9
|
import { trackingPixels } from "./content/noise/pixels.js";
|
|
10
|
+
import { emptyContents } from "./content/noise/emptyContents.js";
|
|
10
11
|
import { pageChrome } from "./content/noise/pageChrome.js";
|
|
11
12
|
import { permalinkGlyphs } from "./content/noise/permalinkGlyphs.js";
|
|
13
|
+
import { stateHidden } from "./content/noise/stateHidden.js";
|
|
12
14
|
import { teaserLinks } from "./content/noise/teaserLinks.js";
|
|
13
15
|
import { markVideoTeasers } from "./content/noise/videoTeasers.js";
|
|
14
16
|
import { flat, pruneEmpty } from "./content/shared.js";
|
|
@@ -105,6 +107,10 @@ function removeReaderNoise(root, title, stats, author) {
|
|
|
105
107
|
changed = true;
|
|
106
108
|
if (pageChrome.apply(root, stats))
|
|
107
109
|
changed = true;
|
|
110
|
+
if (stateHidden.apply(root, stats))
|
|
111
|
+
changed = true;
|
|
112
|
+
if (emptyContents.apply(root, stats))
|
|
113
|
+
changed = true;
|
|
108
114
|
for (const selector of BREADCRUMB_MARKERS) {
|
|
109
115
|
try {
|
|
110
116
|
root.querySelectorAll(selector).forEach(element => drop(element, "breadcrumb"));
|