I extended the default Dilbert comic plugin to also include tags, the comic title (except for Sunday strips) and a transcript as mouseover. Works well for me so far.
I also created some other comic plugins (Foxtrot, Nerf Now, Ctrl+Alt+Del). If anyone is interested, I can do some cleaning up and put them in a repository.
af_comics_dilbert.php
<?php
class Af_Comics_Dilbert extends Af_ComicFilter {
function supported() {
return array("Dilbert");
}
function process(&$article) {
if (strpos($article["guid"], "dilbert.com") !== FALSE ||
strpos($article["link"], "/DilbertDailyStrip") !== FALSE) {
$res = fetch_file_contents($article["link"], false, false, false,
false, false, 0,
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0");
global $fetch_last_error_content;
if (!$res && $fetch_last_error_content)
$res = $fetch_last_error_content;
$doc = new DOMDocument();
@$doc->loadHTML($res);
$basenode = false;
if ($doc) {
$xpath = new DOMXPath($doc);
// Get the image container
$basenode = $xpath->query('(//div[@class="img-comic-container"]/a[@class="img-comic-link"])')->item(0);
// Get the comic title
$comic_title = $xpath->query('(//span[@class="comic-title-name"])')->item(0)->textContent;
// Get tags from the article
$matches = $xpath->query('(//p[contains(@class, "comic-tags")][1]//a)');
$tags = array();
foreach ($matches as $tag) {
// Only strings starting with a number sign are considered tags
if ( substr($tag->textContent, 0, 1) == '#' ) {
$tags[] = mb_strtolower(substr($tag->textContent, 1), 'utf-8');
}
}
// Get the current comics transcript and set it
// as the title so it will be visible on mousover
$transcript = $xpath->query('(//div[starts-with(@id, "js-toggle-transcript-")]//p)')->item(0);
if ($transcript) {
$basenode->setAttribute("title", $transcript->textContent);
}
if ($basenode) {
$article["content"] = $doc->saveXML($basenode);
}
// Add comic title to article type if not empty (mostly Sunday strips)
if ($comic_title) {
$article["title"] = $article["title"] . " - " . $comic_title;
}
if (!empty($tags)) {
// Ignore existing tags and just replace them all
$article["tags"] = array_unique($tags);
}
}
return true;
}
return false;
}
}
?>
fox
2
probably a good idea to rename the class btw
To avoid conflicts with the existing plugin? Wouldn’t it be run twice then?
At first I tried to create a folder in plugins.local/af_comics/filters to have my own plugins separated and keep them from being overwritten on updates but then noticed, that they aren’t loaded at all.
fox
4
yeah, af_comics doesn’t have any code for custom filters in plugins.local. i’m not sure if its a good idea to just overwrite the existing file either, because of git pull issues.
At least for me that’s not an issue. I’ve been running TT-RSS for years on various servers and usually do pulls on a copy merging the changes manually. Probably not the best way to keep it up to date but it works for me. 
Feel free to include the modified plugin in the official code repository though.
fox
6
sure, file a merge request.
Sivan
7
How do you get the plugin to work?
There should already be a plugin in plugins/af_comics/filters/af_comics_dilbert.php which you can overwrite but as fox integrated my changes in the official repository just update your installation.
fox
9
i just subbed on the default feed on dilbert.com and your plugin didn’t work btw :argh:
e: possibly because it was an atom feed
I am using this one: Dilbert Daily Strip
If you’re looking at updating the CAD comic plugin as well, I’ve been using my own updated version for a few weeks now with no issues. Just haven’t got around to figuring out how to do a merge request.
Feel free to use it if you want, if not eventually I’ll get to it.
<?php
class Af_Comics_Cad extends Af_ComicFilter {
function supported() {
return array("Ctrl+Alt+Del");
}
function process(&$article) {
if (strpos($article["link"], "cad-comic.com/comic/") !== FALSE) {
$doc = new DOMDocument();
if (@$doc->loadHTML(fetch_file_contents($article["link"]))) {
$xpath = new DOMXPath($doc);
$basenode = $xpath->query('(//div[@class="comicpage"]/a/img)')->item(0);
if ($basenode) {
$article["content"] = $doc->saveXML($basenode);
}
}
return true;
}
return false;
}
}
fox
12
since there’s multiple filters around i’ll add support for filters.local in af-comics and let people place whatever they want in there
for cad i guess i’ll update with the short plugin above, thanks dude
e: cad also seems to be using cloudflare so i can’t really test anything reliably with my third world ip
no problem, though bummer about the cloudflare, never noticed it 
At least the user-agent gets around it easily though 