File tree Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 4
4
"id": "",
5
5
"use_system": false,
6
6
"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
+ }
7
18
}
8
19
},
9
20
"browser": {
Original file line number Diff line number Diff line change
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
+
You can’t perform that action at this time.
0 commit comments