document.addEventListener("DOMContentLoaded", () => {
    const svgList = document.querySelectorAll('.img-svg');
    console.log(svgList);
    svgList.forEach(function (elem) {
        if (elem.tagName === 'IMG') {
            let url = elem.getAttribute('src');
            fetch(url).then((response) => response.text())
                .then(str => new window.DOMParser().parseFromString(str, "text/xml"))
                .then((data) => {
                    let svg = data.querySelector('svg');
                    if(svg){
                        let imgW = elem.getAttribute('width');
                        let imgH = elem.getAttribute('height');

                        let path = svg.querySelectorAll('path')
                        path.forEach(function (p){
                            if(p.getAttribute('stroke') === 'none')
                                p.style.stroke = 'none';
                        })


                        svg.classList.add('img-svg');
                        svg.setAttribute('width', imgW);
                        svg.setAttribute('height', imgH);
                        svg.setAttribute('viewbox', `0 0 ${imgW} ${imgH}`);

                        elem.replaceWith(svg);
                    }

                });
        }
    });
})
