├── .gitattributes ├── README.md ├── content.js ├── hnuser-screenhot.png ├── images ├── icon128.png ├── icon16.png └── icon48.png ├── manifest.json └── popup.html /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | THIS IS FOR CHROME. 2 | 3 | If requested I will create a Firefox version. 4 | 5 | Check hnuser-screenshot.png to see how it works. 6 | 7 | 8 | How to Use? 9 | 10 | -Download the Folder 11 | 12 | -Extract it somewhere. 13 | 14 | -Open chrome and type: chrome://extensions 15 | 16 | -Select the folder you extracted. 17 | 18 | -Select LOAD UNPACKED and it will run on news.ycombinator.com when you hover on a user after 0.5 second. 19 | 20 | 21 | How to change the delay? 22 | 23 | -Change the value near the bottom of content.js: "}, 500);" to whatever value you desire. 24 | 25 | -Do not change it to 0 so it won't request immediately when you hover. 26 | 27 | -------------------------------------------------------------------------------- /content.js: -------------------------------------------------------------------------------- 1 | // Create and append the tooltip element immediately 2 | let tooltip = document.createElement('div'); 3 | tooltip.style.cssText = 'position: absolute; z-index: 1000; padding: 8px; background: black; color: white; border-radius: 4px; display: none;'; 4 | tooltip.id = 'hn-user-tooltip'; 5 | document.body.appendChild(tooltip); 6 | 7 | let hoverTimer; // Timer for the delay 8 | 9 | document.addEventListener('mouseover', function (e) { 10 | if (e.target && e.target.className === 'hnuser') { 11 | // Clear any existing timer 12 | clearTimeout(hoverTimer); 13 | 14 | // Start a new timer 15 | hoverTimer = setTimeout(() => { 16 | let username = e.target.textContent.trim(); 17 | let fetchURL = `https://news.ycombinator.com/user?id=${username}`; 18 | 19 | fetch(fetchURL) 20 | .then(response => response.text()) 21 | .then(htmlString => { 22 | let parser = new DOMParser(); 23 | let doc = parser.parseFromString(htmlString, 'text/html'); 24 | 25 | let createdElement = doc.querySelector('a[href*="birth"]'); // Example selector 26 | let karmaElement = doc.querySelector('span[id="karma"]'); // Example selector 27 | let aboutElement = doc.querySelector('td[style*="overflow:hidden"]'); // Example selector 28 | 29 | let content = `Username: ${username}`; 30 | content += createdElement ? `
Created: ${createdElement.textContent.trim()}` : '
Created: Not Found'; 31 | content += karmaElement ? `
Karma: ${karmaElement.textContent.trim()}` : '
Karma: Not Found'; 32 | content += aboutElement ? `
About: ${aboutElement.textContent.trim()}` : '
About: Not Found'; 33 | 34 | // Set the tooltip content and position it right under the cursor 35 | tooltip.innerHTML = content; 36 | tooltip.style.left = e.pageX + 'px'; // Right under the cursor horizontally 37 | tooltip.style.top = e.pageY + 20 + 'px'; // 20px below cursor vertically 38 | tooltip.style.display = 'block'; 39 | }) 40 | .catch(err => { 41 | console.error('Failed to fetch user info:', err); 42 | tooltip.style.display = 'none'; 43 | }); 44 | }, 500); // Delay of 0.5 second 45 | } 46 | }); 47 | 48 | document.addEventListener('mouseout', function(e) { 49 | if (e.target && e.target.className === 'hnuser') { 50 | clearTimeout(hoverTimer); // Clear the timer if mouse leaves before the delay 51 | tooltip.style.display = 'none'; 52 | } 53 | }); 54 | -------------------------------------------------------------------------------- /hnuser-screenhot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConsoleScript/hnuser/eed6b991717d1174153011ba63b160b9e2f0e7be/hnuser-screenhot.png -------------------------------------------------------------------------------- /images/icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConsoleScript/hnuser/eed6b991717d1174153011ba63b160b9e2f0e7be/images/icon128.png -------------------------------------------------------------------------------- /images/icon16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConsoleScript/hnuser/eed6b991717d1174153011ba63b160b9e2f0e7be/images/icon16.png -------------------------------------------------------------------------------- /images/icon48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ConsoleScript/hnuser/eed6b991717d1174153011ba63b160b9e2f0e7be/images/icon48.png -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 3, 3 | "name": "HN User Info Fetcher", 4 | "version": "1.0", 5 | "host_permissions": [ 6 | "https://news.ycombinator.com/*" 7 | ], 8 | "content_scripts": [ 9 | { 10 | "matches": ["https://news.ycombinator.com/*"], 11 | "js": ["content.js"] 12 | } 13 | ], 14 | "action": { 15 | "default_icon": { 16 | "16": "images/icon16.png", 17 | "48": "images/icon48.png", 18 | "128": "images/icon128.png" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /popup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | HN User Info 5 | 8 | 9 | 10 |

Hacker News User Info

11 | 12 | 13 | 14 | --------------------------------------------------------------------------------