Skip to content

Instantly share code, notes, and snippets.

@Pudochu
Created March 24, 2024 08:13
Show Gist options
  • Select an option

  • Save Pudochu/e2ed9df335ee55dc5231da7217f48a4b to your computer and use it in GitHub Desktop.

Select an option

Save Pudochu/e2ed9df335ee55dc5231da7217f48a4b to your computer and use it in GitHub Desktop.
[NEW] Remove Tawk.to Branding (2024)
// 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();
@TheEnglishGartner
Copy link

sorry to ask, but where do I put the file in the module section or?

@Pudochu
Copy link
Author

Pudochu commented Jun 7, 2024

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