2 class Af_Fsckportal extends Plugin {
8 "Remove feedsportal spamlinks from article content",
12 function init($host) {
15 $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
18 function hook_article_filter($article) {
20 $doc = new DOMDocument();
22 $charset_hack = '<head>
23 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
26 @$doc->loadHTML($charset_hack . $article["content"]);
29 $xpath = new DOMXPath($doc);
30 $entries = $xpath->query('(//img[@src]|//a[@href])');
32 foreach ($entries as $entry) {
33 if (preg_match("/feedsportal.com/", $entry->getAttribute("src"))) {
34 $entry->parentNode->removeChild($entry);
35 } else if (preg_match("/feedsportal.com/", $entry->getAttribute("href"))) {
36 $entry->parentNode->removeChild($entry);
40 $article["content"] = $doc->saveHTML();
47 function api_version() {