This is tiring

This commit is contained in:
TropiiDev 2025-03-06 13:47:50 -05:00
parent 6551996149
commit b3cb7701b8
2 changed files with 18 additions and 13 deletions

View File

@ -1,13 +1,17 @@
const url = window.location.href; function copyUrl() {
chrome.commands.onCommand.addListener(function (command) { document.navigator.clipboard.writeText(tab.url).then(
if (command === "Copy URL") {
navigator.clipboard.writeText(url).then(
function () { function () {
console.log(`Copied URL: ${url}`); console.log(`Copied URL: ${tab.url}`);
}, },
function (err) { function (err) {
console.error(`Something went wrong..`, err); console.error(`Something went wrong..`, err);
}, },
); );
} }
chrome.action.onClicked.addListener((tab) => {
chrome.scripting.executeScript({
target: { tabId: tab.id },
func: copyUrl,
});
}); });

View File

@ -17,5 +17,6 @@
}, },
"description": "Copy the URL of the current tab" "description": "Copy the URL of the current tab"
} }
} },
"permissions": ["clipboardWrite", "clipboardRead", "activeTab", "scripting"]
} }