]> git.wh0rd.org Git - tt-rss.git/blob - plugins/af_elreg/init.php
af_elreg: remove ads
[tt-rss.git] / plugins / af_elreg / init.php
1 <?php
2 class Af_ElReg extends Plugin {
3
4         private $host;
5
6         function about() {
7                 return array(1.0,
8                         "Fetch content of The Register feeds",
9                         "fox");
10         }
11
12         function init($host) {
13                 $this->host = $host;
14
15                 $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
16         }
17
18         function hook_article_filter($article) {
19                 if (strpos($article["link"], "theregister.co.uk") !== FALSE) {
20
21                                 $doc = new DOMDocument();
22                                 @$doc->loadHTML(fetch_file_contents($article["link"]));
23
24                                 $basenode = false;
25
26                                 if ($doc) {
27                                         $xpath = new DOMXPath($doc);
28
29                                         $trash = $xpath->query("//*[@class='wptl top' or @class='wptl btm']");
30
31                                         foreach ($trash as $t) {
32                                                 $t->parentNode->removeChild($t);
33                                         }
34
35                                         $basenode = $doc->getElementById("body");
36
37                                         if ($basenode) {
38                                                 $article["content"] = $doc->saveXML($basenode);
39                                         }
40                                 }
41                 }
42
43                 return $article;
44         }
45
46         function api_version() {
47                 return 2;
48         }
49 }
50 ?>