|
// ==UserScript== |
|
// @name GitHub Gists Profile Button |
|
// @namespace http://tampermonkey.net/ |
|
// @version 1.0 |
|
// @description Adds a "View Gists Profile" button to GitHub profile pages |
|
// @author Dominic Jonas |
|
// @match https://github.com/* |
|
// @grant none |
|
// @homepageURL https://gist.github.com/djonasdev/55f5cc1fc8462ec8b3fbd0af7c5bc50a#file-github-gists-profile-button-user-js |
|
// @updateURL https://gist.github.com/djonasdev/55f5cc1fc8462ec8b3fbd0af7c5bc50a/raw/eed82ad50b5dc6bdfdd7fd2ff8b39c203b49afd8/GitHub-Gists-Profile-Button.user.js |
|
// @downloadURL https://gist.github.com/djonasdev/55f5cc1fc8462ec8b3fbd0af7c5bc50a/raw/eed82ad50b5dc6bdfdd7fd2ff8b39c203b49afd8/GitHub-Gists-Profile-Button.user.js |
|
// @icon https://www.github.com/favicon.ico |
|
// ==/UserScript== |
|
|
|
(function() { |
|
'use strict'; |
|
|
|
function addGistsProfileButton(){ |
|
// Extract username from URL |
|
const username = window.location.pathname.split('/')[1]; |
|
if (!username) return; |
|
|
|
const gistUrl = `https://gist.github.com/${username}`; |
|
|
|
// Function to create button |
|
function createButton() { |
|
const button = document.createElement('button'); |
|
button.className = 'btn btn-block'; |
|
button.textContent = 'View Gists Profile'; |
|
button.style.marginTop = '5px'; |
|
// button.onclick = () => window.open(gistUrl, '_blank'); |
|
button.onclick = () => window.location.href = gistUrl; |
|
return button; |
|
} |
|
|
|
// Add button under "Edit Profile" section |
|
const profileEditButton = document.querySelector('.js-profile-editable-edit-button'); |
|
if (profileEditButton) { |
|
const container = profileEditButton.parentElement; |
|
if (container) container.appendChild(createButton()); |
|
} |
|
|
|
// Add button under "Follow" section |
|
const followContainer = document.querySelector('.user-following-container'); |
|
if (followContainer) { |
|
followContainer.appendChild(createButton()); |
|
} |
|
} |
|
|
|
// Run the function after a short delay to ensure elements are loaded |
|
setTimeout(addGistsProfileButton, 2000); |
|
})(); |