Back to TILs

linkedin — in progress courses

Date: 2023-01-27Last modified: 2023-03-07

Table of contents

Introduction

The goal of this post is to list in progress courses on linkedin learning ordered by the remain time to finish.

First you need to access the page https://www.linkedin.com/learning/me/my-library/in-progress and scroll down until its end.

Then execute the snippet below in the Source tab of Google Chrome browser:

courses = [];
[...document.getElementsByClassName('in-progress-body__card')].forEach(e=>{
    title = '';
    author = '';
    url = '';
    released = '';
    remainTime = 0;

    h3 = e.getElementsByClassName('lls-card-detail-card-body__headline')[0];
    if (h3) {
        title = h3.innerText;
        url = h3.getElementsByTagName('a')[0].href;
    }

    ul = e.getElementsByClassName('lls-card-detail-card-body__primary-metadata')[0];
    if (ul) {
        a = ul.getElementsByTagName('a')[0];
        if (a) {
            author = a.innerText;
        }
        released = ul.getElementsByClassName('lls-card-released-on')[0].innerText;
        released = released.replace(/\D/g, "");
    }

    spanremainTime = e.getElementsByClassName('lls-card-duration')[0];
    if (spanremainTime) {
        remainTimeTxt = spanremainTime.innerText;
        console.log(remainTimeTxt);
        const remainTimeRE3 = /(?<hour>\d+)h (?<min>\d+)m (?<sec>\d+)s left/;
        const remainTimeRE2 = /(?<min>\d+)m (?<sec>\d+)s left/;

        result = remainTimeTxt.match(remainTimeRE2);
        if (result) {
            remainTime = parseInt(result[1]);
        }

        result = remainTimeTxt.match(remainTimeRE3);
        if (result) {
            remainTime = parseInt(result[1]) * 60;
            remainTime += parseInt(result[2]);
        }
    }

    elem = {
        released: released,
        author: author,
        title: title,
        link: url,
        remainTime: remainTime
    }
    courses.push(elem);
}
);

// sort by date desc
courses.sort((e1,e2)=>(e1.released < e2.released) ? 1 : (e1.released > e2.released) ? -1 : 0);

// sort by remainTime asc
courses.sort((e1,e2)=>(e1.remainTime > e2.remainTime) ? 1 : (e1.remainTime < e2.remainTime) ? -1 : 0);

md = ''
courses.forEach(e=>md += `* ${e.remainTime} min | ${e.released} | [${e.title}](${e.link})\n`);
console.log(md);
copy(md);

After running the code above a list of courses will be on the clipboard.

In progress courses