Adds an 'Open in Gitingest' button with specific icon and tooltip
// ==UserScript==
// @name GitHub to Gitingest
// @namespace http://tampermonkey.net/
// @version 1.2
// @description Adds an 'Open in Gitingest' button with specific icon and tooltip
// @author GGD40727
// @match https://github.com/*/*
// @icon https://private-user-images.githubusercontent.com/45784494/398700624-e6a0c74d-0548-4c76-8536-c613ded73430.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Nzc5MTczNDgsIm5iZiI6MTc3NzkxNzA0OCwicGF0aCI6Ii80NTc4NDQ5NC8zOTg3MDA2MjQtZTZhMGM3NGQtMDU0OC00Yzc2LTg1MzYtYzYxM2RlZDczNDMwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA1MDQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwNTA0VDE3NTA0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTkwNDYwNmFiYTFiZmIyOTg4MjdiZGE4ZDdkZDU2OGFjMTQyOTNhMjljZGQ4ODEyOTBmNzkyMDc1OTY3YjE3MzkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JnJlc3BvbnNlLWNvbnRlbnQtdHlwZT1pbWFnZSUyRnBuZyJ9.4TQrl4SvQM6TIi99kd_m1D-8FGaaPkDJPeQVDhHhoPA
// @grant none
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
function addGitingestButton() {
if (document.getElementById('gitingest-btn')) return;
const actionHeader = document.querySelector('ul.pagehead-actions');
if (!actionHeader) return;
const li = document.createElement('li');
li.id = 'gitingest-btn-container';
li.style.position = 'relative'; // For tooltip positioning
const btn = document.createElement('a');
btn.id = 'gitingest-btn';
btn.className = 'btn btn-sm'; // Standard GitHub small button
btn.href = window.location.href.replace('github.com', 'gitingest.com');
btn.target = '_blank';
// Styling to match the screenshot (Dark Mode GitHub)
Object.assign(btn.style, {
backgroundColor: '#21262d',
border: '1px solid #30363d',
color: '#c9d1d9',
display: 'inline-flex',
alignItems: 'center',
padding: '3px 12px',
fontSize: '12px',
fontWeight: '500',
borderRadius: '6px',
gap: '8px',
textDecoration: 'none'
});
// The "Ingest" Icon (Simplified SVG match)
const iconSvg = `
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4 2H10L14 6V14C14 14.55 13.55 15 13 15H4C3.45 15 3 14.55 3 14V3C3 2.45 3.45 2 4 2Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M9 2V6H14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M2 9H7M7 9L5 7M7 9L5 11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
`;
btn.innerHTML = `${iconSvg} <span>Open in GitIngest</span>`;
// Create the Tooltip
const tooltip = document.createElement('div');
tooltip.innerText = 'Turn this to a LLM-friendly prompt in a new tab';
Object.assign(tooltip.style, {
position: 'absolute',
top: '100%',
left: '50%',
transform: 'translateX(-50%)',
marginTop: '8px',
padding: '5px 12px',
backgroundColor: '#2d333b',
color: '#adbac7',
fontSize: '12px',
borderRadius: '6px',
whiteSpace: 'nowrap',
visibility: 'hidden',
opacity: '0',
transition: 'opacity 0.2s',
zIndex: '100',
border: '1px solid #444c56'
});
// Show/Hide Tooltip
btn.onmouseenter = () => {
tooltip.style.visibility = 'visible';
tooltip.style.opacity = '1';
btn.style.backgroundColor = '#30363d';
};
btn.onmouseleave = () => {
tooltip.style.visibility = 'hidden';
tooltip.style.opacity = '0';
btn.style.backgroundColor = '#21262d';
};
li.appendChild(btn);
li.appendChild(tooltip);
// Place after the Watch button
const watchItem = actionHeader.querySelector('li');
if (watchItem) {
watchItem.after(li);
} else {
actionHeader.appendChild(li);
}
}
// Handle initial load and SPA navigation
addGitingestButton();
document.addEventListener('turbo:render', addGitingestButton);
})();