diff options
author | Andrew Dolgov <[email protected]> | 2020-12-18 08:12:31 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2020-12-18 08:12:31 +0300 |
commit | 50d089ae59bbe916bb5e8aab5aeec5b773cf1c77 (patch) | |
tree | fe1eaf4f0b8560c6c38f11d8b9c647ad342cb73d | |
parent | e48beee7fc2de2bec9202b1de5ef18c4e0d29d58 (diff) |
redditimgur: blacklist github because it usually resolves to a huge profile photo of someone
-rwxr-xr-x | plugins/af_redditimgur/init.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index 7a395801d..fd8364755 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -3,6 +3,7 @@ class Af_RedditImgur extends Plugin { /* @var PluginHost $host */ private $host; + private $domain_blacklist = [ "github.com" ]; function about() { 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); $node = $doc->getElementsByTagName('body')->item(0); @@ -567,4 +571,16 @@ class Af_RedditImgur extends Plugin { 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; + } } |