How I fixed WordPress category page title: Category <span>…</span>

One one of my WordPress sites, the title of category pages was literally

Category <span>My category</span>

Searching through the theme source code didn’t yield a solution quickly, so I added this custom JS using a plugin:

jQuery(document).ready(function( $ ){
    if(jQuery("").text().includes("Category: <span>")) {
        var input = jQuery("").text();
        var output = /<span>(.*)<\/span>/g.exec(input)[1];

This will just replace the title by the content of the span tag. You might need to adjust the CSS classes for your theme.