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

Anonymized screenshots - Lorem Ipsemifier - dummy text #9615

Open
lampholder opened this issue May 2, 2019 · 5 comments
Open

Anonymized screenshots - Lorem Ipsemifier - dummy text #9615

lampholder opened this issue May 2, 2019 · 5 comments
Labels
A-DevTools /devtools, show hidden events, etc. O-Uncommon Most users are unlikely to come across this or unexpected workflow T-Enhancement

Comments

@lampholder
Copy link
Member

A devtools tool to temporarily switch all message text with lorem ipsum (plus generated avatars and display names) so that people can submit anonymised screen captures that don't look like a blurry disaster.

@t3chguy t3chguy added the A-DevTools /devtools, show hidden events, etc. label Mar 5, 2021
@MadLittleMods MadLittleMods changed the title Lorem Ipsemifier Lorem Ipsemifier - dummy text Sep 2, 2021
@MadLittleMods
Copy link
Contributor

MadLittleMods commented Apr 25, 2022

To add some keywords:

  • Anonymize content and UI for screenshots
  • color block font/text
  • blurhash for text
  • blacked-out redacted text (like a CIA document, classified)
  • censored text
  • code editor minimap styles (VSCode, Atom, Sublime)
  • skeleton UI

Screenshot mockup:

https://codepen.io/MadLittleMods/pen/VwyJEOE

You can also see a video demo of this in action: https://youtu.be/n78tHoCx1es?t=252

JavaScript to create screenshot mockup
// Wraps every text node with `span.anonymous-text-block` which can
// be styled to make all text into color blocks to anonymize it.
function anonymizeContentInNode(node) {
  // This is just nested here to make it easy to copy-paste a single function
  const template = document.createElement('template');
  function createNodesFromHtml(html) {
    template.innerHTML = html;
    return template.content.childNodes;
  }
  
  // Loop through each child in the given node
  let nextSibling;
  for (node = node.firstChild; node; node = nextSibling) {
    // Record this before we potentially replace the node below and it will lose its siblings
    // and seems to freeze the browser.
    nextSibling = node.nextSibling;
    
    // Don't mangle styles and scripts
    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')) {
      continue;
    }

    // Only text nodes
    if (node.nodeType === 3) {
        const newNodes = [];
        // Split the text by whitespace
        [...node.textContent.matchAll(/(\s*)(\S*)(\s*)/g)].forEach(([_, padStart, text, padEnd]) => {
          // Ensure the white-space is maintained
          newNodes.push(...createNodesFromHtml(padStart));

          // No need to touch empty nodes
          if (text.length !== 0) {
            const html = `<span class="anonymous-text-block">${text}</span>`;
            newNodes.push(...createNodesFromHtml(html));
          }
      
          // Ensure the white-space is maintained
          newNodes.push(...createNodesFromHtml(padEnd));
        });
        
        // Replace the text node with our wrapped text that we can style with CSS
        node.replaceWith(...newNodes);
    } else {
        // Recursively call for each element
        anonymizeContentInNode(node);
    }
  }
}
anonymizeContentInNode(document.querySelector('body'));

