function initFeedcheckWidgets() {
let container = document.getElementById("feedcheck-widget-53");
container.innerHTML = `
`;
/*
We discovered that if we add an HTML with script tags in it,
the scripts from those tags are not executed and this is the reason for the following approach
*/
function nodeScriptClone(node){
// create a script element and sets it's text to old script innerHTML
var script = document.createElement("script");
script.text = node.innerHTML;
// set it's attributes
var i = -1, attrs = node.attributes, attr;
while ( ++i < attrs.length ) {
script.setAttribute( (attr = attrs[i]).name, attr.value );
}
return script;
}
// get all scripts from the page with the attribute data-source
let widgetScripts = container.querySelectorAll('[data-source="feedcheck"]')
//iterate through all the scripts and replace it with it's clone
for (let i = 0; i < widgetScripts.length; i++) {
let script = widgetScripts[i];
script.parentNode.replaceChild( nodeScriptClone(script) , script );
}
}
initFeedcheckWidgets();