Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anonymize content and UI for screenshots #21921

Closed
MadLittleMods opened this issue Apr 25, 2022 · 1 comment
Closed

Anonymize content and UI for screenshots #21921

MadLittleMods opened this issue Apr 25, 2022 · 1 comment

Comments

@MadLittleMods
Copy link
Contributor

MadLittleMods commented Apr 25, 2022

Your use case

What would you like to do?

Anonymize content in Element with placeholder text blocks.

  • Text: color block it out
  • Images: Just filter: blur(4px); Or could use blurhash representations

Why would you like to do it?

When taking reproduction screenshots, it's pretty cumbersome to edit the DOM in order not to expose any private information. Or even more cumbersome and weird looking if you blur it out after the fact in photoshop.

I want realistic looking screenshots and often bugs occur in private rooms.

Using blur everywhere ruins the context and feel of the app.

How would you like to achieve it?

Here is the code I used for the mockup but it would probably better to customize the styles of some parts of the app to look better. Probably related to our skeleton UI styles already in place.

It would be great if it didn't require any additional markup. But in any case, it should be easily toggled on and off.

JavaScript to create screenshot mockup
function anonymizeContentInNode(node) {
  for (node = node.firstChild; node; node = node.nextSibling) {
    // Don't mangle styles
    if (node.tagName && ['style', 'script'].includes(node.tagName.toLowerCase())) {
        continue;
    }
    
    // Don't anonymize twice if this function is run more than once (while testing).
    // This is not related to the recursive nature of this function.
    if (node.classList && (node.classList.contains('anonymous-text-block') || node.classList.contains('anonymous-text-space'))) {
      continue;
    }
    
    // Only text nodes
    if (node.nodeType === 3) {
        // No need to touch empty nodes
        if (node.textContent.trim().length === 0) {
          continue;
        }

        const newNodes = [];
        const template = document.createElement('template');
        node.textContent.split(/\s/).map((textPiece) => {
            const html = `<span class="anonymous-text-block">${textPiece}</span><span class="anonymous-text-space"></span>`;
            template.innerHTML = html;
            newNodes.push(...template.content.childNodes);
        });
        node.replaceWith(...newNodes);
    } else {
        anonymizeContentInNode(node);
    }
  }
}

anonymizeContentInNode(document.querySelector('.mx_RoomView_MessageList'));

// Add some CSS styles
document.body.insertAdjacentHTML('beforeend', `
<style>
.anonymous-text-block {
    background-color: currentColor;
    opacity: 0.65;
    border-radius: 4px;
}

.anonymous-text-space:after {
    content: ' ';
}

img {
  filter: blur(4px);
}
</style>
`);

Have you considered any alternatives?

No response

Additional context

Similar to the code syntax minimap styles you would see in a code editor (VSCode, Atom, Sublime):

Or placeholder content before a SPA hydrates with real content.

What are the keywords to find this kind of thing?

Here is what the skeleton UI looks like in Element:


  • blurhash for text
  • blacked-out redacted text
  • skeleton UI
@t3chguy
Copy link
Member

t3chguy commented Apr 25, 2022

Duplicate of #9615

@t3chguy t3chguy marked this as a duplicate of #9615 Apr 25, 2022
@t3chguy t3chguy closed this as completed Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants