From c352fbddde13273defe5a4fff6332f43ff427902 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 25 Mar 2020 20:16:39 +0300 Subject: initial --- init.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 init.php diff --git a/init.php b/init.php new file mode 100644 index 0000000..560facc --- /dev/null +++ b/init.php @@ -0,0 +1,41 @@ +add_hook($host::HOOK_ARTICLE_FILTER, $this); + } + + function hook_article_filter($article) { + if (strpos($article["link"], ".fontanka.ru") !== FALSE) { + $tmp = fetch_file_contents(["url" => $article["link"]]); + + if ($tmp) { + $doc = new DOMDocument("1.0", "UTF-8"); + + if (!@$doc->loadHTML($tmp)) + return false; + + $xpath = new DOMXPath($doc); + $base_node = $xpath->query("//article")->item(0); + + if ($base_node) { + $article["content"] = $doc->saveHTML($base_node); + } + } + } + + return $article; + } + + function api_version() { + return 2; + } + +} -- cgit v1.2.3