27 lines
743 B
Plaintext
27 lines
743 B
Plaintext
|
<script>
|
||
|
function loadJS() {
|
||
|
const els = document.querySelectorAll("#comments #giscus");
|
||
|
if (els.length === 0) return;
|
||
|
els.forEach((el, i) => {
|
||
|
try {
|
||
|
el.innerHTML = '';
|
||
|
} catch (error) {
|
||
|
console.log(error);
|
||
|
}
|
||
|
var script = document.createElement('script');
|
||
|
script.src = 'https://giscus.app/client.js';
|
||
|
script.async = true;
|
||
|
for (let key of Object.keys(el.attributes)) {
|
||
|
let attr = el.attributes[key];
|
||
|
if (['class', 'id'].includes(attr.name) === false) {
|
||
|
script.setAttribute(attr.name, attr.value);
|
||
|
}
|
||
|
}
|
||
|
el.appendChild(script);
|
||
|
});
|
||
|
}
|
||
|
window.addEventListener('DOMContentLoaded', (event) => {
|
||
|
loadJS();
|
||
|
});
|
||
|
</script>
|