The Copy Link Text Chrome extension allows users to quickly copy the text content of any link (<a>
tag) or button (<button>
tag) to the clipboard via a right-click context menu. It also provides optional notifications to confirm successful copying.
- Right-Click Context Menu: Adds a
Copy Link Text
option to the context menu when you right-click a link or button. - Clipboard Copying: Automatically copies the text content to the clipboard.
- Notifications: Displays notifications for successful or unsuccessful copy actions. Notifications can be toggled on or off in the extension's settings.
- Cross-Page Support: Works on all web pages by injecting a content script.
-
Clone or Download the repository:
git clone https://github.com/sumanengbd/copy-link-text.git cd copy-link-text
-
Open Chrome and navigate to
chrome://extensions
. -
Enable Developer mode (toggle in the top-right corner).
-
Click Load unpacked and select the project folder.
-
The extension should now be installed and ready to use.
- Right-click on a link (
<a>
tag) or button (<button>
tag). - Select Copy Link Text from the context menu.
- The text will be copied to the clipboard.
- If notifications are enabled, a small popup will confirm the copied text or inform you if no text was available.
- Specifies the extension's metadata, permissions, and configuration.
- Includes the content script (
content.js
) and background service worker (background.js
).
- Manages the context menu dynamically based on the right-click target.
- Listens for context menu clicks and handles clipboard operations via messages to the content script.
- Displays notifications using the Chrome Notifications API.
- Detects right-click events to determine if the target is a link or button.
- Communicates with the background script to show or hide the context menu.
- Handles copying the text of the right-clicked element to the clipboard.
The extension requires the following permissions:
storage
: To save user settings (e.g., notification preferences).activeTab
: To access the current tab when interacting with the extension.contextMenus
: To add the "Copy Link Text" option to the right-click menu.notifications
: To display notifications after a copy action.clipboardWrite
: To copy the text to the clipboard.
To toggle notifications:
- Open the extension settings (to be implemented in a future version).
- Enable or disable the notification preference.
Choose the context where the "Copy Link Text" option should appear:
- Link/Button: The context menu will only appear when right-clicking on links (
<a>
tags) or buttons (<button>
tags). - Anywhere: The context menu will appear when right-clicking anywhere on the page, whether on a link, button, or other elements.
The Select Mode option will be available in the extension's settings, allowing users to choose between these two modes.
- Add an options page for user preferences (e.g., enabling/disabling notifications).
- Extend functionality to include copying URLs or attributes.
- Support keyboard shortcuts for copying.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch (
feature/new-feature
). - Commit your changes and open a pull request.
This extension was built using the Chrome Extensions API. Special thanks to the open-source community for inspiration and resources.
Happy Copying! 😊