Apologies for asking this question again as per here and here there are answers.
BUT
This appears to be specific to a page. I am building a simple "button" for the browser bookmark bar that will grab the Name and URL or the page I am on to paste into a spreadsheet easily.
On other sites, I use Javascript to find the text and then I can easily paste anywhere.
example from another site (business.currys.co.uk)
javascript:void(
eval('function copyToClipboard(element) {
var $temp = $("<input>");
$("body").append($temp);
$temp.val(element).select();
document.execCommand("copy");
$temp.remove();}
var copyableVal = $("#product-container > h1").text().trim() + " " + $(".page-title span:last-child").text() + " " + $("#product-container > div.product-info > form > dl > dd:nth-child(2)").text().trim();
copyToClipboard(copyableVal);'))
I want to do that with LinkedIn. To repeat – open any linkedin Profile page.
The Name is in this element
<h1 class="text-heading-xlarge inline t-24 v-align-middle break-words">Jannes Sörensen</h1>
<!-- Full Xpath -->
/html/body/div[6]/div[3]/div/div/div[2]/div/div/main/section[1]/div[2]/div[2]/div[1]/div[1]/span[1]/a/h1
I am testing the uniqueness of the classes with
$( document ).ready(function() {
var classCount= $('.t-24').length;
console.log(classCount);
});
$( document ).ready(function() {
var classCount = $(':header').length;
console.log(classCount);
});
However I keep getting 0 in the console 🙁
I wonder if Jquery is blocked somehow?
2
Answers
Thanks for the direction mPlungjan. I have taken your answer as inspiration and created some "plain javascript" to make it work.
With some help from perplexity.ai too.
I have created this "grab" - save it as a bookmark and by clicking it, you will get a clipboard entry that is: Person Name, Position, URL Then you can save people you are connecting with easily for later reference or importing to other CRMs.
You need to click it to get it.
Here is a plain js version which does not rely on jQuery
You need to check the selectors. I for example do not find a product-container on a linkedin profile page