const log = document.getElementById('log');
log.innerHTML = "";

async function fetchData() {

    var serverAddress = "techhub.social";

    const response = await fetch(`https://${serverAddress}/api/v1/accounts/111518136987654656/statuses`);

    const data = await response.json();

    data.forEach(obj => {
        Object.entries(obj).forEach(([key, value]) => {

            if (key == "id") {
                log.innerHTML = log.innerHTML + `<iframe src="https://techhub.social/@Melawy/${value}/embed" class="mastodon-embed" style="max-width: 100%; border: 0" height="100%" width="60%" allowfullscreen="allowfullscreen"></iframe>` + '<br>';
            }

        });
        log.innerHTML = log.innerHTML + '<br>';
    });
}

function openInNewTab(url) {
    window.open(url, '_blank').focus();
}

document.addEventListener("DOMContentLoaded", fetchData);