Is there some sort of a placeholder that I can use as the value for the Web URL? I don't want to have a fixed value in here, I want it to always be whatever is in the clipboard. Is that possible?
Instead of providing a URL, provide this HTML/JS:
<html>
<head>
<script>
async function BTTWindowWillBecomeVisible() {
let result = await callBTT('get_clipboard_content', {});
window.location = result;
}
</script>
</head>
<body>
...
</body>
</html>
Also make sure to disable the webview while in background:
That didn't work unfortunately. An empty WebView is opened instead of the copied URL:
Does the result
variable only hold the clipboard content or it has a specific structure (or format)?
it’s only the text from the clipboard, however it must be a valid url (starting with http or https). If that’s not the case you first might want to transform the input a bit
I'm pretty sure it's a valid URL, I just verified my clipboard history immediately after running the trigger, and the last item on the clipboard is a valid URL that starts with https.
Maybe try this, it will show the clipboard content in the webview if redirecting doesn't work. Maybe the BTTInitialize will also help.
<html>
<head>
<script>
async function BTTInitialize() {
let result = await callBTT('get_clipboard_content', {});
window.document.getElementById("url").innerHTML = result;
try {
window.location = result;
} catch (e) {
console.log(e);
}
}
async function BTTWindowWillBecomeVisible() {
let result = await callBTT('get_clipboard_content', {});
window.document.getElementById("url").innerHTML = result;
try {
window.location = result;
} catch (e) {
console.log(e);
}
}
</script>
</head>
<body style="background:white;">
<p id="url"></p>
</body>
</html>