diff --git a/clip/index.html b/clip/index.html
index 5284624..2080351 100644
--- a/clip/index.html
+++ b/clip/index.html
@@ -37,6 +37,23 @@
return url.toString();
}
+ async function processClipboard(content) {
+ if (content == '') {
+ output.textContent = 'Clipboard is empty';
+ return;
+ }
+
+ if (!content.startsWith('http')) {
+ output.textContent = 'URL not found in the clipboard';
+ return;
+ }
+
+ const url = await cleanURL(content);
+ navigator.clipboard.writeText(url);
+ output.textContent = 'Cleaned URL: ' + url;
+ output.innerHTML += '
Copied to the clipboard'
+ }
+
async function readClipboard() {
const text = await navigator.clipboard.readText();
return text.trim();
@@ -45,8 +62,8 @@
document.getElementById('clipboard').addEventListener('click', async function () {
const output = document.getElementById('output');
- if (!navigator.clipboard) {
- output.textContent = 'Clipboard API not supported on this browser';
+ if (!navigator.clipboard || !navigator.clipboard.readText) {
+ output.textContent = 'Clipboard API not supported on this browser, please use CTRL+V';
return;
}
@@ -59,20 +76,12 @@
return;
}
- if (content == '') {
- output.textContent = 'Clipboard is empty';
- return;
- }
-
- if (!content.startsWith('http')) {
- output.textContent = 'URL not found in the clipboard';
- return;
- }
+ await processClipboard(content);
+ });
- const url = await cleanURL(content);
- navigator.clipboard.writeText(url);
- output.textContent = 'Cleaned URL: ' + url;
- output.innerHTML += '
Copied to the clipboard'
+ document.addEventListener('paste', async function (event) {
+ const content = event.clipboardData.getData('Text');
+ await processClipboard(content);
});