Created
March 24, 2024 08:13
-
-
Save Pudochu/e2ed9df335ee55dc5231da7217f48a4b to your computer and use it in GitHub Desktop.
[NEW] Remove Tawk.to Branding (2024)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This function is used to remove specific branding elements. | |
| function removeBranding() { | |
| // Select the iframe and access its content. | |
| var iframe = document.querySelector("iframe[title*='chat']"); | |
| if (iframe && iframe.contentDocument) { | |
| var iframeDocument = iframe.contentDocument; | |
| // Create a new style tag. | |
| var style = document.createElement('style'); | |
| style.innerHTML = ` | |
| a[class*='tawk-button-small'], a[class*='tawk-branding'] { | |
| display: none !important; | |
| } | |
| `; | |
| // Append the style tag to the head of the iframe. | |
| iframeDocument.head.appendChild(style); | |
| } | |
| } | |
| // Create a MutationObserver to monitor DOM changes. | |
| var observer = new MutationObserver(function(mutations) { | |
| mutations.forEach(function(mutation) { | |
| if (mutation.addedNodes.length) { | |
| removeBranding(); | |
| } | |
| }); | |
| }); | |
| // Attach the observer to a target and specify the configuration options. | |
| observer.observe(document.body, { | |
| childList: true, | |
| subtree: true | |
| }); | |
| // Call the remove branding function for the initial load. | |
| removeBranding(); |
Author
sorry to ask, but where do I put the file in the module section or?
For example, on html:
<script>
write those codes here
</script>or write the codes at the bottom of any JavaScript file on your site
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sorry to ask, but where do I put the file in the module section or?