Floating View Web Changes Position

Thanks @Andreas_Hegenberg . Was this the only thing you added to get this floating view into focus?
image

Asking because I was thinking if we can just bring this floating window into focus (not the text area) that should be enough, rather than trying to figure out the CSS everytime. e.g., When I open google.com in this view for the first time after BTT restart (or after like an hour), the window is in focus. (see the buttons on the top left, red/yellow/green)

But when I trigger it the next time, it shows up but is not in focus, like this (see buttons on top left)

So when I open ChatGPT for the first time after 2-3 hours (or after BetterTouchTool restart) it is in focus. If I trigger it within 5-10 mins, it is not. Not sure if it is because the the view in already loaded in memory

the color of the window buttons doesn't matter, macOS has two different concepts (keyboard focus and windows focus - BTT only cares about keyboard focus for the floating menus).

The problem without the javascript is: webviews support auto focus on load, but after a website is loaded and in memory, auto focus can not trigger again automatically without reloading the site. That's actually a security feature of modern browsers, so websites can not activate a textfield without your knowledge to steal your keyboard input.

Besides the JavaScript, it's important to make the menu have keyboard focus:

Finding the id of the element to use in the focus javascript is usually not complicated. Just right-click the text field and choose "inspect element", then right-click the highlighted HTML and choose "copy selector path".

The selector path can then be used like this:

document.querySelector("HERE GOES THE COPIED SELECTOR PATH").focus()

For Google it's

document.querySelector("#APjFqb").focus()

But this might depend on the country.

Awesome! I didn't know about the auto focus happening only on site reload.

Query selector works as well!

Is there a configurable setting that determines when the loaded webpage is reloaded. I notice that when I trigger the floating view first time after BTT restart, it takes a second to load (I see the red background of the webview), but next triggers are instantaneous. However, after an arbitrary amount of time (usually 30-60 mins), when I trigger it again, it reload again.

That could be a bug. I'll monitor this. It should keep in memory as long as BTT is not relaunched.

Make sure to not have "Relaunch after sleep" active in the BTT settings.

I assume you are talking about this? If yes, it disabled. I also used to notice similar behavior with the old Floating WebView. Using this feature has become such an important part of my workflow especially with GPTs being everywhere!

image

Thank you!!

It is possible macOS automatically clears the webview cache if memory gets low, but I'm not sure about this. It could very well be a bug in BTT, I'll add some logs with the next version that will allow to figure out when the cache is lost.

1 Like

I did think about it so monitored my RAM usage and it was below 30% of my 32 GB RAM. Unless macOS has a way to cleanup memory usage - app specific.

Thanks again for being super responsive!!

1 Like

There is currently one known case where BTT clears the cache: if you make any change to a floating menu and save it in the BTT configuration UI. This is so it can be sure to always start at the correct fresh state.

I think I can disable this for webview content though.

1 Like

@Andreas_Hegenberg Everything has been working well with this feature.

I started using the new positioning feature of the floating view and it is very well thought through. Now I can connect my Mac to an external display of any size (or without it) and expect the floating view to open at exactly the same place where I want it to. The multiple coordinates BTT provides with regard to the floating window and the screen size are very very well thought through. Thanks again Andreas!! :heart: .

Here are my settings just in case. I wanted ChatGPT to open on the top right half of the screen with some padding on the right-hand size

1 Like

I've started executing a bunch of JS after the floating view trigger to hide certain HTML elements on the web page. The final result works as expected but it takes it a second to hide the elements. So the full webpage shows up and then the JS is executed which is the reason for the lag. Any way we can add JS while the page is loading so the elements are hidden right away rather than as a separate step which takes a second

image

Yes, you can enter the script here instead of using an action:

1 Like