hexo-theme-stellar/layout/_partial/plugins/comments/beaudar/script.ejs

27 lines
762 B
Plaintext
Raw Normal View History

2021-07-23 12:10:24 +08:00
<script>
2021-07-23 23:44:25 +08:00
function loadBeaudar() {
const els = document.querySelectorAll("#comments #beaudar");
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://beaudar.lipk.org/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);
2021-07-23 12:10:24 +08:00
});
}
2021-07-23 23:44:25 +08:00
window.addEventListener('DOMContentLoaded', (event) => {
loadBeaudar();
});
2021-07-23 12:10:24 +08:00
</script>