hexo-theme-stellar/layout/_partial/comments/giscus/script.ejs

23 lines
654 B
Plaintext
Raw Normal View History

2022-08-28 19:54:34 +08:00
<script>
2024-02-12 23:07:56 +08:00
window.addEventListener('DOMContentLoaded', (event) => {
2022-08-28 19:54:34 +08:00
const els = document.querySelectorAll("#comments #giscus");
if (els.length === 0) return;
els.forEach((el, i) => {
try {
el.innerHTML = '';
} catch (error) {
2023-12-06 13:22:07 +08:00
console.error(error);
2022-08-28 19:54:34 +08:00
}
var script = document.createElement('script');
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);
});
});
</script>