This is tiring
This commit is contained in:
parent
6551996149
commit
b3cb7701b8
16
copyurl.js
16
copyurl.js
@ -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,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -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"]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user