├── .gitignore ├── LICENSE ├── README.md ├── content.js ├── images ├── icon128.png ├── icon16.png ├── icon32.png └── icon48.png ├── manifest.json ├── popup.html └── popup.js /.gitignore: -------------------------------------------------------------------------------- 1 | # Node.js dependencies 2 | node_modules/ 3 | npm-debug.log 4 | yarn-debug.log 5 | yarn-error.log 6 | package-lock.json 7 | yarn.lock 8 | 9 | # Build artifacts 10 | *.zip 11 | *.crx 12 | *.pem 13 | dist/ 14 | build/ 15 | 16 | # IDE and editor files 17 | .idea/ 18 | .vscode/ 19 | *.swp 20 | *.swo 21 | .DS_Store 22 | Thumbs.db 23 | 24 | # Chrome extension packaging 25 | *.zip 26 | *.crx 27 | *.pem 28 | 29 | # Temporary files 30 | *.log 31 | *.tmp 32 | *.bak 33 | *.backup 34 | 35 | # Environment variables 36 | .env 37 | .env.local 38 | .env.development.local 39 | .env.test.local 40 | .env.production.local 41 | 42 | # Debug files 43 | debug.log 44 | debug/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Akhil Juluru 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GitHub Link Opener Chrome Extension 2 | 3 | A simple Chrome extension that automatically opens non-GitHub links in new tabs when browsing GitHub.com. This keeps you on GitHub while still allowing you to easily access external resources. 4 | 5 | ## Features 6 | 7 | - Only activates on GitHub.com pages 8 | - Automatically opens non-GitHub links in new tabs 9 | - Works with all types of links (absolute, relative, and root-relative) 10 | - No configuration needed - just install and browse GitHub as usual 11 | - Minimal permissions - only requires access to GitHub.com 12 | 13 | ## Installation 14 | 15 | ### From Chrome Web Store (Recommended) 16 | 17 | 1. Visit the [Chrome Web Store](https://chromewebstore.google.com/detail/kmedjapbknhaihmnpdanijibjaigedlm) 18 | 2. Click "Add to Chrome" 19 | 3. Confirm the installation 20 | 21 | ### Manual Installation (Developer Mode) 22 | 23 | 1. Clone or download this repository to your local machine 24 | 2. Open Chrome and navigate to `chrome://extensions/` 25 | 3. Enable "Developer mode" by toggling the switch in the top right corner 26 | 4. Click "Load unpacked" and select the directory containing the extension files 27 | 5. The extension should now be installed and visible in your extensions list 28 | 29 | ## Usage 30 | 31 | 1. Navigate to any GitHub.com page 32 | 2. The extension will automatically open any non-GitHub links in new tabs when clicked 33 | 3. No additional action is needed - just browse GitHub as usual! 34 | 35 | ## How It Works 36 | 37 | The extension detects when you click on a link on GitHub.com. If the link points to a non-GitHub website, it: 38 | 39 | 1. Prevents the default navigation behavior 40 | 2. Opens the link in a new tab 41 | 3. Keeps you on the current GitHub page 42 | 43 | This is particularly useful when: 44 | 45 | - Reading documentation that references external resources 46 | - Following links to related projects or tools 47 | - Accessing external documentation without losing your place on GitHub 48 | 49 | ## Privacy 50 | 51 | This extension: 52 | 53 | - Only runs on GitHub.com pages 54 | - Does not collect or transmit any user data 55 | - Requires minimal permissions - only needs access to GitHub.com 56 | - Does not track browsing history or store any data 57 | 58 | ## Files in this Extension 59 | 60 | - `manifest.json`: Extension configuration 61 | - `popup.html`: The extension popup UI 62 | - `popup.js`: JavaScript for the popup functionality 63 | - `content.js`: Code that runs on GitHub pages 64 | - `images/`: Directory containing extension icons 65 | 66 | ## Customization 67 | 68 | To modify the extension's functionality, edit the `content.js` file to change how it interacts with GitHub pages. 69 | 70 | ## License 71 | 72 | MIT License - See LICENSE file for details 73 | 74 | ## Support 75 | 76 | If you encounter any issues or have suggestions for improvements, please [open an issue](https://github.com/JuluruAkhil/github-link-opener/issues) on GitHub. 77 | -------------------------------------------------------------------------------- /content.js: -------------------------------------------------------------------------------- 1 | // This script only runs on GitHub.com pages due to the manifest.json configuration 2 | console.log("GitHub Link Opener extension is active on this page") 3 | 4 | // Function to check if a URL is from GitHub 5 | function isGitHubUrl(url) { 6 | return url.includes("github.com") 7 | } 8 | 9 | // Function to convert relative URL to absolute URL 10 | function getAbsoluteUrl(href) { 11 | // If it's already an absolute URL, return it 12 | if (href.startsWith("http://") || href.startsWith("https://")) { 13 | return href 14 | } 15 | 16 | // If it's a relative URL starting with '/', it's relative to the domain root 17 | if (href.startsWith("/")) { 18 | return "https://github.com" + href 19 | } 20 | 21 | // If it's a relative URL without '/', it's relative to the current path 22 | const currentPath = window.location.pathname 23 | const currentDir = currentPath.substring(0, currentPath.lastIndexOf("/") + 1) 24 | return "https://github.com" + currentDir + href 25 | } 26 | 27 | // Add event listener to all links on the page 28 | document.addEventListener("click", function (event) { 29 | // Find the closest anchor tag that was clicked 30 | const link = event.target.closest("a") 31 | 32 | // If a link was clicked 33 | if (link) { 34 | const href = link.getAttribute("href") 35 | 36 | // Skip if no href or if it's a fragment/anchor link 37 | if (!href || href.startsWith("#") || href.startsWith("javascript:")) { 38 | return 39 | } 40 | 41 | // Get the absolute URL 42 | const absoluteUrl = getAbsoluteUrl(href) 43 | 44 | // Check if it's not a GitHub URL 45 | if (!isGitHubUrl(absoluteUrl)) { 46 | // Prevent the default action 47 | event.preventDefault() 48 | 49 | // Open the link in a new tab 50 | window.open(absoluteUrl, "_blank") 51 | } 52 | } 53 | }) 54 | -------------------------------------------------------------------------------- /images/icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JuluruAkhil/github-link-opener/962224e841d0e03acbc4f178f9e4aaba089df2b8/images/icon128.png -------------------------------------------------------------------------------- /images/icon16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JuluruAkhil/github-link-opener/962224e841d0e03acbc4f178f9e4aaba089df2b8/images/icon16.png -------------------------------------------------------------------------------- /images/icon32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JuluruAkhil/github-link-opener/962224e841d0e03acbc4f178f9e4aaba089df2b8/images/icon32.png -------------------------------------------------------------------------------- /images/icon48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JuluruAkhil/github-link-opener/962224e841d0e03acbc4f178f9e4aaba089df2b8/images/icon48.png -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 3, 3 | "name": "GitHub Link Opener", 4 | "version": "1.0.1", 5 | "description": "Automatically opens non-GitHub links in new tabs when browsing GitHub.com, keeping you on GitHub while accessing external resources.", 6 | "author": "Akhil Juluru", 7 | "host_permissions": ["*://github.com/*"], 8 | "action": { 9 | "default_popup": "popup.html", 10 | "default_icon": { 11 | "16": "images/icon16.png", 12 | "48": "images/icon48.png", 13 | "128": "images/icon128.png" 14 | } 15 | }, 16 | "content_scripts": [ 17 | { 18 | "matches": ["*://github.com/*"], 19 | "js": ["content.js"] 20 | } 21 | ], 22 | "icons": { 23 | "16": "images/icon16.png", 24 | "48": "images/icon48.png", 25 | "128": "images/icon128.png" 26 | }, 27 | "homepage_url": "https://github.com/JuluruAkhil/github-link-opener", 28 | "offline_enabled": true 29 | } 30 | -------------------------------------------------------------------------------- /popup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | GitHub Link Opener 5 | 31 | 32 | 33 |

GitHub Link Opener

34 |

35 | This extension automatically opens non-GitHub links in new tabs when 36 | you're browsing GitHub.com. 37 |

38 |

No action needed - just browse GitHub as usual!

39 |
Extension is active
40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /popup.js: -------------------------------------------------------------------------------- 1 | document.addEventListener("DOMContentLoaded", function () { 2 | // Check if we're on GitHub and update UI accordingly 3 | chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { 4 | const activeTab = tabs[0] 5 | const statusMessage = document.getElementById("statusMessage") 6 | 7 | if (activeTab && activeTab.url && activeTab.url.includes("github.com")) { 8 | statusMessage.textContent = "Extension is active on GitHub" 9 | statusMessage.style.backgroundColor = "#2ea44f" 10 | } else { 11 | statusMessage.textContent = "Extension only works on GitHub.com" 12 | statusMessage.style.backgroundColor = "#d73a49" 13 | } 14 | }) 15 | }) 16 | --------------------------------------------------------------------------------