Menu

Codewars Leaderboard – Twitter, GitHub link extraction

May 2, 2017 - javascript, jQuery
/* 
Code parses leaderboard on https://www.codewars.com/users/leaderboard/kata
and extracts users profiles 

 */
var linkStorage = '';
localStorage.setItem("links", linkStorage);

$('.is-big a')
    .each(function () {
        console.log('works')
        var url = 'https://www.codewars.com' + $(this)['0'].attributes[0].nodeValue; /* Get the href attribute with URL to subpage */
                console.log(url);
               $.get(url)   /*  Load each subpage */
                   .done(function (data) {
                       var source = $(".mrx a", $(data)).attr("href"); /*  Get link to profile */
                       console.log(source);
                       var links = localStorage.getItem("links"); /* Get string with profile urls from the browser */
                       links = links.concat(source, ','); /* Add url to the string */
                       localStorage.setItem("links", links); /* Save the string in browser*/
                   });        
    });

    localStorage.getItem("links"); /* Display all links */