Auto Refresh on Blocked Google

Refreshes the page if Google is blocked.

// ==UserScript==
// @name         Auto Refresh on Blocked Google
// @description  Refreshes the page if Google is blocked.
// @match        *://www.google.com/*
// @version 0.0.1.20250312182138
// @namespace https://greasyfork.org/users/1435046
// ==/UserScript==

(function() {
    'use strict';

    function checkError() {
        if (document.querySelector("#main-frame-error .error-code")?.textContent.includes("ERR_BLOCKED_BY_RESPONSE")) {
            location.reload();
        }
    }

    // Run initially in case the error is already present
    checkError();

    // Observe changes to the document body
    const observer = new MutationObserver(checkError);
    observer.observe(document.body, { childList: true, subtree: true });
})();