This is tiring
This commit is contained in:
parent
6551996149
commit
b3cb7701b8
28
copyurl.js
28
copyurl.js
@ -1,13 +1,17 @@
|
||||
const url = window.location.href;
|
||||
chrome.commands.onCommand.addListener(function (command) {
|
||||
if (command === "Copy URL") {
|
||||
navigator.clipboard.writeText(url).then(
|
||||
function () {
|
||||
console.log(`Copied URL: ${url}`);
|
||||
},
|
||||
function (err) {
|
||||
console.error(`Something went wrong..`, err);
|
||||
},
|
||||
);
|
||||
}
|
||||
function copyUrl() {
|
||||
document.navigator.clipboard.writeText(tab.url).then(
|
||||
function () {
|
||||
console.log(`Copied URL: ${tab.url}`);
|
||||
},
|
||||
function (err) {
|
||||
console.error(`Something went wrong..`, err);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
chrome.action.onClicked.addListener((tab) => {
|
||||
chrome.scripting.executeScript({
|
||||
target: { tabId: tab.id },
|
||||
func: copyUrl,
|
||||
});
|
||||
});
|
||||
|
@ -17,5 +17,6 @@
|
||||
},
|
||||
"description": "Copy the URL of the current tab"
|
||||
}
|
||||
}
|
||||
},
|
||||
"permissions": ["clipboardWrite", "clipboardRead", "activeTab", "scripting"]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user