Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FelipeCorso/c1292db08a55986fb7c2cf191eb71f9a to your computer and use it in GitHub Desktop.
Save FelipeCorso/c1292db08a55986fb7c2cf191eb71f9a to your computer and use it in GitHub Desktop.
Export your linkedin public profile to PDF if you're having trouble with internationalization.
// Reason to create this script:
// My profile was created in Portuguese, but when I translated
// it to English and tried to save my profile as PDF, it could not
// translate some words and dates to English, so I created this gist
// as an alternative.
// Usage
// 1. Open your public profile in an incognito* browser tab. E.g.: https://www.linkedin.com/in/felipe-corso
// 2. Copy-n-past the code below into the browser console
// 3. Save as PDF
// 4. Add me on LinkedIn :) (optional)
// 5. Contribute to make this Gist better (optional)
// * This is necessary to avoid loading private sessions
// of your profile and other unnecessary stuff
// Print Info
// To remove the date, page title, URL and page number
// uncheck the option "Headers and footers" on print pop-up
// More details: https://www.geeksforgeeks.org/how-to-remove-url-from-printing-the-page/
/**
* Page Clean up
*/
// Removes the Sign-in / Sign-up modal
$(
"button[data-tracking-control-name='public_profile_contextual-sign-in-modal_modal_dismiss']"
)?.click();
// Removes the Cookies consent
$("#artdeco-global-alert-container")?.remove();
$("#artdeco-global-alerts-cls-offset")?.remove();
// Removes the top bar
$("header.header")?.remove();
// Removes the right section
$("section.right-rail")?.remove();
// Removes the footer
$("footer.li-footer")?.remove();
/**
* Profile Clean up
*/
// Removes the ellipsis menu
$("div.ellipsis-menu")?.remove();
// The CTA section, the ones which contains the button
$("div.top-card-layout__cta-container")?.remove();
// Removes open to opportunities section
$("section.open-to-opportunities")?.remove();
// Remove the followers and connections, keep just the location
const children = [...($("h3.top-card-layout__first-subline")?.children ?? [])];
for (let child of children) {
if (child.tagName === "SPAN") {
$("h3.top-card-layout__first-subline > span")?.remove();
}
}
// Removes activities section
let activity = $("section.profile > section.core-section-container.activities");
do {
activity?.remove();
activity = $("section.profile > section.core-section-container.activities");
} while (activity);
// Removes publications section
$("section.core-section-container.publications")?.remove();
// Removes recommendations section
$("section.core-section-container.recommendations")?.remove();
// Removes bottom CTA section
$("section.core-section-container.bottom-cta-banner")?.remove();
// Removes the More activity section
$("section.core-section-container.recommended-content")?.remove();
// Clicks and removes the Show More buttons
const showMoreButtons = [
...document.getElementsByClassName("show-more-less-text__button--more"),
];
for (let showMoreButton of showMoreButtons) {
showMoreButton.click();
$("button.show-more-less-text__button--more")?.remove();
}
// Removes the Show Less buttons
const showLessButtons = [
...document.getElementsByClassName("show-more-less-text__button--less"),
];
showLessButtons.forEach(() => {
$("button.show-more-less-text__button--less")?.remove();
});
// Triggres the print command, so you can save as PDF
// Scroll up and check the Print Info section
window.print();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment