hluk / copyq-commands

Useful commands for CopyQ clipboard manager.
331 stars 73 forks source link

Blacklisting passwords when Copy Clipboard to Window Tabs is enabled #27

Closed joshl129 closed 2 years ago

joshl129 commented 4 years ago

Hi, I am very much a layperson when it comes to programming, so apologies for my ignorance/inability to help myself. I started using the command Copy Clipboard to Window Tabs, but then I wanted to blacklist passwords copied in my password manager. I found this approach, but one issue intersecting with the Window Tabs command is that it deletes the pw only from &clipboard -- not also "Windows/Mozilla Firefox" or "Windows/Bitwarden". I realize it's probably just a matter of duplicating the code and replacing "Clipboard" with the names of the two windows I'm also trying to delete copy's from, but I'm not sure which instances I need to replace and which I need to keep. Could you please advise?

hluk commented 4 years ago

Ah, I think you would need to replace lines with function removeItemHash(...) { ... } with this code:

function removeItemHashFromTab(hash, tabName) {
  tab(tabName)
  for (var i = 2; i >= 0; --i) {
    var text = read(mimeText, i)
    if ( hash == calculateTextHash(text) )
      remove(i)
  }
}

function removeItemHash(hash) {
  tabs = tab()
  for (var i in tabs) {
    tabName = tabs[i]
    removeItemHashFromTab(hash, tabName)
  }
}

Depending on how many big tabs you have, it could be fast or slow.

NA0341 commented 2 years ago

much simpler ways: -» command that discards every copied item that has password characteristics before it even gets stored -» command that discards everything copied from specific programs

akoppa commented 2 years ago

NA0341 "much simpler ways: -» command that discards every copied item that has password characteristics before it even gets stored" I second this. Will be very useful if automatically the password is deleted at Windows Shutdown, LogOff, Change User, Sleep etc. except Restart.

hluk commented 2 years ago

-» command that discards every copied item that has password characteristics before it even gets stored

Please open a new pull request or an issue, if you have specific ideas ("password characteristic" is too vague/broad term).

-» command that discards everything copied from specific programs

This can be already handled somewhat by window title filtering: https://copyq.readthedocs.io/en/latest/faq.html#how-to-omit-storing-text-copied-from-specific-windows-like-a-password-manager