Я предполагаю, что тип будет video/mp4
для всех mp3-ссылок.Если тип <source/>
отличается, возможно, вам придется изменить значение querySelectorAll(...)
.
Надеюсь, это поможет:
// Get all the links from `source` tags that have the type `video/mp4`
let links = Array.from(
document.querySelectorAll('source[type="video/mp4"]')
).map(source => source.src);
console.log(links);
<source src="http://url/file.mp3" type="video/mp4">
<!-- Will extract from deep source tags aswell-->
<div>
<source src="http://url/file1.mp3" type="video/mp4">
<div>
<source src="http://url/file2.mp3" type="video/mp4">
</div>
</div>