Are you trying to copy a Linkedin post and all its comments?
If so, this article will show you how to do that. Linkedin makes it intentionally difficult to save old posts and to search through them. With this method, you can save insightful posts to your personal computer – and search through their text for years to come.
Step 1: set up a “Bookmarklet”
First, create a browser “Bookmarklet” that you can reuse to expand long posts. For any Linkedin post, it will load all comments, expand all threads and click “…see more” on individual comments.
Start off by creating a bookmark of the current page. Name it something like “Linkedin Post Saver”:
Next, copy the following line of code. This is what makes the Bookmarklet reveal all comments:
javascript:void%20function(){function%20myclicker(buttonCounter){if(5==buttonCounter)return%20jacobdiv.innerHTML=%22%3Cstyle%3E%40media%20print{%20.no-print{display:none;}}%3C/style%3E%3Cdiv%20class=\%22no-print\%22%20style=\%22position:%20fixed;%20left:%2030vw;%20top:0;z-index:100;background:%20%23a6f8a6;padding:%201ex;box-shadow:%20-1px%200px%2024px%200px%20rgba(0,0,0,0.75);\%22%3E%3Cb%3EThe%20page%20is%20ready%20for%20saving.%3C/b%3E%3C/div%3E%22,0;var%20liArray=document.querySelectorAll(%22button.comments-comments-list__load-more-comments-button,%20button.feed-shared-inline-show-more-text__see-more-less-toggle,%20button.show-prev-replies%22);if(0==liArray.length||lengthOfBodyOld==lengthOfBodyNew)buttonCounter++;else%20for(buttonCounter=0,i=0;i%3CliArray.length;i++){const%20cevent=new%20MouseEvent(%22click%22,{view:window,bubbles:!0,cancelable:!0});liArray[i].dispatchEvent(cevent)}setTimeout(function(){myclicker(buttonCounter)},2e3),lengthOfBodyOld=lengthOfBodyNew,lengthOfBodyNew=document.querySelector(%22div.comments-comments-list%20%3E%20:first-child%22).innerHTML.length}var%20jacobdiv=document.createElement(%22div%22);jacobdiv.innerHTML=%22%3Cdiv%20style=\%22position:%20fixed;%20left:%2030vw;%20top:0;z-index:100;\%22%3E%3Cimg%20src=\%22https://jacobfilipp.com/i/linkedinPostSaverV02.gif\%22%3E%3C/div%3E%22,document.body.appendChild(jacobdiv);var%20buttonCounter=0,lengthOfBodyOld=document.querySelector(%22div.comments-comments-list%20%3E%20:first-child%22).innerHTML.length,lengthOfBodyNew=0;myclicker(0)}();
Next, find this bookmark in your bookmarks list. Right click it and choose Edit:
Finally, paste the code that you copied into the URL portion of the bookmark you are editing.
[Note: never input code that you don’t understand into your browser. If you are on a work computer, ask a member of your IT team to review this page & the code. Lower down there’s an easy-to-read version of the code that you can turn into bookmarklet code yourself.]
Step 2: open the Linkedin post you want to save
Find the post that you want to save to your computer. Open it so it is on it’s own standalone page. One way to do this is to click the “…” icon near the post an “Copy link to post” and then paste it into your browser URL bar. You will then see all the comments – without any other posts on the page.
I also recommend that you click on the “sort” link under the post (1) and change it to “Most recent” (2). This will give you an impartial time-based listing of comments, instead of having Linkedin highlight the ones their algorithm wants to boost.
Step 3: click the Bookmarklet you created
Click on the bookmarklet (special bookmark) you created in Step 1. This will run Javascript code that will simulate clicks on every “…see more” and “Load previous replies” link on the page.
Wait until you see the “This page is ready for saving” message … it might take 20 seconds to load all the content from every comment.
Step 4: save the entire page to your coputer
When the bookmarklet finishes loading the comments, you can save the page as-is to your own computer. You have 2 options here.
Option 1: Save as PDF
Open your browser’s “Print” menu and choose “Save as PDF”. Take a look at the settings before you finish saving – I recommend that you check the “Background graphics” setting. This setting will ensure that all images appear in the PDF.
Option 2: Save as “Complete Web Page”
Your other option is to save the raw HTML code of the page with the post, together with all supporting graphics.
Do this by clicking CTRL+S (or going to the File->Save) menu. Be sure to choose the “Webpage, Complete” option.
You will end up with an .html page of your post and a folder with the same name. The folder will contain all images that are present on the page – for offline viewing.
Refresh your Linkedin window to get rid of the “ready for saving” message at the top.
Happy saving!
With your “Linkedin Post Saver” bookmarklet, you can now save any Linkedin post you want. Just follow steps #2 -> #4.
Appendix: the full code for the bookmarklet
Here is the easy-to-read code for this bookmarklet. You can turn this code into a bookmarklet yourself by pasting it into the tool at https://chriszarate.github.io/bookmarkleter/ (check only the first 2 checkboxes).
/* changes in v02: monitor length changes on comment section (instead of whole HTML body); hide "ready" message from printing; */
// Set up an image that shows if we're using the latest version of the tool. To keep up with Linkedin interface changes
var jacobdiv = document.createElement('div');
jacobdiv.innerHTML = '<div style="position: fixed; left: 30vw; top:0;z-index:100;"><img src="https://jacobfilipp.com/i/linkedinPostSaverV02.gif"></div>';
document.body.appendChild( jacobdiv );
// these are counters that tell us when to stop clicking on webpage items (because the area with comments isn't changing/no more elements to click)
var buttonCounter = 0;
var lengthOfBodyOld = document.querySelector("div.comments-comments-list > :first-child").innerHTML.length;
var lengthOfBodyNew = 0;
// recursive function that simulates clicks
function myclicker( buttonCounter )
{
//console.log( "buttonCounter: "+buttonCounter+"\n"+"lengthOfBodyOld: "+lengthOfBodyOld+"\n"+"lengthOfBodyNew: "+lengthOfBodyNew );
// if we go through 5 executions without changes, display the "done" message and exit
if( buttonCounter == 5 )
{
jacobdiv.innerHTML = '<style>@media print{ .no-print{display:none;}}</style><div class="no-print" style="position: fixed; left: 30vw; top:0;z-index:100;background: #a6f8a6;padding: 1ex;box-shadow: -1px 0px 24px 0px rgba(0,0,0,0.75);"><b>The page is ready for saving.</b></div>';
return 0;
}
// put all "load more comments" links into an array
var liArray = document.querySelectorAll( "button.comments-comments-list__load-more-comments-button, button.feed-shared-inline-show-more-text__see-more-less-toggle, button.show-prev-replies"); // select every type of button we're looking for
// no more links? page not changing? then increment our counter
if( liArray.length == 0 || lengthOfBodyOld == lengthOfBodyNew)
{
buttonCounter++;
}
else
{
buttonCounter = 0;
// go through every link we found
for( i=0; i < liArray.length; i++ )
{
// simulate a click on each element
const cevent = new MouseEvent("click", {view: window,bubbles: true,cancelable: true,});
liArray[i].dispatchEvent(cevent);
}
}
// wait for 2 seconds so Linkedin loads the content, and repeat the entire cycle to find new comment links
setTimeout(function(){myclicker(buttonCounter)}, 2000);
lengthOfBodyOld = lengthOfBodyNew;
lengthOfBodyNew = document.querySelector("div.comments-comments-list > :first-child").innerHTML.length;
}
// start execution
myclicker( 0 );
Leave a Reply