4 |
5 |
6 |
7 | copy-rich-link popup
8 |
9 |
10 | Copied
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "engines": {
4 | "node": "18"
5 | },
6 | "scripts": {
7 | "dev": "vite",
8 | "build": "tsc && vite build",
9 | "preview": "vite preview",
10 | "lint": "prettier --write ."
11 | },
12 | "devDependencies": {
13 | "@crxjs/vite-plugin": "^1.0.3",
14 | "@types/chrome": "^0.0.184",
15 | "prettier": "^2.6.2",
16 | "typescript": "^4.5.4",
17 | "vite": "^2.9.7"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "useDefineForClassFields": true,
5 | "module": "ESNext",
6 | "lib": ["ESNext", "DOM"],
7 | "moduleResolution": "Node",
8 | "strict": true,
9 | "sourceMap": true,
10 | "resolveJsonModule": true,
11 | "isolatedModules": true,
12 | "esModuleInterop": true,
13 | "noEmit": true,
14 | "noUnusedLocals": true,
15 | "noUnusedParameters": true,
16 | "noImplicitReturns": true,
17 | "skipLibCheck": true
18 | },
19 | "include": ["src"]
20 | }
21 |
--------------------------------------------------------------------------------
/docs/chrome_web_store_description.txt:
--------------------------------------------------------------------------------
1 | Useful for pasting links to Slack, Google Docs, etc.
2 |
3 | ## Usage
4 |
5 | Click the extension icon or execute the keyboard shortcut to copy the link to the page as rich text.
6 |
7 | ## Keyboard shortcut
8 |
9 | The default keyboard shortcut is Ctrl + Shift + L, and Command + Shift + L on Mac.
10 | This can be changed from the browser's extension settings.
11 |
12 | ## Plain text fallback
13 |
14 | As a fallback, we also copy in plain text format in the form `"{title}" {url}`,
15 | so that if you paste where rich text is not available or paste explicitly as plain text (Ctrl + Shift + V on Windows), this plain text format will be pasted.
16 |
--------------------------------------------------------------------------------
/src/main.ts:
--------------------------------------------------------------------------------
1 | import "./style.css";
2 |
3 | function copy({ html, plain }: { html: string; plain: string }) {
4 | const listener = (event: any) => {
5 | event.clipboardData.setData("text/html", html);
6 | event.clipboardData.setData("text/plain", plain);
7 | event.preventDefault();
8 | };
9 | document.addEventListener("copy", listener);
10 | document.execCommand("copy");
11 | document.removeEventListener("copy", listener);
12 | }
13 |
14 | chrome.tabs.query(
15 | {
16 | active: true,
17 | currentWindow: true,
18 | },
19 | (tabs) => {
20 | const { title, url } = tabs[0];
21 | copy({
22 | html: `${title}`,
23 | plain: `"${title}" ${url}`,
24 | });
25 | }
26 | );
27 |
--------------------------------------------------------------------------------
/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Copy Rich Link",
3 | "description": "Copy the page title and URL as rich text.",
4 | "version": "0.1.0",
5 | "manifest_version": 3,
6 | "action": {
7 | "default_popup": "index.html",
8 | "default_icon": {
9 | "16": "images/icon16.png",
10 | "32": "images/icon32.png",
11 | "48": "images/icon48.png",
12 | "128": "images/icon128.png"
13 | }
14 | },
15 | "icons": {
16 | "16": "images/icon16.png",
17 | "32": "images/icon32.png",
18 | "48": "images/icon48.png",
19 | "128": "images/icon128.png"
20 | },
21 | "commands": {
22 | "_execute_action": {
23 | "suggested_key": {
24 | "default": "Ctrl+Shift+L"
25 | }
26 | }
27 | },
28 | "permissions": ["activeTab", "clipboardWrite"]
29 | }
30 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Copy Rich Link
2 |
3 | Browser extension to copy the page title and URL as rich text.
4 |
5 | Useful for pasting links to Slack, Google Docs, etc.
6 |
7 | 
8 |
9 | 
10 |
11 | ## Usage
12 |
13 | ### Install
14 |
15 | Install from [Chrome Web Store](https://chrome.google.com/webstore/detail/copy-rich-link/hikiamlgpdcabppakpmemaofmkgknpea).
16 |
17 | ### Copy
18 |
19 | Click the extension icon or execute the keyboard shortcut to copy the link to the page as rich text.
20 |
21 | ### Keyboard shortcut
22 |
23 | The default keyboard shortcut is Ctrl + Shift + L, and Command + Shift + L on Mac.
24 | This can be changed from the browser's extension settings.
25 |
26 | ### Plain text fallback
27 |
28 | As a fallback, we also copy in plain text format in the form `"{title}" {url}`,
29 | so that if you paste where rich text is not available or paste explicitly as plain text (Ctrl + Shift + V on Windows), this plain text format will be pasted.
30 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Ryo Nakamura
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 |
--------------------------------------------------------------------------------
/favicon.svg:
--------------------------------------------------------------------------------
1 |
16 |
--------------------------------------------------------------------------------