const getImages = (el, includeDuplicates = false) => {
const images = [...el.getElementsByTagName('img')].map(img => img.getAttribute('src'));
return includeDuplicates ? images : [...new Set(images)];
};
// includeDuplicates 为 false 表示需要排除重复元素
getImages(document, true);
getImages(document, false);