Last active
November 23, 2023 16:23
-
-
Save LenweSaralonde/7bf224fc069e8ce282eff9e31c20214e to your computer and use it in GitHub Desktop.
Export your LinkedIn profile as a resumé in print friendly PDF, with projects, experience etc.
This file contains 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
/** | |
* How to use | |
* | |
* 1. Log into LinkedIn | |
* 2. Head to https://www.linkedin.com/public-profile/settings | |
* 3. Fill your e-mail and phone number in the variables below | |
* 4. Open dev tools with F12 | |
* 5. Copy-paste the whole code in the console and press Enter | |
* 6. Scroll down to the bottom of the page to make sure all images load properly | |
* 7. Print the page to PDF | |
* 8. Done :) | |
*/ | |
{ | |
const EMAIL_ADDRESS = 'leeroy.jenkins@gmail.com'; | |
const PHONE_NUMBER = '+33 666 666 666'; | |
////////////////////// Functions | |
function hideStuff(query) { | |
document.querySelectorAll(query).forEach(e => e.style.setProperty('display', 'none', 'important')); | |
} | |
////////////////////// Create resume | |
// Remove LinkedIn redirect URLs | |
document.querySelectorAll('a').forEach((a) => { | |
const urlMatches = a.href.match(/https:\/\/www.linkedin.com\/redir\/redirect\?url=(.+)\&urlhash=/); | |
if (urlMatches && urlMatches[1]) { | |
a.href = decodeURIComponent(urlMatches[1]); | |
} | |
}); | |
// Expand all blocks | |
document.querySelectorAll('.show-more-less-text__button--more').forEach(e => e.closest('.show-more-less-text').classList.add('show-more-less-text--more')); | |
hideStuff('.show-more-less-text__button'); | |
// Replace project URLs | |
document.querySelectorAll('a.personal-project__button').forEach((button) => { | |
button.firstChild.data = button.href; | |
}); | |
// Replace "websites" link by LinkedIn profile URL | |
const vanityDomainNameElement = document.querySelector('.vanity-name__display .vanity-name__domain'); | |
const vanityNameElement = document.querySelector('.vanity-name__display [data-js-module-id=vanity-name__display-name]'); | |
const websiteLinkDescription = document.querySelector('.websites .top-card-link__description'); | |
const websitesElement = document.querySelector('.websites'); | |
if (websitesElement && vanityDomainNameElement && vanityNameElement && websiteLinkDescription) { | |
const profileUrl = vanityDomainNameElement.innerText.replace(/www\./, '') + vanityNameElement.innerText; | |
websiteLinkDescription.innerText = profileUrl; | |
const linkElement = document.createElement('a'); | |
linkElement.classList.add('top-card-link'); | |
linkElement.classList.add('top-card-link--link'); | |
linkElement.href = `https://${profileUrl}`; | |
websitesElement.parentNode.appendChild(linkElement); | |
linkElement.appendChild(websitesElement); | |
} | |
// Add phone number | |
document.querySelectorAll('span.top-card__subline-item:nth-of-type(1)').forEach(e => e.innerHTML = `<a href="tel://${PHONE_NUMBER.replace(/\s/g, '')}">${PHONE_NUMBER}</a>`); | |
// Add email address | |
document.querySelectorAll('span.top-card__subline-item:nth-of-type(2)').forEach(e => e.innerHTML = `<a href="mailto:${EMAIL_ADDRESS}">${EMAIL_ADDRESS}</a>`); | |
// Hide header and footer | |
hideStuff('header'); | |
hideStuff('footer'); | |
document.querySelector('body').style.setProperty('padding-top', '0px', 'important'); | |
// Hide right rail | |
hideStuff('.right-rail'); | |
// Hide setting header | |
hideStuff('.settings-header'); | |
// Hide "Activity" | |
hideStuff('.activities'); | |
// Hide recommended content | |
hideStuff('.recommended-content'); | |
// Hide "other creators" | |
hideStuff('ul.list-none.mt-1'); | |
hideStuff('div.mt-2'); | |
// Hide "See your mutual connections" | |
hideStuff('h4.top-card-layout__second-subline'); | |
// Hide top card CTA button | |
hideStuff('.top-card-layout__cta-container'); | |
// Hide recommendations | |
hideStuff('.recommendations'); | |
////////////////////// Style adjustments for printing | |
// Force blue links | |
document.querySelectorAll('.top-card-layout a').forEach(e => e.style.setProperty('color', '#0a66c2', 'important')); | |
// Keep the top card contents on 2 columns | |
document.querySelectorAll('.top-card-layout .babybear\\:flex-none').forEach(e => e.style.setProperty('flex', '0px 1 0', 'important')); | |
// Justify summary text | |
document.querySelectorAll('.summary p').forEach(e => e.style.setProperty('text-align', 'justify', 'important')); | |
// Avoid page breaks within sections | |
document.querySelectorAll('section.experience, .profile-section-card__contents').forEach(e => e.style.setProperty('break-inside', 'avoid', 'important')); | |
// Update page title | |
{ | |
const title = document.querySelector('.top-card-layout__title'); | |
const headline = document.querySelector('.top-card-layout__headline'); | |
document.querySelector('title').innerText = `${title.innerText}${headline ? (' – ' + headline.innerText) : ''}`; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment