Created
May 18, 2021 16:21
-
-
Save badursun/3e734868c5dcbced2ad100cf4425a416 to your computer and use it in GitHub Desktop.
tawk.to Dynamicli Script Remove Re-Init
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
var scriptAdded = false; | |
function TawkRun(RunCode){ | |
console.log('RunCode:', RunCode); | |
if(scriptAdded==true && window.Tawk_API !== undefined && typeof window.Tawk_API.hideWidget === 'function'){ | |
window.Tawk_API.hideWidget(); | |
} | |
const scripts = document.getElementsByTagName('script'); | |
for (let i = 0; i < scripts.length; i++) { | |
const tag = scripts[i]; | |
if (tag.getAttribute('tawk') === 'yes') { | |
tag.parentNode.removeChild(tag); | |
} | |
} | |
for (const name in window) { | |
if(window.hasOwnProperty(name) && (name.includes('tawk') || name.includes('Tawk'))){ | |
delete window[name]; | |
} | |
} | |
window.Tawk_API = {}; | |
window.Tawk_LoadStart = new Date(); | |
(function() { | |
const s1 = document.createElement('script'), | |
s0 = document.getElementsByTagName('script')[0]; | |
s1.async = true; | |
s1.src = 'https://embed.tawk.to/'+ RunCode +''; | |
s1.charset = 'UTF-8'; | |
s1.setAttribute('crossorigin', '*'); | |
s1.setAttribute('tawk', 'yes'); | |
s0.parentNode.insertBefore(s1, s0); | |
})(); | |
scriptAdded=true; | |
Tawk_API.onLoad = function(){ | |
Tawk_API.toggle(); | |
}; | |
} | |
TawkRun('xxa3bb3ab1d6182476b9fexx/xxdvp95qxx'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment