-
-
Save usecdn/d64144a0af5e9679cc45ec300f47e374 to your computer and use it in GitHub Desktop.
Revisions
-
jbinto created this gist
Jan 13, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ // Only using native browser features (no jQuery). // Uses `fetch`, `DOMParser` and `querySelectorAll`. const getTitle = (url) => { return fetch(`https://crossorigin.me/${url}`) .then((response) => response.text()) .then((html) => { const doc = new DOMParser().parseFromString(html, "text/html"); const title = doc.querySelectorAll('title')[0]; return title.innerText; }); }; var urls = [ 'https://medium.com/@unakravets/the-sad-state-of-entitled-web-developers-e4f314764dd', 'http://frontendnewsletter.com/issues/1#start', 'https://groups.google.com/forum/#!topic/v8-users/PInzACvS5I4', 'https://www.youtube.com/watch?v=9kJVYpOqcVU', ] // This one keeps the order the same as the URL list. Promise.all( urls.map((url) => getTitle(url)) ).then((titles) => { console.log(titles); });