Skip to content

Instantly share code, notes, and snippets.

@thebigredgeek
Last active June 25, 2020 17:27
Show Gist options
  • Save thebigredgeek/75bfe4c9319b7880b0e5f63e5e9d6b23 to your computer and use it in GitHub Desktop.
Save thebigredgeek/75bfe4c9319b7880b0e5f63e5e9d6b23 to your computer and use it in GitHub Desktop.
Remove TidioChat branding
(() => {
let iframeBody = null;
function purge (iframe) {
var timer = null;
var tdo = iframeBody.querySelector(`a.powered`);
if(!tdo || typeof tdo === 'undefined') {
if(timer !== null) {
clearTimeout(timer);
}
timer = setTimeout(purge, 10);
return;
}
tdo.remove();
}
function cb (mutationList) {
let chatDiv = iframeBody.querySelector('div.chat')
if (chatDiv) {
mutationList.some(item => {
if (item.type === 'childList' && item.addedNodes && item.addedNodes[0] === chatDiv) {
purge();
return true;
}
})
}
}
function bind () {
try {
iframeBody = document.querySelector('#tidio-chat iframe').contentWindow.document.body;
if (!iframeBody) {
return setTimeout(bind, 100) // wait and retry
}
const mutationObservable = new MutationObserver(cb);
setTimeout(() => {
purge();
mutationObservable.observe(iframeBody, { attributes: true, childList: true, subtree: true });
}, 100);
} catch (err) {}
}
bind();
})();
@Ajay3147
Copy link

Hello..

After adding the function to hide tidio logo in bot im unable to see URL links in conversations, Its hiding URL links after adding this code along with logo.....What i have to do plz help..

function hideTdo() {
var timer = null;
var target = document.querySelector("#tidio-chat iframe");
if (!target) {
if (timer !== null) {
clearTimeout(timer);
}
timer = setTimeout(hideTdo, 500);
return;
} else {
var timer2 = null;
var tdo = document
.querySelector("#tidio-chat iframe")
.contentDocument.querySelector("a[target=_blank]");
if (!tdo) {
if (timer2 !== null) {
clearTimeout(timer2);
}
timer2 = setTimeout(hideTdo, 1);
return;
}
document
.querySelector("#tidio-chat iframe")
.contentDocument.querySelector("a[target=_blank]")
.remove();
return true;
}
}

hideTdo();

setInterval(hideTdo, 10);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment