Skip to content

Commit 0955a84

Browse files
committed
Copy URL to clipboard Chrome extension
This creates an Omarchy migration that makes a Chrome plugin that allows you to copy the current URL to the system clipboard and send a notification.
1 parent 8fd668f commit 0955a84

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

config/chromium/Default/Preferences

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44
"id": "",
55
"use_system": false,
66
"use_custom": false
7+
},
8+
"settings": {
9+
"copy-url-extension": {
10+
"location": 4,
11+
"path": "../../chromium/extensions/copy-url",
12+
"state": 1,
13+
"manifest": {
14+
"name": "Copy URL",
15+
"version": "1.0"
16+
}
17+
}
718
}
819
},
920
"browser": {

migrations/1757021485.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
echo "Install Copy URL extension for Chromium"
2+
3+
EXTENSION_DIR="$HOME/.local/share/chromium/extensions/copy-url"
4+
5+
mkdir -p "$EXTENSION_DIR"
6+
7+
cat >"$EXTENSION_DIR/manifest.json" <<'EOF'
8+
{
9+
"manifest_version": 3,
10+
"name": "Copy URL",
11+
"version": "1.0",
12+
"description": "Copy current URL to clipboard",
13+
"permissions": ["activeTab", "scripting", "notifications"],
14+
"commands": {
15+
"copy-url": {
16+
"suggested_key": {"default": "Ctrl+Shift+U"},
17+
"description": "Copy URL"
18+
}
19+
},
20+
"background": {"service_worker": "background.js"}
21+
}
22+
EOF
23+
24+
cat >"$EXTENSION_DIR/background.js" <<'EOF'
25+
chrome.commands.onCommand.addListener((command) => {
26+
if (command === 'copy-url') {
27+
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
28+
const currentTab = tabs[0];
29+
30+
chrome.scripting.executeScript({
31+
target: { tabId: currentTab.id },
32+
func: () => {
33+
navigator.clipboard.writeText(window.location.href);
34+
}
35+
}).then(() => {
36+
chrome.notifications.create({
37+
type: 'basic',
38+
iconUrl: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==',
39+
title: 'Copy URL',
40+
message: 'URL copied'
41+
});
42+
});
43+
});
44+
}
45+
});
46+
EOF
47+

0 commit comments

Comments
 (0)