Created
June 16, 2018 04:40
-
-
Save GitHub30/b1c3cec6a12cc4b7dbdc3e0fe4a1cb46 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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