redditimgur: blacklist github because it usually resolves to a huge profile photo of someone

This commit is contained in:
Andrew Dolgov 2020-12-18 08:12:31 +03:00
parent e48beee7fc
commit 50d089ae59
1 changed files with 16 additions and 0 deletions

View File

@ -3,6 +3,7 @@ class Af_RedditImgur extends Plugin {
/* @var PluginHost $host */ /* @var PluginHost $host */
private $host; private $host;
private $domain_blacklist = [ "github.com" ];
function about() { function about() {
return array(1.0, return array(1.0,
@ -431,6 +432,9 @@ class Af_RedditImgur extends Plugin {
} }
} }
if ($content_link && $this->is_blacklisted($content_link->getAttribute("href")))
return $article;
$found = $this->inline_stuff($article, $doc, $xpath); $found = $this->inline_stuff($article, $doc, $xpath);
$node = $doc->getElementsByTagName('body')->item(0); $node = $doc->getElementsByTagName('body')->item(0);
@ -567,4 +571,16 @@ class Af_RedditImgur extends Plugin {
return $article; return $article;
} }
private function is_blacklisted($src) {
$src_domain = parse_url($src, PHP_URL_HOST);
foreach ($this->domain_blacklist as $domain) {
if (strstr($src_domain, $domain) !== false) {
return true;
}
}
return false;
}
} }