Daily Comicstrips

FREE
By pnpninja | Updated a month ago | Entertainment
Popularity

0.2 / 10

Latency

210ms

Service Level

100%

Health Check

N/A

Back to All Discussions

substitute with pure javascript

Rapid account: Powlwoq
powlwoq
2 years ago
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Daily Comicstrip</title>
    <script type="application/javascript">
        function loadComicImage(comicType) {
            const baseUrl = "https://www.arcamax.com/thefunnies/";
            const xhr = new XMLHttpRequest();
            var remoteUrl;
            xhr.open("GET", baseUrl + comicType);
            xhr.send(null);
            xhr.onreadystatechange = function(){
                if(xhr.readyState === 4){
                    const remotedoc = new DOMParser().parseFromString(xhr.responseText.replace(/<script(.|\s)*?\/script>/g, ''), 'text/html');
                    remoteUrl = remotedoc.getElementById("comic-zoom").getAttribute("data-zoom-image");
                    console.log("remoteUrl: " + remoteUrl)
                    var image = document.getElementById("comic");
                    image.src = remoteUrl;
                }
            };
        }
        
    </script>
</head>
<body>
<p align="center">
    <button onclick="loadComicImage('dilbert')">ENGAGE</button>
    <br>

    <img id="comic" src="XXX" title="comicstrip of the day"/>
</p>
</body>
</html>

Join in the discussion - add comment below:

Login / Signup to post new comments