Add README.org, documentation and logging changes

This commit is contained in:
2025-08-25 18:11:17 -04:00
parent 4d385d0d8b
commit f1689a9777
3 changed files with 20 additions and 6 deletions

View File

@@ -15,16 +15,16 @@
return(cleanedUrl)
}
// return original url if it is not a share link
console.log("Not a share link, clipboard contents unmodified.")
return(url)
}
function sleep(ms) {
// sleep for half a second
return new Promise(resolve => setTimeout(resolve, ms));
}
async function onMouseUp() {
// wait half a second after clicking before reading clipboard
// delay clipboard read slightly because of page script nonsense
await sleep(500);
let clipText = await navigator.clipboard.readText();
@@ -33,12 +33,13 @@
if (clipText !== newText) {
const newClip = await navigator.clipboard.writeText(newText);
console.log("Modified clipboard with cleaned share link: %o", newText);
clipText = undefined;
newText = undefined;
} else {
console.log("Share link not detected, clipboard contents unmodified.");
}
// discard clipboard data
clipText = undefined;
newText = undefined;
}
// run whenever MOUSE1 is released
document.addEventListener('mouseup', onMouseUp, false);
})();