Skip to content

Instantly share code, notes, and snippets.

@GitHub30
Created June 16, 2018 04:40
Show Gist options
  • Save GitHub30/b1c3cec6a12cc4b7dbdc3e0fe4a1cb46 to your computer and use it in GitHub Desktop.
Save GitHub30/b1c3cec6a12cc4b7dbdc3e0fe4a1cb46 to your computer and use it in GitHub Desktop.
async function avatarUrl(url) {
const html = await fetch('https://allow-any-origin.appspot.com/' + url).then(res => res.text());
const doc = new DOMParser().parseFromString(html, "text/html");
if (url.includes('youtube')) {
return doc.querySelector('img[src$="photo.jpg"]').src;
} else if (url.includes('twitter')) {
return doc.querySelector('.ProfileAvatar-image').src;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment