import re


def replace_html_links(content: str, new_extension: str) -> str:
    def replace_match(match):
        original_url = match.group(1)

        if ".html" not in original_url:
            return original_url

        if original_url.startswith(('http://', 'https://', '//', '/')):
            if original_url.endswith(".html"):
                temp_url_without_html = original_url.replace(".html", "")
                if new_extension == "":
                    return temp_url_without_html if not temp_url_without_html.endswith("/index") else "/"
                else:
                    return temp_url_without_html + new_extension
            return original_url

        if original_url.endswith(".html"):
            temp_url_without_html = original_url.replace(".html", "")
            if new_extension == "":
                if temp_url_without_html == "index" or temp_url_without_html.endswith("/index"):
                    return "/" if temp_url_without_html == "index" else temp_url_without_html[:-5]
                return temp_url_without_html
            else:
                return temp_url_without_html + new_extension

        return original_url

    content = re.sub(r"""(?<=href=['"])([^'"]+)(?=['"])""", replace_match, content)
    content = re.sub(r"""(?<=action=['"])([^'"]+)(?=['"])""", replace_match, content)
    content = re.sub(r'href=["\']/(#|javascript:)', r'href="\1', content)

    return content