Redacting each character in a selection

How would you create an extension that replaces each character in a selection with a special character, perhaps a ▬? Doing so would redact the selected text, while maintaining the same length. Spaces could be replaced as well so that it isn’t necessary to treat them separately.

Examples:

Redact the word Popclip from this sentence.
Redact the word ▬ ▬ ▬ ▬ ▬ ▬ ▬ from this sentence.

Redact the next word from this sentence.
Redact the next ▬ ▬ ▬ ▬ from this sentence.

Redact the next three words from this sentence.
Redact the next ▬ ▬ ▬ ▬ ▬ ▬ ▬ ▬ ▬ ▬ ▬ ▬ ▬ ▬ ▬ ▬ this sentence.

This ought to do it:

// #popclip
// name: Redact
// language: javascript
// after: paste-result
return "▬".repeat(popclip.input.text.length)

(The above block is an extension snippet — select it then click “Install Extension” in PopClip.)

1 Like

Wonderful!

1 Like