Craigslist: Bigger Pics in Thumb View

Loads higher resolution thumbnail images when browsing in "thumb" view

// ==UserScript==
// @name         Craigslist: Bigger Pics in Thumb View
// @description  Loads higher resolution thumbnail images when browsing in "thumb" view
// @version      0.9
// @author       mica
// @namespace    greasyfork.org/users/12559
// @match        https://*.craigslist.org/d/*
// @match        https://*.craigslist.org/search/*
// @license      MIT
// ==/UserScript==

let url;
const style = document.createElement("style");
style.setAttribute('id', 'thumbStyle');
style.textContent = `
li.cl-search-result {
    border-top: 1px solid #ddd;
    border-left: 1px solid #ddd;
}
li.cl-search-result:nth-child(odd) {
    background-color: #eee;
}
div.result-node {
    min-height: 150px;
    padding-bottom: 5px;
    margin: 0 !important;
}
a.result-thumb {
    min-width: 350px;
    margin: 0;
}
img.cl-thumb {
    height: auto;
    width: auto;
}
div.result-info {
    font-size: large;
    padding-top: 50px;
}
`;
function resizeThumbs() {
    document.querySelectorAll('img.cl-thumb').forEach((element) => {
        element.setAttribute('src', element.attributes.src.value.replace('50x50c', '300x300'));
    });
}
function checkView() {
    if (document.querySelector('main.cl-search-view-mode-thumb')) {
        if (!document.getElementById('thumbStyle')) {
            document.head.appendChild(style);
        }
        resizeThumbs();
    } else {
        document.getElementById('thumbStyle').remove();
    }
}
function checkReady() {
    if (document.querySelector('body.bd-can-hover')) {
        checkView();
    } else {
        setTimeout(checkReady, 300);
    }
}
setInterval(() => {
    if (url != location.href) {
        url = location.href;
        checkReady();
    }
}, 300);