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;
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,
});
});

View File

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