Selected text as search query (%@) in Floating WebView

Would it be possible to have selected text as a search query in user defined URL in the Floating WebView?
Like this: https://i.imgur.com/64MAMsM.png

I'm attempting the same thing. Did you manage to figure this out?

@Andreas_Hegenberg if not this, is there a workaround?
This will be sooo handy for quick google searches / dictionary lookups etc :slight_smile:

I just tried and with current BTT versions it works like this:


So first add an action with the predefined action "Save selected text to variable selected text"

Then in the webview use code like this to retrieve the variable:

<html>
<style>
// spinner from https://loading.io/css/
.lds-dual-ring {
  display: inline-block;
  width: 80px;
  height: 80px;
}
.lds-dual-ring:after {
  content: " ";
  display: block;
  width: 64px;
  height: 64px;
  margin: 8px;
  border-radius: 50%;
  border: 6px solid #fff;
  border-color: #fff transparent #fff transparent;
  animation: lds-dual-ring 1.2s linear infinite;
}
@keyframes lds-dual-ring {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
</style>
<script>

async function BTTInitialize() {


let selectedText = await callBTT("get_string_variable", {variableName:"selected_text"})

window.location.href="https://www.google.com/search?q=" + encodeURIComponent(selectedText);


}

</script>
<body>
<div  style="with:100%; height:100%; display:flex; align-items:center;align-content:center; justify-content:center">
<div class="lds-dual-ring"></div>
</div>
</body>
</html>

Make sure to also check this option:

1 Like