diff options
author | wn_ <[email protected]> | 2024-04-03 17:23:41 +0000 |
---|---|---|
committer | wn_ <[email protected]> | 2024-04-03 17:25:30 +0000 |
commit | 29c099cb9c1a9e2f6871068513fc321828da31d2 (patch) | |
tree | e6b44c6309edadf6e933caf81321740a0ace79a1 /src/Readability.php | |
parent | 8ac5abdd497b37d2be4833bcf18d6819bba4d9c9 (diff) |
Add config support for ignoring additional elements.
Diffstat (limited to 'src/Readability.php')
-rw-r--r-- | src/Readability.php | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Readability.php b/src/Readability.php index 6407a92..c5318a4 100644 --- a/src/Readability.php +++ b/src/Readability.php @@ -342,7 +342,7 @@ class Readability // Extract JSON-LD metadata before removing scripts $this->jsonld = $this->configuration->getDisableJSONLD() ? [] : $this->getJSONLD($dom); - $this->removeScripts($dom); + $this->removeIgnoredElements($dom); $this->prepDocument($dom); @@ -1188,13 +1188,13 @@ class Readability } /** - * Removes all the scripts of the html. + * Removes elements that should be ignored. * * @param DOMDocument $dom */ - private function removeScripts(DOMDocument $dom) + private function removeIgnoredElements(DOMDocument $dom) { - foreach (['script', 'noscript'] as $tag) { + foreach (['noscript', 'script', ...$this->configuration->getExtraIgnoredElements()] as $tag) { $nodes = $dom->getElementsByTagName($tag); foreach (iterator_to_array($nodes) as $node) { NodeUtility::removeNode($node); |