// Add some CSS styles
document.body.insertAdjacentHTML('beforeend', `
<style>
.should-anonymize .anonymous-text-block {
  overflow: hidden;
  display: inline-block;
  height: 1ex;
  margin-top: calc((1em - 1ex) / 2);

  background-color: currentColor;
  opacity: 0.65;
  border-radius: 4px;
}

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

document.body.classList.add('should-anonymize');

Right now it’s a general script that runs on any page and replaces all text nodes on the page. But we don’t need to replace all text nodes. The normal strings in the UI aren’t sensitive. We only need to apply this to user-generated content that is sensitive like messages, room names, and things like IP’s and keys in the settings, etc. So this could benefit from some deeper integration in Element itself.


Probably related to the skeleton UI (placeholder content before a SPA hydrates with real content) styles we already have in place:

Another example is the code syntax minimap styles you would see in a code editor (VSCode, Atom, Sublime):


When in this mode, it would also be interesting to add some event_id labels in the corner of each messages for better debugging. Possibly room_id's as well for the room list. That way you can easily correlate the logs to the screenshot.

@SimonBrandner SimonBrandner added the O-Uncommon Most users are unlikely to come across this or unexpected workflow label Apr 29, 2022
@MadLittleMods MadLittleMods changed the title Lorem Ipsemifier - dummy text Anonymized screenshots - Lorem Ipsemifier - dummy text May 4, 2022
@JokerGermany

This comment was marked as off-topic.

@JokerGermany

This comment was marked as off-topic.

@JokerGermany

This comment was marked as off-topic.

@MadLittleMods
Copy link
Contributor

MadLittleMods commented May 6, 2022

@JokerGermany This is very noisy and this issue is not really the place to nitpick the proof of concept (obviously not perfect and just made to craft a screenshot to show what's possible). Probably best to chat in https://matrix.to/#/#element-web:matrix.org and you can also see people sharing concerns when I first posted it in the TWIM room.

The JavaScript snippet, simply color blocks all text currently on the page. If the page updates in any way, that text won't also be obscured. Details on the design can change in any way when we actually implement something (it's not even designed atm, just me as a developer).

To unblur stuff, you will need to refresh the page.

su-ex added a commit to SchildiChat/element-web that referenced this issue Dec 6, 2022
* Further improve replies ([\element-hq#6396](matrix-org/matrix-react-sdk#6396)). Fixes element-hq#19074, element-hq#18194 element-hq#18027 and element-hq#19179.
* Enable users to join group calls from multiple devices ([\element-hq#9625](matrix-org/matrix-react-sdk#9625)).
* fix(visual): make cursor a pointer for summaries ([\element-hq#9419](matrix-org/matrix-react-sdk#9419)). Contributed by @r00ster91.
* Add placeholder for rich text editor ([\element-hq#9613](matrix-org/matrix-react-sdk#9613)).
* Consolidate public room search experience ([\element-hq#9605](matrix-org/matrix-react-sdk#9605)). Fixes element-hq#22846.
* New password reset flow ([\element-hq#9581](matrix-org/matrix-react-sdk#9581)). Fixes element-hq#23131.
* Device manager - add tooltip to device details toggle ([\#9594](matrix-org/matrix-react-sdk#9594)).
* sliding sync: add lazy-loading member support ([\element-hq#9530](matrix-org/matrix-react-sdk#9530)).
* Limit formatting bar offset to top of composer ([\element-hq#9365](matrix-org/matrix-react-sdk#9365)). Fixes element-hq#12359. Contributed by @owi92.
* Fix issues around up arrow event edit shortcut ([\element-hq#9645](matrix-org/matrix-react-sdk#9645)). Fixes element-hq#18497 and element-hq#18964.
* Fix search not being cleared when clicking on a result ([\element-hq#9635](matrix-org/matrix-react-sdk#9635)). Fixes element-hq#23845.
* Fix screensharing in 1:1 calls ([\element-hq#9612](matrix-org/matrix-react-sdk#9612)). Fixes element-hq#23808.
* Fix the background color flashing when joining a call ([\element-hq#9640](matrix-org/matrix-react-sdk#9640)).
* Fix the size of the 'Private space' icon ([\element-hq#9638](matrix-org/matrix-react-sdk#9638)).
* Fix reply editing in rich text editor (https ([\element-hq#9615](matrix-org/matrix-react-sdk#9615)).
* Fix thread list jumping back down while scrolling ([\element-hq#9606](matrix-org/matrix-react-sdk#9606)). Fixes element-hq#23727.
* Fix regression with TimelinePanel props updates not taking effect ([\element-hq#9608](matrix-org/matrix-react-sdk#9608)). Fixes element-hq#23794.
* Fix form tooltip positioning ([\element-hq#9598](matrix-org/matrix-react-sdk#9598)). Fixes element-hq#22861.
* Extract Search handling from RoomView into its own Component ([\element-hq#9574](matrix-org/matrix-react-sdk#9574)). Fixes element-hq#498.
* Fix call splitbrains when switching between rooms ([\element-hq#9692](matrix-org/matrix-react-sdk#9692)).
* [Backport staging] Fix replies to emotes not showing as inline ([\element-hq#9708](matrix-org/matrix-react-sdk#9708)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-DevTools /devtools, show hidden events, etc. O-Uncommon Most users are unlikely to come across this or unexpected workflow T-Enhancement
Projects
None yet
Development

No branches or pull requests

6 participants