david-tejada / rango

🦎 The cross browser extension that helps you control your browser by voice. It blends in!
MIT License
121 stars 15 forks source link

Mark response payload as non monitored/transient #300

Open AndreasArvidsson opened 3 weeks ago

AndreasArvidsson commented 3 weeks ago

By setting the appropriate mime type on the clipboard for the response we can make sure that it does not end up in clipboard managers and similar monitoring softwares.

Here is how I do it Talon side. https://github.com/AndreasArvidsson/andreas-talon/blob/e0c7c409b86981789b6152ee26e290fe625e804f/core/edit/edit.py#L158

Note that there are other mime types used on different platforms. Here is what I use in my clipboard manager: https://github.com/AndreasArvidsson/clippy/blob/12a9b4bf5a03a2224e055bc362966892594357fa/src/clipboard.ts#L10-L14

david-tejada commented 3 weeks ago

I guess it would also make sense to set it on the request, right? I understand that you use ExcludeClipboardContentFromMonitorProcessing because you are on Windows. I should probably have different MIME types based on the platform, right?

The issue with setting the MIME type on the response is that I can only make it for manifest v2 (Firefox) because I can use navigator.clipboard.write. For Chrome and Safari I need to use document.execCommand("copy"), so there's no way to change the MIME type.

AndreasArvidsson commented 3 weeks ago

Definitely. In my own fork I only I already set it on the request, but for the public release you definitely show do that Talon side as well.

Probably. I don't know if you should set multiple mime types or one specific per platform.

Annoying, but personally I would prefer to have it on firefox then no browsers. Fortunately for me I am on firefox :)

david-tejada commented 3 weeks ago

Can you set multiple mime types with Talon? It doesn't seem possible using navigator.clipboard.write.

AndreasArvidsson commented 3 weeks ago

Yes you can. If I can only set one then I suggest you pick one per platform.

david-tejada commented 3 weeks ago

Unfortunately navigator.clipboard.write only allows setting the mime type to "text/plain", "text/html" or "image/png". I will only be able to set the mime type on the request.

The mime types you use in your clipboard manager are for Windows and Mac. Are you aware of one for Linux?

AndreasArvidsson commented 3 weeks ago

Got it. That is unfortunate.

No

david-tejada commented 2 weeks ago

This doesn't work for me: mime["ExcludeClipboardContentFromMonitorProcessing"] = b"true"

I get the error TypeError: 'builtins.PyMimeData' object does not support item assignment

AndreasArvidsson commented 2 weeks ago

You need the latest version of Talon beta. Tested on windows and mac at least.

mime = clip.MimeData()
mime.text = text
mime["ExcludeClipboardContentFromMonitorProcessing"] = b"true"
clip.set_mime(mime)

https://github.com/AndreasArvidsson/andreas-talon/blob/f859f5609f7d1af959d3e66d364cf3bb46cbfba7/core/edit/edit.py#L154-L159

david-tejada commented 2 weeks ago

Makes sense. I don't use the beta. I will wait until this is supported in the public version to add it.

AndreasArvidsson commented 2 weeks ago

You can add it in a try catch then it will work for beta users without giving problems for public?