├── .gitignore ├── b2.webp ├── 48x48.png ├── README.md ├── hideTwitterDMDrawer.js ├── manifest.json ├── LICENSE └── hideEmailAddresses.js /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /b2.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ykdojo/StreamSafe/HEAD/b2.webp -------------------------------------------------------------------------------- /48x48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ykdojo/StreamSafe/HEAD/48x48.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # StreamSafe 2 | 3 | This is part of our suite of open source tools for streamers called [OpenStream](https://github.com/ykdojo/OpenStream/). 4 | 5 | (This README is work in progress...) 6 | -------------------------------------------------------------------------------- /hideTwitterDMDrawer.js: -------------------------------------------------------------------------------- 1 | var style = document.createElement('style'); 2 | style.type = 'text/css'; 3 | style.innerHTML = '[data-testid="DMDrawer"] { display: none !important; }'; 4 | document.head.appendChild(style); -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | "name": "StreamSafe", 4 | "version": "1.0", 5 | "description": "Helps streamers hide sensitive information", 6 | "permissions": [ 7 | ], 8 | "icons_commented_out": { 9 | "48": "48x48.png" 10 | }, 11 | "browser_action": { 12 | "default_title": "Pop out Twitch chat" 13 | }, 14 | "content_scripts": [ 15 | { 16 | "matches": [ "" ], 17 | "js": ["hideEmailAddresses.js"] 18 | }, 19 | { 20 | "matches": [ "https://twitter.com/*" ], 21 | "js": ["hideTwitterDMDrawer.js"] 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 YK Sugi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /hideEmailAddresses.js: -------------------------------------------------------------------------------- 1 | function blurContentContainingEmails(root = document.body) { 2 | const emailRegex = /[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}/; 3 | 4 | // Function to blur elements based on the presence of an email address 5 | const blurElementIfContainsEmail = (element) => { 6 | if (emailRegex.test(element.nodeValue || element.value)) { 7 | element.parentNode.style.filter = "blur(7px)"; 8 | } 9 | }; 10 | 11 | // Use TreeWalker to handle general content 12 | const filter = { 13 | acceptNode: function(node) { 14 | return emailRegex.test(node.nodeValue) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP; 15 | } 16 | }; 17 | 18 | const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, filter, false); 19 | let node; 20 | while (node = walker.nextNode()) { 21 | blurElementIfContainsEmail(node); 22 | } 23 | 24 | // Directly handle input elements 25 | const inputs = root.querySelectorAll("input[type='email'], input[type='password'], input[type='text']"); 26 | inputs.forEach(input => { 27 | // For "text" inputs, check if the value matches the email pattern 28 | if (input.type === "text" && emailRegex.test(input.value)) { 29 | input.style.filter = "blur(7px)"; 30 | } else if (input.type !== "text") { // For "email" and "password" inputs, blur directly 31 | input.style.filter = "blur(7px)"; 32 | } 33 | }); 34 | } 35 | 36 | // Enhanced usage 37 | blurContentContainingEmails(); // Initial call for the main document 38 | 39 | // Function to handle dynamic content like popups 40 | function handleDynamicContent() { 41 | // Example: Re-run blur function after a popup is opened. 42 | const observer = new MutationObserver((mutations) => { 43 | mutations.forEach((mutation) => { 44 | if (mutation.addedNodes.length) { 45 | mutation.addedNodes.forEach((node) => { 46 | blurContentContainingEmails(node); 47 | }); 48 | } 49 | // Check if attributes or characterData have changed 50 | if (mutation.type === 'attributes' || mutation.type === 'characterData') { 51 | const target = mutation.target; 52 | // For characterData changes, target is the text node itself 53 | // For attribute changes, target is the element with the changed attribute 54 | blurContentContainingEmails(target.nodeType === Node.TEXT_NODE ? target.parentNode : target); 55 | } 56 | }); 57 | }); 58 | 59 | observer.observe(document.body, { 60 | childList: true, 61 | subtree: true 62 | }); 63 | } 64 | 65 | handleDynamicContent(); // Listen for dynamic content like popups --------------------------------------------------------------------------------