Skip to content

Commit 8803fa9

Browse files
authored
Merge pull request #1119 from gayatripadalia/feat/copy-clipboard-clean
feat: add copy-to-clipboard for repository, profile and contribution links
2 parents b45a357 + 80fc205 commit 8803fa9

1 file changed

Lines changed: 14 additions & 27 deletions

File tree

‎script.js‎

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -616,10 +616,7 @@ function initGithubDashboard() {
616616
if (customRange) customRange.style.display = 'none';
617617
updateFilterBadge(null, null);
618618
}
619-
var avatarEl = document.getElementById('gh-avatar');
620-
if (avatarEl) {
621-
avatarEl.removeAttribute('src');
622-
}
619+
623620
setGithubStatus('Dashboard cleared.');
624621
});
625622
}
@@ -822,9 +819,13 @@ function showContributionsChart(username, events) {
822819
var btn = document.createElement("button");
823820
btn.innerHTML = "📋";
824821
btn.className = "copy-btn";
825-
822+
// GitHub doesn't provide a dedicated public contributions page.
823+
// A user's contribution history is displayed on their GitHub profile,
824+
// including contributions across their own repositories and repositories
825+
// where they've contributed via issues or pull requests.
826+
// Therefore, we copy the profile URL instead.
826827
btn.onclick = function () {
827-
copyLink("https://github.com/users/" + username + "/contributions");
828+
copyLink("https://github.com/users/" + username);
828829
};
829830

830831
container.appendChild(btn);
@@ -1250,28 +1251,14 @@ function injectCompareUI() {
12501251
});
12511252

12521253
// ── Wire compare button ──
1253-
document.getElementById('gh-compare-btn').addEventListener('click', function () {
1254-
var u1 = (document.getElementById('gh-username').value || '').trim();
1255-
var u2 = (document.getElementById('gh-compare-username').value || '').trim();
1256-
1257-
if (!u1) {
1258-
alert('Please load a primary profile first.');
1259-
return;
1260-
}
1261-
1262-
if (!u2) {
1263-
alert('Please enter a username to compare with.');
1264-
return;
1265-
}
1266-
1267-
// Prevent comparing the same GitHub profile
1268-
if (u1.toLowerCase() === u2.toLowerCase()) {
1269-
alert('Please enter a different GitHub username to compare.');
1270-
return;
1271-
}
1254+
document.getElementById('gh-compare-btn').addEventListener('click', function() {
1255+
var u1 = (document.getElementById('gh-username').value || '').trim();
1256+
var u2 = (document.getElementById('gh-compare-username').value || '').trim();
1257+
if (!u1) { alert('Please load a primary profile first.'); return; }
1258+
if (!u2) { alert('Please enter a username to compare with.'); return; }
1259+
runComparison(u1, u2);
1260+
});
12721261

1273-
runComparison(u1, u2);
1274-
});
12751262
// Also allow Enter key in the compare input
12761263
document.getElementById('gh-compare-username').addEventListener('keydown', function(e) {
12771264
if (e.key === 'Enter') document.getElementById('gh-compare-btn').click();

0 commit comments

Comments
 (0)