├── README.md ├── af_belauscht └── init.php ├── af_comics └── filters │ ├── af_comics_betweenfailures.php │ ├── af_comics_cad.php │ ├── af_comics_codinglove.php │ ├── af_comics_erzaehlmirnix.php │ ├── af_comics_mrlovenstein.php │ ├── af_comics_nerfnow.php │ ├── af_comics_nichtlustig.php │ ├── af_comics_optipess.php │ ├── af_comics_stuttmann.php │ ├── af_comics_userfriendly.php │ ├── af_comics_wordpress.php │ └── af_comics_xkcd.php ├── af_datenschutzbuero └── init.php ├── af_digitalcourage └── init.php ├── af_faz └── init.php ├── af_gamestar └── init.php ├── af_githubcommits └── init.php ├── af_githubnoavatars └── init.php ├── af_githubreleases └── init.php ├── af_gnonline └── init.php ├── af_golem └── init.php ├── af_gulli └── init.php ├── af_handelsblatt └── init.php ├── af_heise └── init.php ├── af_hltv └── init.php ├── af_mimikama └── init.php ├── af_nrz └── init.php ├── af_old_reddit └── init.php ├── af_pcgames └── init.php ├── af_raumfahrer └── init.php ├── af_rockpapershotgun └── init.php ├── af_rponline └── init.php ├── af_ruhrbarone └── init.php ├── af_spiegel └── init.php ├── af_ssdebian └── init.php ├── af_stimmthaltnicht └── init.php ├── af_sueddeutsche └── init.php ├── af_tagesschau └── init.php ├── af_taz └── init.php ├── af_thepit └── init.php ├── af_titanic └── init.php ├── af_volksstimme └── init.php ├── af_winfuture └── init.php ├── af_wissenslogs └── init.php ├── af_youtube └── init.php └── ff_sinnfrei └── init.php /README.md: -------------------------------------------------------------------------------- 1 | Tiny-Tiny-RSS-Plugins 2 | ===================== 3 | 4 | Some plugins for Tiny-Tiny-RSS 5 | 6 | * Plugins for news sites 7 | * af_datenschutzbuero (german, http://www.datenschutz.de/) 8 | * af_digitalcourage (german, https://digitalcourage.de/) 9 | * af_faz (german, http://www.faz.de) 10 | * af_gamestar (german, http://www.gamestar.de/) 11 | * af_gnonline (german, http://www.gn-online.de/) 12 | * af_golem (german, http://www.golem.de/) 13 | * af_gulli (german, http://www.gulli.com/) 14 | * af_handelsblatt (german, https://www.handelsblatt.com/) 15 | * af_heise (german, http://www.heise.de/) 16 | * af_hltv (english, http://www.hltv.org/) 17 | * af_nrz (german, http://www.nrz.de/) 18 | * af_raumfahrer (german, http://www.raumfahrer.net/) 19 | * af_rockpapershotgun (english, http://www.rockpapershotgun.com/) 20 | * af_rponline (german, http://rp-online.de) 21 | * af_ruhrbarone (german, http://www.ruhrbarone.de/) 22 | * af_spiegel (german, http://www.spiegel.de/) 23 | * af_stimmthaltnicht (german, http://www.stimmthaltnicht.de/) 24 | * af_sueddeutsche (german, http://www.sueddeutsche.de/) 25 | * af_tagesschau (german, http://www.tagesschau.de/) 26 | * af_taz (german, http://www.taz.de/) 27 | * af_thepit (german, http://www.the-pit.de/) 28 | * af_winfuture (german, http://winfuture.de/) 29 | * af_wissenslogs (german, http://www.scilogs.de/) 30 | * Other plugins 31 | * af_belauscht (german, http://www.belauscht.de/) 32 | * af_githubcommits (-, https://www.github.com/) 33 | * af_githubnoavatars (-, https://www.github.com/) 34 | * af_githubreleases (-, https://www.github.com/) 35 | * af_titanic (german, http://www.titanic-magazin.de/newsticker.html) 36 | * af_ssdebian (english, http://screenshots.debian.net/) 37 | * af_volksstimme (deutsch, http://www.volksstimme.de/) 38 | * af_youtube (whatever, http://www.youtube.com/) 39 | 40 | * Plugins for webcomics 41 | * Moved all comic filters into the (official) af_comics plugin 42 | -------------------------------------------------------------------------------- /af_belauscht/init.php: -------------------------------------------------------------------------------- 1 | host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | private function removeStuff($xpath, $filter) { 23 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 24 | $stuff = $xpath->query($filter); 25 | foreach ($stuff as $removethis) { 26 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 27 | /* _debug(htmlspecialchars($removethis->C14N())); */ 28 | $removethis->parentNode->removeChild($removethis); 29 | } 30 | } 31 | 32 | function hook_article_filter($article) { 33 | if (strpos($article["link"], "belauscht.de") !== FALSE) { 34 | $doc = new DOMDocument(); 35 | @$doc->loadHTML(mb_convert_encoding(fetch_file_contents($article["link"]), 'HTML-ENTITIES', "UTF-8")); 36 | 37 | $basenode = false; 38 | 39 | if ($doc) { 40 | $xpath = new DOMXPath($doc); 41 | 42 | $this->removeStuff($xpath, '(//div[@class="category_link"])'); 43 | 44 | $entries = $xpath->query('(//div[@class="entry-content"])'); 45 | foreach ($entries as $entry) { 46 | $new_content = $doc->saveHTML($entry); 47 | break; 48 | } 49 | 50 | if($new_content) { 51 | $new_content = preg_replace('/\s\s+/', ' ', $new_content); 52 | $article["content"] = $new_content; 53 | /* _debug(htmlspecialchars($new_content)); */ 54 | } 55 | } 56 | } 57 | return $article; 58 | } 59 | } 60 | ?> 61 | -------------------------------------------------------------------------------- /af_comics/filters/af_comics_betweenfailures.php: -------------------------------------------------------------------------------- 1 | loadHTML(fetch_file_contents($article["link"])); 15 | 16 | $basenode = false; 17 | 18 | if ($doc) { 19 | $xpath = new DOMXPath($doc); 20 | $comic = preg_match("/^[0-9]+/", $article["title"]); 21 | // starts with number: comic strip 22 | // else bonus picture 23 | 24 | $entries = $xpath->query('(//div[@class="webcomic-image"]/img[@src])'); 25 | 26 | $matches = array(); 27 | 28 | foreach ($entries as $entry) { 29 | if (preg_match("/(http:\/\/.*\/wp-content\/uploads\/.*)/i", $entry->getAttribute("src"), $matches)) { 30 | $basenode = $entry; 31 | $src = $basenode->getAttribute("src"); 32 | if(strpos($src, "sitelogobetweenfailuresalt") !== FALSE) continue; 33 | if(!$comic) $src = preg_replace("/-[0-9]+x[0-9]+.([a-z]{3})$/", ".$1", $src); 34 | $basenode->setAttribute("src", $src); 35 | $basenode->removeAttribute("width"); 36 | $basenode->removeAttribute("height"); 37 | break; 38 | } 39 | } 40 | 41 | if ($basenode) { 42 | $article["content"] = $doc->saveHTML($basenode); 43 | $article["plugin_data"] = "af_comics,$owner_uid:" . $article["plugin_data"]; 44 | } 45 | } 46 | } else if (isset($article["stored"]["content"])) { 47 | $article["content"] = $article["stored"]["content"]; 48 | } 49 | 50 | return true; 51 | } 52 | 53 | return false; 54 | } 55 | } 56 | ?> 57 | -------------------------------------------------------------------------------- /af_comics/filters/af_comics_cad.php: -------------------------------------------------------------------------------- 1 | loadHTML(fetch_file_contents($article["link"])); 16 | 17 | $basenode = false; 18 | 19 | if ($doc) { 20 | $xpath = new DOMXPath($doc); 21 | $basenode = $xpath->query('(//img[contains(@src, "/comics/sillies-")]|//img[contains(@src, "/comics/cad-")])')->item(0); 22 | 23 | if ($basenode) { 24 | $article["content"] = $doc->saveHTML($basenode); 25 | } 26 | } 27 | 28 | } 29 | 30 | return true; 31 | } 32 | 33 | return false; 34 | } 35 | } 36 | ?> 37 | -------------------------------------------------------------------------------- /af_comics/filters/af_comics_codinglove.php: -------------------------------------------------------------------------------- 1 | loadHTML(fetch_file_contents($article["link"])); 15 | 16 | $basenode = false; 17 | 18 | if ($doc) { 19 | $xpath = new DOMXPath($doc); 20 | $entries = $xpath->query('//div[@class="post"]//img[@src]'); 21 | 22 | foreach ($entries as $entry) { 23 | if (preg_match("/(host|imgur)\.com/", $entry->getAttribute("src"))) { 24 | $basenode = $entry; 25 | break; 26 | } 27 | } 28 | 29 | if ($basenode) { 30 | $article["content"] = $doc->saveHTML($basenode); 31 | $article["plugin_data"] = "af_comics,$owner_uid:" . $article["plugin_data"]; 32 | } 33 | } 34 | } else if (isset($article["stored"]["content"])) { 35 | $article["content"] = $article["stored"]["content"]; 36 | } 37 | 38 | return true; 39 | } 40 | 41 | return false; 42 | } 43 | } 44 | ?> 45 | -------------------------------------------------------------------------------- /af_comics/filters/af_comics_erzaehlmirnix.php: -------------------------------------------------------------------------------- 1 | loadHTML(fetch_file_contents($article["link"])); 15 | 16 | $basenode = false; 17 | 18 | if ($doc) { 19 | $xpath = new DOMXPath($doc); 20 | $entries = $xpath->query('(//img[contains(@src, "erzaehlmirnix.files.wordpress.com")])'); 21 | 22 | $found = false; 23 | 24 | foreach ($entries as $entry) { 25 | $basenode = $entry; 26 | } 27 | 28 | if ($basenode) { 29 | $article["content"] = $doc->saveHTML($basenode); 30 | $article["plugin_data"] = "af_comics,$owner_uid:" . $article["plugin_data"]; 31 | } 32 | } 33 | } else if (isset($article["stored"]["content"])) { 34 | $article["content"] = $article["stored"]["content"]; 35 | } 36 | 37 | return true; 38 | } 39 | 40 | return false; 41 | } 42 | } 43 | ?> 44 | -------------------------------------------------------------------------------- /af_comics/filters/af_comics_mrlovenstein.php: -------------------------------------------------------------------------------- 1 | loadHTML($article["content"]); 15 | 16 | if ($doc) { 17 | $xpath = new DOMXPath($doc); 18 | $entries = $xpath->query('(//img[@alt])'); 19 | 20 | $basenode = false; 21 | 22 | foreach ($entries as $entry) { 23 | // get image 24 | $basenode = $entry->parentNode; 25 | 26 | // add linebreak 27 | $linebreak = $doc->createElement("br"); 28 | $basenode->appendChild( $linebreak ); 29 | 30 | // add text 31 | $alt = $entry->getAttribute("alt"); 32 | $textnode = $doc->createTextNode( $alt ); 33 | $basenode->appendChild($textnode); 34 | break; 35 | } 36 | 37 | if($basenode) { 38 | $doc->removeChild( $doc->firstChild ); 39 | $article["content"] = $doc->saveHTML(); 40 | $article["plugin_data"] = "af_comics,$owner_uid:" . $article["plugin_data"]; 41 | } 42 | } 43 | } else if (isset($article["stored"]["content"])) { 44 | $article["content"] = $article["stored"]["content"]; 45 | } 46 | 47 | return true; 48 | } 49 | 50 | return false; 51 | } 52 | } 53 | ?> 54 | -------------------------------------------------------------------------------- /af_comics/filters/af_comics_nerfnow.php: -------------------------------------------------------------------------------- 1 | loadHTML($article["content"]); 15 | 16 | if ($doc) { 17 | $xpath = new DOMXPath($doc); 18 | $entries = $xpath->query('(//img[@src])'); 19 | 20 | $found = false; 21 | 22 | foreach ($entries as $entry) { 23 | $src = $entry->getAttribute("src"); 24 | $src = preg_replace("/\/thumb\//", "/image/", $src); 25 | $src = preg_replace("/\/large/", "", $src); 26 | $entry->setAttribute("src", $src); 27 | $found = true; 28 | } 29 | 30 | $node = $doc->getElementsByTagName('body')->item(0); 31 | 32 | if ($node && $found) { 33 | $article["content"] = $doc->saveHTML($node); 34 | $article["plugin_data"] = "af_comics,$owner_uid:" . $article["plugin_data"]; 35 | } 36 | } 37 | } else if (isset($article["stored"]["content"])) { 38 | $article["content"] = $article["stored"]["content"]; 39 | } 40 | 41 | return true; 42 | } 43 | 44 | return false; 45 | } 46 | } 47 | ?> 48 | -------------------------------------------------------------------------------- /af_comics/filters/af_comics_nichtlustig.php: -------------------------------------------------------------------------------- 1 | loadHTML($article["content"]); 17 | 18 | $basenode = false; 19 | 20 | if ($doc) { 21 | $xpath = new DOMXPath($doc); 22 | $entries = $xpath->query('(//img[@src])'); 23 | 24 | 25 | foreach ($entries as $entry) { 26 | if (preg_match("/(http:\/\/.*\/comics\/full\/.*)/i", $entry->getAttribute("src"))) { 27 | $basenode = $entry; 28 | break; 29 | } 30 | } 31 | 32 | if ($basenode) { 33 | $article["content"] = $doc->saveHTML($basenode); 34 | $article["plugin_data"] = "af_comics,$owner_uid:" . $article["plugin_data"]; 35 | } 36 | } 37 | } else if (isset($article["stored"]["content"])) { 38 | $article["content"] = $article["stored"]["content"]; 39 | } 40 | 41 | return true; 42 | } 43 | 44 | return false; 45 | } 46 | } 47 | ?> 48 | -------------------------------------------------------------------------------- /af_comics/filters/af_comics_optipess.php: -------------------------------------------------------------------------------- 1 | loadHTML(fetch_file_contents($article["link"])); 15 | 16 | if ($doc) { 17 | $xpath = new DOMXPath($doc); 18 | 19 | $entries = $xpath->query('(//div[contains(@id, "comic")]//img[@alt])'); 20 | 21 | $basenode = false; 22 | foreach ($entries as $entry) { 23 | $basenode = $entry->parentNode; 24 | 25 | // add linebreak 26 | $linebreak = $doc->createElement("br"); 27 | $basenode->appendChild( $linebreak ); 28 | 29 | // add text 30 | $alt = $entry->getAttribute("alt"); 31 | $textnode = $doc->createTextNode( $alt ); 32 | $basenode->appendChild($textnode); 33 | break; 34 | } 35 | 36 | if ($basenode) { 37 | $article["content"] = $doc->saveHTML($basenode); 38 | $article["plugin_data"] = "af_comics,$owner_uid:" . $article["plugin_data"]; 39 | } 40 | } 41 | } else if (isset($article["stored"]["content"])) { 42 | $article["content"] = $article["stored"]["content"]; 43 | } 44 | 45 | return true; 46 | } 47 | 48 | return false; 49 | } 50 | } 51 | ?> 52 | -------------------------------------------------------------------------------- /af_comics/filters/af_comics_stuttmann.php: -------------------------------------------------------------------------------- 1 | loadHTML($article["content"]); 15 | 16 | if ($doc) { 17 | $xpath = new DOMXPath($doc); 18 | $entries = $xpath->query('(//img[@src])'); 19 | 20 | $found = false; 21 | 22 | foreach ($entries as $entry) { 23 | $src = $entry->getAttribute("src"); 24 | $src = preg_replace("/\/thumbs\//", "/", $src); 25 | /* $src = preg_replace("/jpg$/", "gif", $src); */ 26 | $entry->setAttribute("src", $src); 27 | $found = true; 28 | } 29 | 30 | $node = $doc->getElementsByTagName('body')->item(0); 31 | 32 | if ($node && $found) { 33 | $article["content"] = $doc->saveHTML($node); 34 | $article["plugin_data"] = "af_comics,$owner_uid:" . $article["plugin_data"]; 35 | } 36 | } 37 | } else if (isset($article["stored"]["content"])) { 38 | $article["content"] = $article["stored"]["content"]; 39 | } 40 | 41 | return true; 42 | } 43 | 44 | return false; 45 | } 46 | } 47 | ?> 48 | -------------------------------------------------------------------------------- /af_comics/filters/af_comics_userfriendly.php: -------------------------------------------------------------------------------- 1 | loadHTML(mb_convert_encoding(fetch_file_contents($article["link"]), 'HTML-ENTITIES', "UTF-8")); 15 | 16 | $basenode = false; 17 | 18 | if ($doc) { 19 | $xpath = new DOMXPath($doc); 20 | 21 | $entries = $xpath->query('(//img[@alt])'); 22 | 23 | foreach ($entries as $entry) { 24 | 25 | if(strpos($entry->getAttribute('alt'), 'Strip for') !== false) { 26 | $basenode = $entry; 27 | break; 28 | } 29 | } 30 | 31 | if ($basenode) { 32 | $article["content"] = $doc->saveHTML($basenode); 33 | $article["plugin_data"] = "af_comics,$owner_uid:" . $article["plugin_data"]; 34 | } 35 | } 36 | } else if (isset($article["stored"]["content"])) { 37 | $article["content"] = $article["stored"]["content"]; 38 | } 39 | 40 | return true; 41 | } 42 | 43 | return false; 44 | } 45 | } 46 | ?> 47 | -------------------------------------------------------------------------------- /af_comics/filters/af_comics_wordpress.php: -------------------------------------------------------------------------------- 1 | loadHTML(fetch_file_contents($article["link"])); 17 | 18 | $basenode = false; 19 | 20 | if ($doc) { 21 | $xpath = new DOMXPath($doc); 22 | $entries = $xpath->query('(//div[@class="entry-content"]//img[@src])|(//div[@id="content-wrapper"]//img[@src])'); 23 | 24 | foreach ($entries as $entry) { 25 | if (preg_match("/(https?:\/\/.*\/wp-content\/uploads\/.*)/i", $entry->getAttribute("src"))) { 26 | $entry->removeAttribute("srcset"); 27 | $basenode = $entry; 28 | break; 29 | } 30 | } 31 | 32 | if ($basenode) { 33 | $article["content"] = $doc->saveHTML($basenode); 34 | $article["plugin_data"] = "af_comics,$owner_uid:" . $article["plugin_data"]; 35 | } 36 | } 37 | } else if (isset($article["stored"]["content"])) { 38 | $article["content"] = $article["stored"]["content"]; 39 | } 40 | 41 | return true; 42 | } 43 | 44 | return false; 45 | } 46 | } 47 | ?> 48 | -------------------------------------------------------------------------------- /af_comics/filters/af_comics_xkcd.php: -------------------------------------------------------------------------------- 1 | loadHTML($article["content"]); 15 | 16 | if ($doc) { 17 | $xpath = new DOMXPath($doc); 18 | $entries = $xpath->query('(//img[@alt])'); 19 | 20 | $basenode = false; 21 | 22 | foreach ($entries as $entry) { 23 | // get image 24 | $basenode = $entry->parentNode; 25 | 26 | // add linebreak 27 | $linebreak = $doc->createElement("br"); 28 | $basenode->appendChild( $linebreak ); 29 | 30 | // add text 31 | $alt = $entry->getAttribute("alt"); 32 | $textnode = $doc->createTextNode( $alt ); 33 | $basenode->appendChild($textnode); 34 | break; 35 | } 36 | 37 | if($basenode) { 38 | $doc->removeChild( $doc->firstChild ); 39 | $article["content"] = $doc->saveHTML(); 40 | $article["plugin_data"] = "af_comics,$owner_uid:" . $article["plugin_data"]; 41 | } 42 | } 43 | } else if (isset($article["stored"]["content"])) { 44 | $article["content"] = $article["stored"]["content"]; 45 | } 46 | 47 | return true; 48 | } 49 | 50 | return false; 51 | } 52 | } 53 | ?> 54 | -------------------------------------------------------------------------------- /af_datenschutzbuero/init.php: -------------------------------------------------------------------------------- 1 | host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | $host->add_hook($host::HOOK_FEED_FETCHED, $this); 21 | } 22 | 23 | function hook_feed_fetched($feed_data, $fetch_url, $owner_uid, $feed) { 24 | if (strpos($fetch_url, "datenschutz.de/rss") !== FALSE) { 25 | // Feed does not encode & in , but in 26 | // For now, there aren't any & in other fields (like url) 27 | $feed_data = str_replace('&', '&', $feed_data); 28 | $feed_data = str_replace('&', '&', $feed_data); 29 | } 30 | return $feed_data; 31 | } 32 | 33 | private function removeStuff($xpath, $filter) { 34 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 35 | $stuff = $xpath->query($filter); 36 | foreach ($stuff as $removethis) { 37 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 38 | /* _debug(htmlspecialchars($removethis->C14N())); */ 39 | $removethis->parentNode->removeChild($removethis); 40 | } 41 | } 42 | 43 | function hook_article_filter($article) { 44 | if (strpos($article["link"], "datenschutz.de") !== FALSE) { 45 | $doc = new DOMDocument(); 46 | $content = fetch_file_contents($article["link"]); 47 | @$doc->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'Windows-1252')); 48 | 49 | $basenode = false; 50 | 51 | if ($doc) { 52 | $xpath = new DOMXPath($doc); 53 | 54 | $this->removeStuff($xpath, '(//script)|(//noscript)|(//style)|(//hr[@noshade])|(//div[@align="center"])'); 55 | 56 | $entries = $xpath->query('(//div[@id="content"])'); 57 | foreach ($entries as $entry) { 58 | $new_content = $doc->saveHTML($entry); 59 | break; 60 | } 61 | 62 | if($new_content) { 63 | $new_content = preg_replace('/\s\s+/', ' ', $new_content); 64 | $article["content"] = $new_content; 65 | /* _debug(htmlspecialchars($new_content)); */ 66 | } 67 | } 68 | } 69 | return $article; 70 | } 71 | } 72 | ?> 73 | -------------------------------------------------------------------------------- /af_digitalcourage/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_digitalcourage extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.4, 8 | "Fetch content of digitalcourage feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | private function removeStuff($xpath, $filter) { 23 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 24 | $stuff = $xpath->query($filter); 25 | foreach ($stuff as $removethis) { 26 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 27 | /* _debug(htmlspecialchars($removethis->C14N())); */ 28 | $removethis->parentNode->removeChild($removethis); 29 | } 30 | } 31 | 32 | function hook_article_filter($article) { 33 | if (strpos($article["link"], "digitalcourage.de") !== FALSE) { 34 | $doc = new DOMDocument(); 35 | @$doc->loadHTML(mb_convert_encoding(fetch_file_contents($article["link"]), 'HTML-ENTITIES', "UTF-8")); 36 | 37 | $basenode = false; 38 | 39 | if ($doc) { 40 | $xpath = new DOMXPath($doc); 41 | 42 | $this->removeStuff($xpath, '(//div[@class="documentActions"])'); 43 | 44 | $entries = $xpath->query('(//div[@id="content"])'); 45 | foreach ($entries as $entry) { 46 | $new_content = $doc->saveHTML($entry); 47 | break; 48 | } 49 | 50 | if($new_content) { 51 | $new_content = preg_replace('/\s\s+/', ' ', $new_content); 52 | $article["content"] = $new_content; 53 | /* _debug(htmlspecialchars($new_content)); */ 54 | } 55 | } 56 | } 57 | return $article; 58 | } 59 | } 60 | ?> 61 | -------------------------------------------------------------------------------- /af_faz/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_faz extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.3, 8 | "Fetch content of FAZ feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 19 | } 20 | 21 | private function removeStuff($xpath, $filter) { 22 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 23 | $stuff = $xpath->query($filter); 24 | foreach ($stuff as $removethis) { 25 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 26 | /* _debug(htmlspecialchars($removethis->C14N())); */ 27 | $removethis->parentNode->removeChild($removethis); 28 | } 29 | } 30 | 31 | function hook_article_filter($article) { 32 | if (strpos($article["link"], "faz.net") !== FALSE) { 33 | $doc = new DOMDocument(); 34 | @$doc->loadHTML(mb_convert_encoding(fetch_file_contents($article["link"]), 'HTML-ENTITIES', "UTF-8")); 35 | 36 | $new_content = ''; 37 | 38 | if ($doc) { 39 | $xpath = new DOMXPath($doc); 40 | 41 | $this->removeStuff($xpath, '(//script)|(//noscript)|(//style)|(//figure)|(//aside)'); 42 | $this->removeStuff($xpath, '(//div[@class="ContainerSocialMedia"])|(//span[contains(@class, "Hidden")])|(//ul[contains(@class, "Author_Profile")])|(//div[contains(@class, "PlaceholderBox")])'); 43 | 44 | $entries = $xpath->query('(//div[contains(@class, "atc-Text")])|(//div[@itemprop="articleBody"])|(//div[@class="single-entry-content"])'); 45 | 46 | foreach ($entries as $entry) { 47 | $new_content = $doc->saveHTML($entry); 48 | break; 49 | } 50 | 51 | if($new_content) { 52 | $new_content = preg_replace('/\s\s+/', ' ', $new_content); 53 | $article["content"] = $new_content; 54 | /* _debug(htmlspecialchars($new_content)); */ 55 | } 56 | } 57 | } 58 | return $article; 59 | } 60 | } 61 | ?> 62 | -------------------------------------------------------------------------------- /af_gamestar/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_Gamestar extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.4, 8 | "Fetch content of gamestar.de feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | private function removeStuff($xpath, $filter) { 23 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 24 | $stuff = $xpath->query($filter); 25 | foreach ($stuff as $removethis) { 26 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 27 | /* _debug(htmlspecialchars($removethis->C14N())); */ 28 | $removethis->parentNode->removeChild($removethis); 29 | } 30 | } 31 | 32 | function hook_article_filter($article) { 33 | if (strpos($article["link"], "gamestar.de") !== FALSE) { 34 | $doc = new DOMDocument(); 35 | $html = fetch_file_contents($article["link"]); 36 | // remove <script>-Tags (causing trouble with nested <div>-writes) 37 | // sU = including newline, not greedy 38 | $html = preg_replace('/<script .*<\/script>/sU', '', $html); 39 | @$doc->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8")); 40 | 41 | $basenode = false; 42 | 43 | if ($doc) { 44 | $xpath = new DOMXPath($doc); 45 | 46 | $this->removeStuff($xpath, '(//script)|(//noscript)|(//div[@id="comments"])|(//p[contains(@class, "info")])|'. 47 | '(//div[contains(@class, "teaser")])|(//div[@class="modal-body"])|(//p[@class="caption"])|(//ul[contains(@class, "taglist")])|'. 48 | '(//div[@id="socialshare"])|(//div[@class="imagecontainer"])|(//h1)|(//a[@class="hidden-md-up"])|'. 49 | '(//img[@height="1" or @width="1"])'); 50 | 51 | $entries = $xpath->query('(//div[contains(@class, "article")])'); 52 | foreach ($entries as $entry) { 53 | if (!$basenode) { 54 | $basenode = $entry; 55 | } else { 56 | $basenode->appendChild($entry); 57 | } 58 | } 59 | 60 | if ($basenode) { 61 | $new_content = $doc->saveHTML($basenode); 62 | $new_content = preg_replace('/\s\s+/', ' ', $new_content); 63 | $article["content"] = $new_content; 64 | /* _debug(htmlspecialchars($new_content)); */ 65 | } 66 | } 67 | } 68 | return $article; 69 | } 70 | } 71 | ?> 72 | -------------------------------------------------------------------------------- /af_githubcommits/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_GithubCommits extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.3, 8 | "Show all commits in github feed.", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 19 | } 20 | 21 | function hook_article_filter($article) { 22 | if (strpos($article["link"], "github.com") !== FALSE && strpos($article["link"], "/compare/") !== FALSE) { 23 | $doc = new DOMDocument(); 24 | @$doc->loadHTML($article["content"]); 25 | 26 | $basenode = false; 27 | 28 | if ($doc) { 29 | $xpath = new DOMXPath($doc); 30 | 31 | // Remove 'View comparison for these x commits >>' 32 | $stuff = $xpath->query('//a[contains(text(),"View comparison for these ")]'); 33 | foreach ($stuff as $removethis) { 34 | $removethis->parentNode->parentNode->removeChild($removethis->parentNode); 35 | 36 | } 37 | // Fetch 'x more commits >>' 38 | $stuff = $xpath->query('//a[contains(text()," more commit")]'); 39 | foreach ($stuff as $removethis) { 40 | // 1. Remove old links 41 | $url = $removethis->attributes->getNamedItem("href")->value; 42 | /* _debug('URL = '.$url); */ 43 | $item = $removethis->parentNode; 44 | $list = $item->parentNode; 45 | while($list->childNodes->length > 0) { 46 | $list->removeChild($list->childNodes->item(0)); 47 | } 48 | 49 | // 2. Fetch URL (.patch) 50 | $patch = fetch_file_contents('https://www.github.com/'.$url.'.patch'); 51 | 52 | // 3. Search for ^Subject... & ^From ... 53 | $lines = explode("\n", $patch); 54 | $fromlength = strlen('From '); 55 | $subjectlength = strlen('Subject: '); 56 | $curSubject = ''; 57 | $curHash = ''; 58 | $subLastline = false; 59 | $linkbase = substr($article['link'], 0, strpos($article['link'], 'compare')); 60 | foreach ($lines as $line) { 61 | if ($subLastline && substr($line, 0, 1) === ' ') { 62 | $curSubject = $curSubject.$line; 63 | } else 64 | $subLastline = false; 65 | if (substr($line, 0, $subjectlength) === 'Subject: ') { 66 | $curSubject = substr($line, $subjectlength); 67 | /* _debug('Found subject: '.$curSubject); */ 68 | $subLastline = true; 69 | } 70 | elseif (substr($line, 0, $fromlength) === 'From ') { 71 | $curHash = substr($line, $fromlength, 40); 72 | /* _debug('Found hash: '.$curHash); */ 73 | } 74 | else { continue; } 75 | if (!empty($curSubject) && !empty($curHash)) { 76 | // Found patchlink&title, rebuild ul structure for feed 77 | /* _debug('Found both, blabla!'); */ 78 | $li = $doc->createElement('li'); 79 | $code = $doc->createElement('code'); 80 | $a = $doc->createElement('a'); 81 | $div = $doc->createElement('div'); 82 | $quote = $doc->createElement('blockquote'); 83 | 84 | $quote->textContent = $curSubject; 85 | $a->textContent = $curHash; 86 | 87 | $Eli = $list->appendChild($li); 88 | $Ecode = $Eli->appendChild($code); 89 | $Ediv = $Eli->appendChild($div); 90 | $Ea = $Ecode->appendChild($a); 91 | $Equote = $Ediv->appendChild($quote); 92 | 93 | $Ea->setAttribute('href', $linkbase.'commit/'.$curHash); 94 | 95 | $curHash = ''; 96 | $curSubject = ''; 97 | $subLastline = false; 98 | } 99 | } 100 | } 101 | 102 | $node = $doc->getElementsByTagName('body')->item(0); 103 | 104 | if ($node) { 105 | $article["content"] = $doc->saveHTML($node); 106 | /* _debug(htmlspecialchars($article["content"])); */ 107 | } 108 | } 109 | } 110 | return $article; 111 | } 112 | } 113 | ?> 114 | -------------------------------------------------------------------------------- /af_githubnoavatars/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_GithubNoAvatars extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.2, 8 | "Remove avatars in github feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | $host->add_hook($host::HOOK_FORMAT_ENCLOSURES, $this); 21 | } 22 | 23 | private function removeStuff($xpath, $filter) { 24 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 25 | $stuff = $xpath->query($filter); 26 | foreach ($stuff as $removethis) { 27 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 28 | /* _debug(htmlspecialchars($removethis->C14N())); */ 29 | $removethis->parentNode->removeChild($removethis); 30 | } 31 | } 32 | 33 | public function hook_format_enclosures($rv, $result, $id, $always_display_enclosures, $article_content, $hide_images) 34 | { 35 | $newresult = array(); 36 | foreach ($result as $enc) { 37 | $url = $enc['content_url']; 38 | if (strpos($url, 'githubusercontent') === FALSE || strpos($url, 'avatar') === FALSE ) { 39 | $newresult[] = $enc; 40 | } 41 | } 42 | return array('', $newresult); 43 | } 44 | 45 | function hook_article_filter($article) { 46 | if (strpos($article["link"], "github.com") !== FALSE) { 47 | $doc = new DOMDocument(); 48 | @$doc->loadHTML($article["content"]); 49 | 50 | $basenode = false; 51 | 52 | if ($doc) { 53 | $xpath = new DOMXPath($doc); 54 | 55 | $this->removeStuff($xpath, '//img'); 56 | 57 | $node = $doc->getElementsByTagName('body')->item(0); 58 | 59 | if ($node) { 60 | $article["content"] = $doc->saveHTML($node); 61 | } 62 | } 63 | } 64 | return $article; 65 | } 66 | } 67 | ?> 68 | -------------------------------------------------------------------------------- /af_githubreleases/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_GithubReleases extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.0, 8 | "Add repository name to github releases feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 19 | } 20 | 21 | function hook_article_filter($article) { 22 | if (preg_match('/github.com\/.*\/(.*)\/releases.atom$/', $article["feed"]["fetch_url"], $matches) === 1) { 23 | $repositoryName = $matches[1]; 24 | if (strpos(strtolower($article['title']), strtolower($repositoryName)) === FALSE) { 25 | $article['title'] = sprintf("[%s] %s", $repositoryName, $article['title']); 26 | } 27 | } 28 | return $article; 29 | } 30 | } 31 | ?> 32 | -------------------------------------------------------------------------------- /af_gnonline/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_GNOnline extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.3, 8 | "Fetch content of gn-online.de feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | private function removeStuff($xpath, $filter) { 23 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 24 | $stuff = $xpath->query($filter); 25 | foreach ($stuff as $removethis) { 26 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 27 | /* _debug(htmlspecialchars($removethis->C14N())); */ 28 | $removethis->parentNode->removeChild($removethis); 29 | } 30 | } 31 | 32 | function hook_article_filter($article) { 33 | if (strpos($article["link"], "gn-online.de") !== FALSE) { 34 | $doc = new DOMDocument(); 35 | $html = fetch_file_contents($article["link"]); 36 | 37 | @$doc->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8")); 38 | 39 | $paidContent = (strpos($html, "...WEITERLESEN?") !== FALSE); 40 | 41 | if ($doc) { 42 | $xpath = new DOMXPath($doc); 43 | 44 | $this->removeStuff($xpath, '(//script)|(//noscript)|(//header)|(//div[@class="clear"])'); 45 | $this->removeStuff($xpath, '(//div[contains(@class, "StoryShowShare")])|(//div[contains(@class, "StoryShowInteraction")])'); 46 | 47 | $entries = $xpath->query('(//span[@class="Ortsmarke"])'); 48 | foreach ($entries as $entry) { 49 | $entry->textContent = '[' . trim($entry->textContent) . '] '; 50 | } 51 | 52 | if ($paidContent) { 53 | $query = '(//div[@class="StoryShowBox"])'; 54 | } else { 55 | $query = '(//div[@class="StoryShowBox"])|(//div[@class="StoryShowBaseTextBox"])'; 56 | } 57 | 58 | $new_content = ""; 59 | $entries = $xpath->query($query); 60 | foreach ($entries as $entry) { 61 | $new_content = $new_content . $doc->saveHTML($entry); 62 | } 63 | 64 | if($new_content) { 65 | $new_content = preg_replace('/\s\s+/', ' ', $new_content); 66 | $article["content"] = $new_content; 67 | /* _debug(htmlspecialchars($new_content)); */ 68 | } 69 | } 70 | 71 | if ($paidContent) { 72 | $article["content"] = "<p><strong>Dieser Artikel benötigt ein Abo.</strong></p>" . $article["content"]; 73 | } 74 | 75 | } 76 | return $article; 77 | } 78 | } 79 | ?> 80 | -------------------------------------------------------------------------------- /af_golem/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_Golem extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(2.0, 8 | "Fetch content of golem feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | private function removeStuff($xpath, $filter) { 23 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 24 | $stuff = $xpath->query($filter); 25 | foreach ($stuff as $removethis) { 26 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 27 | /* _debug(htmlspecialchars($removethis->C14N())); */ 28 | $removethis->parentNode->removeChild($removethis); 29 | } 30 | } 31 | 32 | private function fetch_page($url) { 33 | $useragent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"; 34 | 35 | $url = ltrim($url, ' '); 36 | $url = str_replace(' ', '%20', $url); 37 | $url = validate_url($url); 38 | if (!$url) return false; 39 | 40 | $url_host = parse_url($url, PHP_URL_HOST); 41 | 42 | if (!defined('NO_CURL') && function_exists('curl_init') && !ini_get("open_basedir")) { 43 | $ch = curl_init($url); 44 | 45 | $curl_http_headers = []; 46 | array_push($curl_http_headers, "Cookie: golem_consent20=simple|200801;"); 47 | 48 | if (count($curl_http_headers) > 0) 49 | curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_http_headers); 50 | 51 | curl_setopt($ch, CURLOPT_MAXREDIRS, 20); 52 | curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); 53 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 54 | curl_setopt($ch, CURLOPT_HEADER, true); 55 | curl_setopt($ch, CURLOPT_USERAGENT, $useragent); 56 | curl_setopt($ch, CURLOPT_ENCODING, ""); 57 | 58 | if (!ini_get("open_basedir")) { 59 | curl_setopt($ch, CURLOPT_COOKIEJAR, "/dev/null"); 60 | } 61 | 62 | $ret = @curl_exec($ch); 63 | 64 | $headers_length = curl_getinfo($ch, CURLINFO_HEADER_SIZE); 65 | $headers = explode("\r\n", substr($ret, 0, $headers_length)); 66 | $contents = substr($ret, $headers_length); 67 | 68 | foreach ($headers as $header) { 69 | if (strstr($header, ": ") !== FALSE) { 70 | list ($key, $value) = explode(": ", $header); 71 | 72 | if (strtolower($key) == "last-modified") { 73 | $fetch_last_modified = $value; 74 | } 75 | } 76 | 77 | if (substr(strtolower($header), 0, 7) == 'http/1.') { 78 | $fetch_last_error_code = (int) substr($header, 9, 3); 79 | $fetch_last_error = $header; 80 | } 81 | } 82 | 83 | if (curl_errno($ch) === 23 || curl_errno($ch) === 61) { 84 | curl_setopt($ch, CURLOPT_ENCODING, 'none'); 85 | $contents = @curl_exec($ch); 86 | } 87 | 88 | $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); 89 | $fetch_last_content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); 90 | 91 | $fetch_effective_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); 92 | 93 | $fetch_last_error_code = $http_code; 94 | 95 | if ($http_code != 200 || $type && strpos($fetch_last_content_type, "$type") === false) { 96 | 97 | if (curl_errno($ch) != 0) { 98 | $fetch_last_error .= "; " . curl_errno($ch) . " " . curl_error($ch); 99 | } 100 | 101 | $fetch_last_error_content = $contents; 102 | curl_close($ch); 103 | return false; 104 | } 105 | 106 | if (!$contents) { 107 | $fetch_last_error = curl_errno($ch) . " " . curl_error($ch); 108 | curl_close($ch); 109 | return false; 110 | } 111 | 112 | curl_close($ch); 113 | 114 | $is_gzipped = RSSUtils::is_gzipped($contents); 115 | 116 | if ($is_gzipped) { 117 | $tmp = @gzdecode($contents); 118 | 119 | if ($tmp) $contents = $tmp; 120 | } 121 | 122 | return $contents; 123 | } else { 124 | _debug("Lazy me did not support non-curl here."); 125 | } 126 | 127 | } 128 | 129 | protected function load_page($link) { 130 | 131 | $doc = new DOMDocument(); 132 | 133 | $url = str_replace("-rss", "", $link); 134 | $html = $this->fetch_page($url); 135 | 136 | // $html_enc = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8"); 137 | $doc->loadHTML($html); 138 | 139 | $basenode = false; 140 | $add_content = ""; 141 | 142 | if ($doc) { 143 | $xpath = new DOMXPath($doc); 144 | 145 | $nextpage = $xpath->query('//a[@id="jtocb_next"]'); 146 | if($nextpage && $nextpage->length > 0 && $nextpage->item(0)->hasAttributes()){ 147 | /* _debug("Found next page: " . "https://www.golem.de".$nextpage->item(0)->attributes->getNamedItem("href")->value); */ 148 | $add_content = $this->load_page("https://www.golem.de".$nextpage->item(0)->attributes->getNamedItem("href")->value); 149 | } 150 | 151 | // Fix gallery images 152 | $galleryimg = $xpath->query('(//img[@data-src])'); 153 | foreach ($galleryimg as $img) { 154 | /* _debug("Found image: " . $img->getAttribute('data-src')); */ 155 | $img->setAttribute('src', $img->getAttribute('data-src')); 156 | } 157 | 158 | // Remove advertising and scripts 159 | $this->removeStuff($xpath, '(//script)|(//noscript)|(//figcaption)|(//style)|(//ul[contains(@class, "social-tools")])|(//section[@id="job-market"])|(//div[@id="breadcrumbs"])|(//div[@class="tags"])|(//div[contains(@id, "iqad") or contains(@class, "iqad")])|(//header[@class="cluster-header"]/h1)|(//div[@class="changelog_list"])|(//table[@id="table-jtoc"])|(//ol[@id="list-jtoc"])'); 160 | 161 | // now get the (cleaned) article 162 | $entries = $xpath->query('(//article)'); 163 | foreach ($entries as $entry) { 164 | $new_content = $doc->saveHTML($entry); 165 | break; 166 | } 167 | 168 | if($new_content) { 169 | return $new_content . $add_content; 170 | } 171 | else return false; 172 | } 173 | } 174 | 175 | function hook_article_filter($article) { 176 | if (strpos($article["guid"], "golem.de") !== FALSE) { 177 | if( ($content = $this->load_page($article["link"])) != FALSE) { 178 | $content = preg_replace('/\s\s+/', ' ', $content); 179 | /* _debug("Done. Content below!"); */ 180 | /* _debug(htmlspecialchars($content)); */ 181 | $article["content"] = $content; 182 | } 183 | 184 | } 185 | return $article; 186 | } 187 | } 188 | ?> 189 | -------------------------------------------------------------------------------- /af_gulli/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_Gulli extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.4, 8 | "Fetch content of gulli.com feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | private function removeStuff($xpath, $filter) { 23 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 24 | $stuff = $xpath->query($filter); 25 | foreach ($stuff as $removethis) { 26 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 27 | /* _debug(htmlspecialchars($removethis->C14N())); */ 28 | $removethis->parentNode->removeChild($removethis); 29 | } 30 | } 31 | 32 | function hook_article_filter($article) { 33 | if (strpos($article["link"], "gulli.com") !== FALSE) { 34 | $doc = new DOMDocument(); 35 | @$doc->loadHTML(mb_convert_encoding(fetch_file_contents($article["link"]), 'HTML-ENTITIES', "UTF-8")); 36 | 37 | $basenode = false; 38 | 39 | if ($doc) { 40 | $xpath = new DOMXPath($doc); 41 | 42 | $this->removeStuff($xpath, '(//script)|(//noscript)|(//div[@class="adsenseContainer"])|(//div[@class="_newsCrumb"])|(//div[@class="_forumBox"])|(//div[@class="nointelliTXT"])'); 43 | 44 | $entries = $xpath->query('(//div[@id="_contentLeft"])'); 45 | foreach ($entries as $entry) { 46 | $new_content = $doc->saveHTML($entry); 47 | break; 48 | } 49 | 50 | if($new_content) { 51 | $new_content = preg_replace('/\s\s+/', ' ', $new_content); 52 | $article["content"] = $new_content; 53 | /* _debug(htmlspecialchars($new_content)); */ 54 | } 55 | } 56 | } 57 | return $article; 58 | } 59 | } 60 | ?> 61 | -------------------------------------------------------------------------------- /af_handelsblatt/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_Handelsblatt extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.1, 8 | "Fetch content of handelsblatt.com feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | private function removeStuff($xpath, $filter) { 23 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 24 | $stuff = $xpath->query($filter); 25 | foreach ($stuff as $removethis) { 26 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 27 | /* _debug(htmlspecialchars($removethis->C14N())); */ 28 | $removethis->parentNode->removeChild($removethis); 29 | } 30 | } 31 | 32 | function hook_article_filter($article) { 33 | if (strpos($article["link"], "handelsblatt.com") !== FALSE) { 34 | $doc = new DOMDocument(); 35 | $html = fetch_file_contents($article["link"]); 36 | @$doc->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8")); 37 | 38 | $basenode = false; 39 | 40 | if ($doc) { 41 | $xpath = new DOMXPath($doc); 42 | 43 | $this->removeStuff($xpath, '(//script)|(//noscript)|(//style)|(//aside)'); 44 | $this->removeStuff($xpath, '(//img[@width="1" or @height="1"])|(//div[contains(@class, "ad-wrapper")])|(//div[contains(@class, "hollow-area")])|(//div[contains(@class, "special-html-box")])|(//ul[@class="vhb-author-shortcutlist"])'); 45 | $this->removeStuff($xpath, '(//div[@class="vhb-hidden"])|(//div[@class="clearfix"])|(//div[contains(@class, "hcf-content")])'); 46 | 47 | $entries = $xpath->query('(//span[@class="hcf-location-mark"])'); 48 | foreach ($entries as $entry) { 49 | $entry->textContent = '[' . trim($entry->textContent) . '] '; 50 | } 51 | 52 | $entries = $xpath->query('(//div[@itemprop="articleBody"])'); 53 | foreach ($entries as $entry) { 54 | $new_content = $doc->saveHTML($entry); 55 | break; 56 | } 57 | 58 | if($new_content) { 59 | $new_content = preg_replace('/\s\s+/', ' ', $new_content); 60 | $article["content"] = $new_content; 61 | /* _debug(htmlspecialchars($new_content)); */ 62 | } 63 | } 64 | 65 | } 66 | return $article; 67 | } 68 | } 69 | ?> 70 | -------------------------------------------------------------------------------- /af_heise/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | 3 | class Af_Heise extends Plugin { 4 | 5 | private $host; 6 | 7 | function about() { 8 | return array(1.6, 9 | "Fetch content of heise.de feed", 10 | "Joschasa"); 11 | } 12 | 13 | function api_version() { 14 | return 2; 15 | } 16 | 17 | function init($host) { 18 | $this->host = $host; 19 | 20 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 21 | } 22 | 23 | private function removeStuff($xpath, $filter) { 24 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 25 | $stuff = $xpath->query($filter); 26 | foreach ($stuff as $removethis) { 27 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 28 | /* _debug(htmlspecialchars($removethis->C14N())); */ 29 | $removethis->parentNode->removeChild($removethis); 30 | } 31 | } 32 | 33 | function hook_article_filter($article) { 34 | if ((strpos($article["link"], "heise.de") !== FALSE) 35 | || (strpos($article["link"], "techstage.de") !== FALSE)) { 36 | $link_orig = $article["link"]; //e.g.: "https://www.heise.de/newsticker/meldung/Waehrung-oder-Spekulationsobjekt-das-Bitcoin-Dilemma-Zahlen-oder-Zocken-3926657.html?wt_mc=rss.ho.beitrag.atom"; 37 | $link_complete_article = substr($link_orig, 0, strrpos($link_orig, '?')); 38 | 39 | //Not all article-links end with a ".html", so we have to append it in that case. 40 | if(strrpos($link_complete_article, '.html') !== false) { 41 | $link = $link_complete_article.'?seite=all'; 42 | } 43 | else { 44 | $link = $link_complete_article.'.html?seite=all'; 45 | } 46 | 47 | $doc = new DOMDocument(); 48 | @$doc->loadHTML(mb_convert_encoding(fetch_file_contents($link), 'HTML-ENTITIES', "UTF-8")); 49 | 50 | $new_content = ""; 51 | 52 | if ($doc) { 53 | $xpath = new DOMXPath($doc); 54 | 55 | //Remove unneeded stuff 56 | $this->removeStuff($xpath, '(//script)|(//noscript)|(//a[@class="hinweis_anzeige"])|(//div[@class="shariff"])|(//p[@class="themenseiten"])|(//p[@class="permalink"])|(//p[@class="printversion"])|(//footer)|(//div[@class="adbottom"])|(//div[@class="rte__dossier"])|(//div[@class="publish-info"])|(//h2[@class="article__heading"])|(//p[@class="article-content__lead"])|(//div[@class="creator-info"])|(//div[@class="article-footer__content"])|(//section)'); 57 | 58 | //c't and autos have their articles inside "section"-element 59 | if(strrpos($link_complete_article, '/ct/') !== false || strrpos($link_complete_article, '/autos/') !== false) { 60 | $entries = $xpath->query('(//section)'); 61 | } 62 | //All other magazines, e.g. "news", list their articles inside an "article"-element 63 | else { 64 | $entries = $xpath->query('(//article)'); 65 | } 66 | 67 | foreach ($entries as $entry) { 68 | $new_content = $doc->saveHTML($entry); 69 | break; 70 | } 71 | 72 | if ($new_content) { 73 | /* _debug(htmlspecialchars($new_content)); */ 74 | $article["content"] = $new_content; 75 | } else { 76 | //Problem here. Better output some infos into the feed to debug later 77 | ob_start(); 78 | var_dump($stuff); 79 | $result = ob_get_clean(); 80 | $article["content"] = "LINK: ".$link." - LINK_ORIG: ".$link_orig." - STUFF: ".$stuff; 81 | } 82 | } 83 | } 84 | return $article; 85 | } 86 | } 87 | ?> 88 | -------------------------------------------------------------------------------- /af_hltv/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_HLTV extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.1, 8 | "Fetch content of hltv.org newsfeed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | private function removeStuff($xpath, $filter) { 23 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 24 | $stuff = $xpath->query($filter); 25 | foreach ($stuff as $removethis) { 26 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 27 | /* _debug(htmlspecialchars($removethis->C14N())); */ 28 | $removethis->parentNode->removeChild($removethis); 29 | } 30 | } 31 | 32 | function hook_article_filter($article) { 33 | if (strpos($article["link"], "hltv.org/news/") !== FALSE) { 34 | $doc = new DOMDocument(); 35 | @$doc->loadHTML(mb_convert_encoding(fetch_file_contents($article["link"]), 'HTML-ENTITIES', "auto")); 36 | 37 | $basenode = false; 38 | 39 | if ($doc) { 40 | $xpath = new DOMXPath($doc); 41 | 42 | $this->removeStuff($xpath, '(//div[@id="_mcePaste"])'); 43 | 44 | $entries = $xpath->query('(//div[@id="newsContent"])'); 45 | foreach ($entries as $entry) { 46 | $new_content = $doc->saveHTML($entry); 47 | break; 48 | } 49 | 50 | if($new_content) { 51 | $new_content = preg_replace('/\s\s+/', ' ', $new_content); 52 | $article["content"] = $new_content; 53 | /* _debug(htmlspecialchars($new_content)); */ 54 | } 55 | } 56 | } 57 | return $article; 58 | } 59 | } 60 | ?> 61 | -------------------------------------------------------------------------------- /af_mimikama/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_Mimikama extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.0, 8 | "Fetch content of mimikama.at feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | private function removeStuff($xpath, $filter) { 23 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 24 | $stuff = $xpath->query($filter); 25 | foreach ($stuff as $removethis) { 26 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 27 | /* _debug(htmlspecialchars($removethis->C14N())); */ 28 | $removethis->parentNode->removeChild($removethis); 29 | } 30 | } 31 | 32 | function hook_article_filter($article) { 33 | if (strpos($article["link"], "mimikama.at") !== FALSE) { 34 | $doc = new DOMDocument(); 35 | @$doc->loadHTML(fetch_file_contents($article["link"])); 36 | 37 | $basenode = false; 38 | 39 | if ($doc) { 40 | $xpath = new DOMXPath($doc); 41 | 42 | $this->removeStuff($xpath, '(//script)|(//noscript)|(//div[contains(@class, "ads")])'); 43 | 44 | $content = ''; 45 | $entries = $xpath->query('(//div[contains(@class, "feature-image")])|(//div[@class="info"]/div[@class="name"])|(//div[contains(@class, "article-excerpt")])'); 46 | _debug("Entries: ".$entries->length); 47 | foreach ($entries as $entry) { 48 | _debug("FOUND"); 49 | _debug(htmlspecialchars($content)); 50 | $content .= $doc->saveHTML($entry); 51 | } 52 | 53 | if($content) { 54 | $content = preg_replace('/\s\s+/', ' ', $content); 55 | $article["content"] = $content; 56 | /* _debug(htmlspecialchars($content)); */ 57 | } 58 | } 59 | } 60 | return $article; 61 | } 62 | } 63 | ?> 64 | -------------------------------------------------------------------------------- /af_nrz/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_nrz extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.2, 8 | "Fetch content of NRZ feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 19 | } 20 | 21 | private function removeStuff($xpath, $filter) { 22 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 23 | $stuff = $xpath->query($filter); 24 | foreach ($stuff as $removethis) { 25 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 26 | /* _debug(htmlspecialchars($removethis->C14N())); */ 27 | $removethis->parentNode->removeChild($removethis); 28 | } 29 | } 30 | 31 | function hook_article_filter($article) { 32 | if (strpos($article["link"], "nrz.de") !== FALSE) { 33 | $doc = new DOMDocument(); 34 | @$doc->loadHTML(mb_convert_encoding(fetch_file_contents($article["link"]), 'HTML-ENTITIES', "UTF-8")); 35 | 36 | $basenode = false; 37 | 38 | if ($doc) { 39 | $xpath = new DOMXPath($doc); 40 | 41 | $this->removeStuff($xpath, '(//script)|(//noscript)|(//aside)'); 42 | 43 | $entries = $xpath->query('(//article)'); 44 | 45 | $new_content = ""; 46 | foreach ($entries as $entry) { 47 | $new_content = $new_content . $doc->saveHTML($entry); 48 | } 49 | 50 | if($new_content) { 51 | $new_content = preg_replace('/\s\s+/', ' ', $new_content); 52 | $article["content"] = $new_content; 53 | /* _debug(htmlspecialchars($new_content)); */ 54 | } 55 | } 56 | } 57 | return $article; 58 | } 59 | } 60 | ?> 61 | -------------------------------------------------------------------------------- /af_old_reddit/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_Old_Reddit extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.0, 8 | "Point towards old reddit", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | private function removeStuff($xpath, $filter) { 23 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 24 | $stuff = $xpath->query($filter); 25 | foreach ($stuff as $removethis) { 26 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 27 | /* _debug(htmlspecialchars($removethis->C14N())); */ 28 | $removethis->parentNode->removeChild($removethis); 29 | } 30 | } 31 | 32 | function hook_article_filter($article) { 33 | if (strpos($article["link"], "www.reddit") !== FALSE) { 34 | $article["link"] = str_replace("www.reddit", "old.reddit", $article["link"]); 35 | } 36 | return $article; 37 | } 38 | } 39 | ?> 40 | -------------------------------------------------------------------------------- /af_pcgames/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_PCGames extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.0, 8 | "Fetch content of pcgames.de feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | private function removeStuff($xpath, $filter) { 23 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 24 | $stuff = $xpath->query($filter); 25 | foreach ($stuff as $removethis) { 26 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 27 | /* _debug(htmlspecialchars($removethis->C14N())); */ 28 | $removethis->parentNode->removeChild($removethis); 29 | } 30 | } 31 | 32 | private function loadPage($url) { 33 | $doc = new DOMDocument(); 34 | $html = fetch_file_contents($url); 35 | @$doc->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8")); 36 | 37 | $basenode = false; 38 | 39 | if ($doc) { 40 | $xpath = new DOMXPath($doc); 41 | 42 | /* Find next page */ 43 | $next_page = $xpath->query('(//div[@class=articlenavigation_right]/a)'); 44 | $next_page_content = ""; 45 | foreach ($next_page as $entry) { 46 | $next_url = "http://www.pcgames.de".$nextpage->item(0)->attributes->getNamedItem("href")->value; 47 | $next_page_content = $this->loadPage($next_url); 48 | } 49 | 50 | $this->removeStuff($xpath, '(//script)|(//noscript)|(//*[contains(@class, "cxenseignore")])|'. 51 | '(//div[@class="affiliateNoteText"])|(//aside[contains(@class, "tagAndSocialFrame")])|'. 52 | '(//div[@class="articlenavigation"])|(//div[@class="linkToHomePageFromVideoContainer"])|' 53 | .'(//li[@class="articleInfoItem"])'); 54 | 55 | $entries = $xpath->query('(//article)'); 56 | foreach ($entries as $entry) { 57 | if (!$basenode) { 58 | $basenode = $entry; 59 | } else { 60 | $basenode->appendChild($entry); 61 | } 62 | } 63 | 64 | if ($basenode) { 65 | $new_content = $doc->saveHTML($basenode); 66 | $new_content = preg_replace('/\s\s+/', ' ', $new_content); 67 | return $new_content . $next_page_content; 68 | } else { 69 | return false; 70 | } 71 | } 72 | return false; 73 | } 74 | 75 | function hook_article_filter($article) { 76 | if (strpos($article["link"], "/PCGamesde/") !== FALSE) { 77 | if( ($content = $this->loadPage($article["link"])) != FALSE) { 78 | /* _debug("[Complete Page]"); */ 79 | /* _debug(htmlspecialchars($content)); */ 80 | $article["content"] = $content; 81 | } 82 | } 83 | return $article; 84 | } 85 | } 86 | ?> 87 | -------------------------------------------------------------------------------- /af_raumfahrer/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_Raumfahrer extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.5, 8 | "Fetch content of raumfahrer.net feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | private function removeStuff($xpath, $filter) { 23 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 24 | $stuff = $xpath->query($filter); 25 | foreach ($stuff as $removethis) { 26 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 27 | /* _debug(htmlspecialchars($removethis->C14N())); */ 28 | $removethis->parentNode->removeChild($removethis); 29 | } 30 | } 31 | 32 | function hook_article_filter($article) { 33 | if (strpos($article["link"], "raumfahrer.net") !== FALSE) { 34 | $doc = new DOMDocument(); 35 | @$doc->loadHTML(fetch_file_contents($article["link"])); 36 | 37 | // TODO: Add Express mp3 as attachment/enclosure once plugins are able to do that 38 | 39 | if ($doc) { 40 | $xpath = new DOMXPath($doc); 41 | 42 | $this->removeStuff($xpath, '(//div[@class="druckansicht"])|(//span[@class="head"])'); 43 | 44 | $entries = $xpath->query('(//td[@class="tab_text"])'); 45 | foreach ($entries as $entry) { 46 | $new_content = $doc->saveHTML($entry); 47 | break; 48 | } 49 | 50 | if($new_content) { 51 | $new_content = preg_replace('/\s\s+/', ' ', $new_content); 52 | $article["content"] = $new_content; 53 | /* _debug(htmlspecialchars($new_content)); */ 54 | } 55 | } 56 | } 57 | return $article; 58 | } 59 | } 60 | ?> 61 | -------------------------------------------------------------------------------- /af_rockpapershotgun/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_RockPaperShotgun extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.2, 8 | "Fetch content of rockpapershotgun.com feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | private function removeStuff($xpath, $filter) { 23 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 24 | $stuff = $xpath->query($filter); 25 | foreach ($stuff as $removethis) { 26 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 27 | /* _debug(htmlspecialchars($removethis->C14N())); */ 28 | $removethis->parentNode->removeChild($removethis); 29 | } 30 | } 31 | 32 | function hook_article_filter($article) { 33 | if (strpos($article["guid"], "rockpapershotgun.com") !== FALSE) { 34 | $doc = new DOMDocument(); 35 | @$doc->loadHTML(mb_convert_encoding(fetch_file_contents($article["link"]), 'HTML-ENTITIES', "UTF-8")); 36 | 37 | $basenode = false; 38 | 39 | if ($doc) { 40 | $xpath = new DOMXPath($doc); 41 | 42 | $this->removeStuff($xpath, '(//div[@class="dd_post_share"])|(//div[@class="social"])|(//iframe)'); 43 | 44 | $entries = $xpath->query('(//div[@class="entry"])'); 45 | foreach ($entries as $entry) { 46 | $new_content = $doc->saveHTML($entry); 47 | break; 48 | } 49 | 50 | if($new_content) { 51 | $new_content = preg_replace('/\s\s+/', ' ', $new_content); 52 | $article["content"] = $new_content; 53 | /* _debug(htmlspecialchars($new_content)); */ 54 | } 55 | } 56 | } 57 | return $article; 58 | } 59 | } 60 | ?> 61 | -------------------------------------------------------------------------------- /af_rponline/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_rponline extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.1, 8 | "Fetch content of RP Online feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 19 | } 20 | 21 | private function removeStuff($xpath, $filter) { 22 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 23 | $stuff = $xpath->query($filter); 24 | foreach ($stuff as $removethis) { 25 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 26 | /* _debug(htmlspecialchars($removethis->C14N())); */ 27 | $removethis->parentNode->removeChild($removethis); 28 | } 29 | } 30 | 31 | function hook_article_filter($article) { 32 | if (strpos($article["link"], "rp-online.de") !== FALSE) { 33 | $doc = new DOMDocument(); 34 | @$doc->loadHTML(mb_convert_encoding(fetch_file_contents($article["link"]), 'HTML-ENTITIES', "UTF-8")); 35 | 36 | if ($doc) { 37 | $xpath = new DOMXPath($doc); 38 | 39 | $this->removeStuff($xpath, '(//script)|(//noscript)|(//style)'); 40 | $this->removeStuff($xpath, '(//aside)|(//header)'); 41 | 42 | // Fetch Article Headline, Top Image, Article Paragraphs 43 | $content = ""; 44 | $entries = $xpath->query('(//p[contains(@class, "park-article__intro")])|(//img[contains(@class, "park-image")])|(//p[contains(@class, "text")])'); 45 | foreach ($entries as $entry) { 46 | $new_content = $doc->saveHTML($entry); 47 | /* _debug("Added: " . htmlspecialchars($new_content)); */ 48 | $content = $content . $new_content; 49 | } 50 | 51 | if($content) { 52 | $content = preg_replace('/\s\s+/', ' ', $content); 53 | $article["content"] = $content; 54 | /* _debug(htmlspecialchars($content)); */ 55 | } 56 | } 57 | } 58 | return $article; 59 | } 60 | } 61 | ?> 62 | -------------------------------------------------------------------------------- /af_ruhrbarone/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_Ruhrbarone extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.1, 8 | "Fetch content of ruhrbarone.de feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | private function removeStuff($xpath, $filter) { 23 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 24 | $stuff = $xpath->query($filter); 25 | foreach ($stuff as $removethis) { 26 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 27 | /* _debug(htmlspecialchars($removethis->C14N())); */ 28 | $removethis->parentNode->removeChild($removethis); 29 | } 30 | } 31 | 32 | function hook_article_filter($article) { 33 | if (strpos($article["link"], "ruhrbarone.de") !== FALSE) { 34 | $doc = new DOMDocument(); 35 | @$doc->loadHTML(mb_convert_encoding(fetch_file_contents($article["link"]), 'HTML-ENTITIES', "UTF-8")); 36 | 37 | $basenode = false; 38 | 39 | if ($doc) { 40 | $xpath = new DOMXPath($doc); 41 | 42 | // first remove advertisement stuff 43 | $this->removeStuff($xpath, '(//script)|(//noscript)'); 44 | 45 | // now get the (cleaned) article 46 | $entries = $xpath->query('(//div[@class="entry-content"])'); 47 | foreach ($entries as $entry) { 48 | $new_content = $doc->saveHTML($entry); 49 | break; 50 | } 51 | 52 | if($new_content) { 53 | $new_content = preg_replace('/\s\s+/', ' ', $new_content); 54 | $article["content"] = $new_content; 55 | /* _debug(htmlspecialchars($new_content)); */ 56 | } 57 | } 58 | } 59 | return $article; 60 | } 61 | } 62 | ?> 63 | -------------------------------------------------------------------------------- /af_spiegel/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_spiegel extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.6, 8 | "Fetch content of spiegel.de feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | private function removeStuff($xpath, $filter) { 23 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 24 | $stuff = $xpath->query($filter); 25 | foreach ($stuff as $removethis) { 26 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 27 | /* _debug(htmlspecialchars($removethis->C14N())); */ 28 | $removethis->parentNode->removeChild($removethis); 29 | } 30 | } 31 | 32 | function hook_article_filter($article) { 33 | if (strpos($article["link"], "spiegel.de") !== FALSE) { 34 | $doc = new DOMDocument(); 35 | @$doc->loadHTML(fetch_file_contents($article["link"])); 36 | 37 | $basenode = false; 38 | 39 | if ($doc) { 40 | $xpath = new DOMXPath($doc); 41 | 42 | $this->removeStuff($xpath, '(//script)|(//noscript)|(//div[contains(@class, "content_ad_")])|(//div[@class="article-function-social-media"])|(//div[contains(@class, "article-function-box")])'); 43 | 44 | $entries = $xpath->query('(//div[contains(@class, "article-section")])'); 45 | foreach ($entries as $entry) { 46 | $new_content = $doc->saveHTML($entry); 47 | break; 48 | } 49 | 50 | if($new_content) { 51 | $new_content = preg_replace('/\s\s+/', ' ', $new_content); 52 | $article["content"] = $new_content; 53 | /* _debug(htmlspecialchars($new_content)); */ 54 | } 55 | } 56 | } 57 | return $article; 58 | } 59 | } 60 | ?> 61 | -------------------------------------------------------------------------------- /af_ssdebian/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_SSDebian extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.3, 8 | "Fetch content of debian screenshots into feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | function hook_article_filter($article) { 23 | if (strpos($article["link"], "screenshots.debian.net") !== FALSE) { 24 | $feed = new DOMDocument(); 25 | 26 | $doc = new DOMDocument(); 27 | @$doc->loadHTML(fetch_file_contents($article["link"])); 28 | 29 | if ($doc) { 30 | $xpath = new DOMXPath($doc); 31 | $entries = $xpath->query('(//a[@href])'); // we might also check for img[@class='strip'] I guess... 32 | 33 | $matches = array(); 34 | 35 | foreach ($entries as $entry) { 36 | if (preg_match("/\/screenshots\/.*large\.png/i", $entry->getAttribute("href"))) { 37 | $picture = $feed->createElement("img"); 38 | $picture->setAttribute("src", "http://screenshots.debian.net".$entry->getAttribute("href")); 39 | $feed->appendChild($picture); 40 | } 41 | } 42 | 43 | $article["content"] = $feed->saveHTML(); 44 | } 45 | } 46 | return $article; 47 | } 48 | } 49 | ?> 50 | -------------------------------------------------------------------------------- /af_stimmthaltnicht/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_StimmtHaltNicht extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.2, 8 | "Fetch content of stimmthaltnicht.de feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | function hook_article_filter($article) { 23 | if (strpos($article["link"], "stimmthaltnicht.de") !== FALSE) { 24 | $doc = new DOMDocument(); 25 | @$doc->loadHTML(mb_convert_encoding(fetch_file_contents($article["link"]), 'HTML-ENTITIES', "UTF-8")); 26 | 27 | $basenode = false; 28 | 29 | if ($doc) { 30 | $xpath = new DOMXPath($doc); 31 | 32 | $entries = $xpath->query('(//div[@class="entry-content"])'); 33 | foreach ($entries as $entry) { 34 | $new_content = $doc->saveHTML($entry); 35 | break; 36 | } 37 | 38 | if($new_content) { 39 | $new_content = preg_replace('/\s\s+/', ' ', $new_content); 40 | $article["content"] = $new_content; 41 | /* _debug(htmlspecialchars($new_content)); */ 42 | } 43 | } 44 | } 45 | return $article; 46 | } 47 | } 48 | ?> 49 | -------------------------------------------------------------------------------- /af_sueddeutsche/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_sueddeutsche extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.3, 8 | "Fetch content of sueddeutsche feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | private function removeStuff($xpath, $filter) { 23 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 24 | $stuff = $xpath->query($filter); 25 | foreach ($stuff as $removethis) { 26 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 27 | /* _debug(htmlspecialchars($removethis->C14N())); */ 28 | $removethis->parentNode->removeChild($removethis); 29 | } 30 | } 31 | 32 | function hook_article_filter($article) { 33 | if (strpos($article["link"], "sz.de") !== FALSE) { 34 | $doc = new DOMDocument(); 35 | @$doc->loadHTML(mb_convert_encoding(fetch_file_contents($article["link"]), 'HTML-ENTITIES', "UTF-8")); 36 | 37 | $basenode = false; 38 | 39 | if ($doc) { 40 | $xpath = new DOMXPath($doc); 41 | 42 | $this->removeStuff($xpath, '(//script)|(//noscript)|(//div[@class="ad"])|(//section[@class="article-header"])|(//section[@class="article-footer"])|(//div[@class="article-sidebar-wrapper"])|(//span[@class="imagelabel"])'); 43 | 44 | $entries = $xpath->query('(//article)'); 45 | foreach ($entries as $entry) { 46 | $new_content = $doc->saveHTML($entry); 47 | break; 48 | } 49 | 50 | if($new_content) { 51 | $new_content = preg_replace('/\s\s+/', ' ', $new_content); 52 | $article["content"] = $new_content; 53 | /* _debug(htmlspecialchars($new_content)); */ 54 | } 55 | } 56 | } 57 | return $article; 58 | } 59 | } 60 | ?> 61 | -------------------------------------------------------------------------------- /af_tagesschau/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_tagesschau extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.6, 8 | "Fetch content of tagesschau.de feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 19 | } 20 | 21 | private function removeStuff($xpath, $filter) { 22 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 23 | $stuff = $xpath->query($filter); 24 | foreach ($stuff as $removethis) { 25 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 26 | /* _debug(htmlspecialchars($removethis->C14N())); */ 27 | $removethis->parentNode->removeChild($removethis); 28 | } 29 | } 30 | 31 | function hook_article_filter($article) { 32 | if (strpos($article["link"], "tagesschau.de") !== FALSE) { 33 | $doc = new DOMDocument(); 34 | @$doc->loadHTML(mb_convert_encoding(fetch_file_contents($article["link"]), 'HTML-ENTITIES', "UTF-8")); 35 | 36 | $basenode = false; 37 | 38 | if ($doc) { 39 | $xpath = new DOMXPath($doc); 40 | 41 | // first remove header, footer 42 | $this->removeStuff($xpath, '(//script)|(//noscript)|(//iframe)|(//div[contains(@class, "infokasten")])|(//div[@class="teaser"])|(//div[@class="socialMedia"])|(//div[contains(@class, "linklist")])|(//div[@class="metablockwrapper"])|(//div[@class="embedhinweis"])'); 43 | 44 | // rewrite gallery-icon with textlink 45 | $linktext = new DOMText('(Galerie)'); 46 | $galllink = $xpath->query('(//img[contains(@src, "galerie.png")])'); 47 | foreach ($galllink as $img) { 48 | $link = $img->parentNode; 49 | foreach ($link->childNodes as $child) { 50 | $link->removeChild($child); 51 | } 52 | $link->appendChild($linktext); 53 | } 54 | 55 | $move_src = $xpath->query('(//fieldset)'); 56 | $move_dst = $xpath->query('(//div[@class="mediaInfo"])'); 57 | if ($move_src->length > 1 && $move_dst->length > 1) { 58 | $move_dst->item(0)->appendChild($move_src->item(0)); 59 | } 60 | 61 | $entries = $xpath->query('(//div[contains(@class, "sectionZ")])|(//article)'); 62 | foreach ($entries as $entry) { 63 | $new_content = $doc->saveHTML($entry); 64 | break; 65 | } 66 | 67 | if($new_content) { 68 | $new_content = preg_replace('/\s\s+/', ' ', $new_content); 69 | $article["content"] = $new_content; 70 | /* _debug(htmlspecialchars($new_content)); */ 71 | } 72 | } 73 | } 74 | return $article; 75 | } 76 | } 77 | ?> 78 | -------------------------------------------------------------------------------- /af_taz/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_taz extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.5, 8 | "Fetch content of taz feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | function hook_article_filter($article) { 23 | if (strpos($article["link"], "taz.de") !== FALSE) { 24 | $doc = new DOMDocument(); 25 | @$doc->loadHTML(mb_convert_encoding(fetch_file_contents($article["link"]), 'HTML-ENTITIES', "UTF-8")); 26 | 27 | $basenode = false; 28 | 29 | if ($doc) { 30 | $xpath = new DOMXPath($doc); 31 | 32 | // first remove advertisement stuff 33 | $stuff = $xpath->query('(//script)|(//noscript)|(//iframe)|(//style)|(//div[@class="sectfoot"])|(//div[@id="tzi_paywall"])|(//div[contains(@class, "rack")])'); 34 | foreach ($stuff as $removethis) { 35 | $removethis->parentNode->removeChild($removethis); 36 | } 37 | 38 | $entries = $xpath->query('(//div[@class="sectbody"])'); 39 | foreach ($entries as $entry) { 40 | $basenode = $entry; 41 | break; 42 | } 43 | 44 | if ($basenode) { 45 | $article["content"] = $doc->saveHTML($basenode); 46 | } 47 | } 48 | } 49 | return $article; 50 | } 51 | } 52 | ?> 53 | -------------------------------------------------------------------------------- /af_thepit/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_thepit extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.2, 8 | "Fetch content of the-pit.de feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | function hook_article_filter($article) { 23 | if (strpos($article["link"], "the-pit.de") !== FALSE) { 24 | $doc = new DOMDocument(); 25 | @$doc->loadHTML(mb_convert_encoding(fetch_file_contents($article["link"]), 'HTML-ENTITIES', "UTF-8")); 26 | 27 | $basenode = false; 28 | 29 | if ($doc) { 30 | $xpath = new DOMXPath($doc); 31 | 32 | // first remove header, footer 33 | $stuff = $xpath->query('(//script)|(//noscript)|(//div[@class="ad"])|(//div[@class="header"])|(//div[@class="footer"])|(//div[@class="news-related-wrap"])|(//div[@class="addthis_toolbox"])|(//div[@class="disq"])'); 34 | 35 | foreach ($stuff as $removethis) { 36 | $removethis->parentNode->removeChild($removethis); 37 | } 38 | 39 | $entries = $xpath->query('(//div[@class="newsdetails"])'); 40 | 41 | foreach ($entries as $entry) { 42 | 43 | $basenode = $entry; 44 | break; 45 | } 46 | 47 | if ($basenode) { 48 | $article["content"] = $doc->saveHTML($basenode); 49 | } 50 | } 51 | } 52 | return $article; 53 | } 54 | } 55 | ?> 56 | -------------------------------------------------------------------------------- /af_titanic/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_Titanic extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.4, 8 | "Fetch content of Titanic feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | function hook_article_filter($article) { 23 | if (strpos($article["link"], "titanic-magazin.de") !== FALSE) { 24 | $doc = new DOMDocument(); 25 | @$doc->loadHTML(mb_convert_encoding(fetch_file_contents($article["link"]), 'HTML-ENTITIES', "UTF-8")); 26 | 27 | $basenode = false; 28 | 29 | if ($doc) { 30 | $xpath = new DOMXPath($doc); 31 | 32 | // first remove advertisement + tracking stuff 33 | $stuff = $xpath->query('(//script)|(//noscript)|(//form)|(//a[@name="form"])|(//p)|(//a[@href="newsticker.html"])'); 34 | 35 | foreach ($stuff as $removethis) { 36 | if($removethis->localName === "p") 37 | { 38 | if($removethis->textContent == "bezahlte Anzeige") 39 | { 40 | $removethis->parentNode->removeChild($removethis); 41 | } 42 | } 43 | else 44 | { 45 | $removethis->parentNode->removeChild($removethis); 46 | } 47 | } 48 | 49 | // now get the (cleaned) article 50 | $entries = $xpath->query('(//div[@class="tt_news-bodytext"])'); 51 | 52 | foreach ($entries as $entry) { 53 | 54 | $basenode = $entry; 55 | break; 56 | } 57 | 58 | if ($basenode) { 59 | $article["content"] = $doc->saveHTML($basenode); 60 | } 61 | } 62 | } 63 | return $article; 64 | } 65 | } 66 | ?> 67 | -------------------------------------------------------------------------------- /af_volksstimme/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_Volksstimme extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.2, 8 | "Fetch content of volksstimme.de newsfeed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | function hook_article_filter($article) { 23 | if (strpos($article["link"], "volksstimme.de") !== FALSE) { 24 | $doc = new DOMDocument(); 25 | @$doc->loadHTML(mb_convert_encoding(fetch_file_contents($article["link"]), 'HTML-ENTITIES', "auto")); 26 | 27 | $basenode = ""; 28 | 29 | if ($doc) { 30 | $xpath = new DOMXPath($doc); 31 | 32 | // first remove advertisement stuff 33 | /* $stuff = $xpath->query('(//div[contains(@class, "em_left")])|(//div[contains(@class, "em_artikelansicht_tags")])|(//div[contains(@class, "em_ads_")])'); */ 34 | 35 | /* foreach ($stuff as $removethis) { */ 36 | /* $removethis->parentNode->removeChild($removethis); */ 37 | /* } */ 38 | 39 | $entries = $xpath->query('(//div[@itemprop="image"]|//div[@itemprop="articleBody"])'); 40 | 41 | foreach ($entries as $entry) { 42 | $basenode = $basenode . $doc->saveHTML($entry); 43 | } 44 | 45 | if (!empty($basenode)) { 46 | $article["content"] = $basenode; 47 | } 48 | } 49 | } 50 | return $article; 51 | } 52 | } 53 | ?> 54 | -------------------------------------------------------------------------------- /af_winfuture/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_WinFuture extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.6, 8 | "Fetch content of winfuture feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | private function removeStuff($xpath, $filter) { 23 | /* _debug("[RemoveStuff] Running filter " . $filter); */ 24 | $stuff = $xpath->query($filter); 25 | foreach ($stuff as $removethis) { 26 | /* _debug("[RemoveStuff] Removing tag <" . $removethis->tagName . ">"); */ 27 | /* _debug(htmlspecialchars($removethis->C14N())); */ 28 | $removethis->parentNode->removeChild($removethis); 29 | } 30 | } 31 | 32 | function hook_article_filter($article) { 33 | if (strpos($article["link"], "winfuture.de") !== FALSE) { 34 | $doc = new DOMDocument(); 35 | $html = fetch_file_contents($article["link"]); 36 | $html = preg_replace('/(<[\ ]*br[\/\ ]*>){2}/', '<br />', $html); // remove double linebreaks 37 | $html = preg_replace('/<script .*<\/script>/', '', $html); // remove <script>-Tags (causing trouble with nested <div>-writes) 38 | @$doc->loadHTML($html); 39 | 40 | $basenode = false; 41 | 42 | if ($doc) { 43 | $xpath = new DOMXPath($doc); 44 | 45 | $this->removeStuff($xpath, '(//script)|(//noscript)|(//div[@id="wf_ContentAd"])|(//div[@class="wf_SingleAdNews"])|(//img[@width="1"])'); 46 | 47 | $entries = $xpath->query('(//div[@id="news_content"])|(//div[contains(@class, "showitxt")])'); 48 | foreach ($entries as $entry) { 49 | $basenode = $entry; 50 | break; 51 | } 52 | 53 | if ($basenode) { 54 | $article["content"] = $doc->saveHTML($basenode); 55 | } 56 | } 57 | } 58 | return $article; 59 | } 60 | } 61 | ?> 62 | -------------------------------------------------------------------------------- /af_wissenslogs/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_wissenslogs extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.2, 8 | "Fetch content of scilogs.de feed", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | function hook_article_filter($article) { 23 | if (strpos($article["link"], "scilogs.de/wblogs/blog") !== FALSE) { 24 | $doc = new DOMDocument(); 25 | @$doc->loadHTML(mb_convert_encoding(fetch_file_contents($article["link"]), 'HTML-ENTITIES', "UTF-8")); 26 | 27 | $basenode = false; 28 | 29 | if ($doc) { 30 | $xpath = new DOMXPath($doc); 31 | 32 | // first remove header, footer 33 | $stuff = $xpath->query('(//script)|(//noscript)|(//div[@id="socialshareprivacy"])'); 34 | 35 | foreach ($stuff as $removethis) { 36 | $removethis->parentNode->removeChild($removethis); 37 | } 38 | 39 | $entries = $xpath->query('(//div[@class="entrybody"])'); 40 | 41 | foreach ($entries as $entry) { 42 | 43 | $basenode = $entry; 44 | break; 45 | } 46 | 47 | if ($basenode) { 48 | $article["content"] = $doc->saveHTML($basenode); 49 | } 50 | } 51 | } 52 | return $article; 53 | } 54 | } 55 | ?> 56 | -------------------------------------------------------------------------------- /af_youtube/init.php: -------------------------------------------------------------------------------- 1 | <?php 2 | class Af_Youtube extends Plugin { 3 | 4 | private $host; 5 | 6 | function about() { 7 | return array(1.3, 8 | "Embed youtube video for youtube feeds.", 9 | "Joschasa"); 10 | } 11 | 12 | function api_version() { 13 | return 2; 14 | } 15 | 16 | function init($host) { 17 | $this->host = $host; 18 | 19 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); 20 | } 21 | 22 | function hook_article_filter($article) { 23 | $force = false; 24 | 25 | if (strpos($article['link'], 'youtube.com') !== FALSE || strpos($article['link'], 'youtu.be') !== FALSE) { 26 | $doc = new DOMDocument(); 27 | @$doc->loadHTML($article['content']); 28 | 29 | if ($doc) { 30 | $xpath = new DOMXPath($doc); 31 | $entries = $xpath->query('(//a[@href]/img)'); 32 | 33 | $found = false; 34 | 35 | foreach ($entries as $entry) { 36 | $entry = $entry->parentNode; 37 | $url = $entry->getAttribute('href'); 38 | 39 | $matches = array(); 40 | if (!preg_match_all('/(youtu.be\/|\/watch\?v=|\/embed\/)([a-z0-9\-_]+)/i', $url, $matches) ) 41 | continue; 42 | if (empty($matches[2][0])) 43 | continue; 44 | $ytid = $matches[2][0]; 45 | 46 | $div = $entry->parentNode; 47 | $div->removeChild($entry); 48 | 49 | // create iframe element 50 | $iframe = $doc->createElement('iframe'); 51 | $iframe->setAttribute('width', '640'); 52 | $iframe->setAttribute('height', '360'); 53 | $iframe->setAttribute('src', 'http://www.youtube.com/embed/'.$ytid.'?feature=player_detailpage'); 54 | 55 | // place iframe inside div 56 | $div->appendChild($iframe); 57 | $found = true; 58 | } 59 | 60 | /* $node = $doc->getElementsByTagName('body')->item(0); */ 61 | 62 | if ($found) { 63 | $article['content'] = $doc->saveHTML(); 64 | } 65 | } 66 | } 67 | return $article; 68 | } 69 | } 70 | ?> 71 | -------------------------------------------------------------------------------- /ff_sinnfrei/init.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Joschasa/Tiny-Tiny-RSS-Plugins/01b45d86b7877adcc0799df520503b69d5c48867/ff_sinnfrei/init.php --------------------------------------------------------------------------------