Skip to content

Commit

Permalink
copy username/groupname/person now copies name, not url
Browse files Browse the repository at this point in the history
  • Loading branch information
on committed Sep 5, 2025
1 parent 4e15846 commit a4d933b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions bas-search.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
// Check if it's a group or account page
if (titleText.startsWith('Group ') || titleText.startsWith('Account ') || titleText.startsWith('Person ')) {
const objectType = titleText.split(' ')[0].toLowerCase();
const objectName = titleText.split(' ')[1];

if (objectType === 'group') {
var baseUrl = 'https://bas.ntnu.no/group/view?id=';
Expand All @@ -92,13 +93,13 @@

const objectId = document.getElementById('entity_id').value;
const objectUrl = baseUrl + objectId;
console.log(`Copying ${objectType} link to clipboard: ${objectUrl}`);
//console.log(`Copying ${objectType} link to clipboard: ${objectUrl}`);

const htmlLink = `<a href="${objectUrl}" target="_blank">${titleText}</a>`;
const htmlLink = `<a href="${objectUrl}" target="_blank">${objectName}</a>`;

copyToClipboard(null, objectUrl);
copyToClipboard(null, objectName);

showMessage(titleText);
showMessage(objectName);
});
}
}
Expand Down Expand Up @@ -157,7 +158,7 @@
normalSpan.style.color = '#ddd';
normalSpan.style.fontFamily = 'sans-serif';
normalSpan.style.fontSize = 'inherit';
normalSpan.textContent = ' link copied to clipboard!';
normalSpan.textContent = ' copied to clipboard!';

messageBox.appendChild(boldSpan);
messageBox.appendChild(normalSpan);
Expand Down

0 comments on commit a4d933b

Please sign in to comment.