Search code examples
webkit2webkit2-webextension

Clear selection in WebKit2 Web Extension without JavaScript


I want to clear the selection from a web extension.

There is a signal selection-changed, but there does not seem to have a way to clear the selection.

I tried creating a WebKitDOMRange but it seems there is no way to set this new range in the document. And it does not seem to have a way to get the current range.

How can I clear the selection from a WebKit2 web extension without using a JavaScript string?


Solution

  • WebKit2 seems to have an unstable API that does not appear in the documentation.

    I was able to get the current selection with the webkit_dom_dom_window_get_selection and clearing it with webkit_dom_dom_selection_empty