This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2022-04-06 04:52:14 -07:00
|
|
|
<template>
|
|
|
|
<span>
|
2022-04-24 02:09:46 -07:00
|
|
|
<span ref="original" v-show="!$isGranted('users') || !hasSus">
|
2022-04-06 04:52:14 -07:00
|
|
|
<slot ref="original"></slot>
|
|
|
|
</span>
|
2022-04-24 02:09:46 -07:00
|
|
|
<span ref="marked" v-show="$isGranted('users') && hasSus"></span>
|
2022-04-06 04:52:14 -07:00
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
moderation: null,
|
2022-04-24 02:09:46 -07:00
|
|
|
hasSus: false,
|
2022-04-06 04:52:14 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
async mounted() {
|
|
|
|
if (!this.$isGranted('users')) { return; }
|
|
|
|
this.moderation = await this.$axios.$get(`/admin/moderation`);
|
|
|
|
|
|
|
|
this.update();
|
|
|
|
|
|
|
|
const observer = new MutationObserver(this.update);
|
|
|
|
observer.observe(this.$refs.original, {
|
|
|
|
childList: true,
|
|
|
|
subtree: true
|
|
|
|
});
|
|
|
|
this.observer = observer;
|
|
|
|
},
|
|
|
|
beforeUnmount() {
|
|
|
|
this.observer.disconnect();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
update() {
|
|
|
|
if (!this.moderation) { return; }
|
|
|
|
|
|
|
|
let html = this.$refs.original.innerHTML;
|
|
|
|
for (let sus of this.moderation.susRegexes) {
|
2022-04-24 02:09:46 -07:00
|
|
|
html = html.replace(new RegExp(sus, 'gi'), m => {
|
|
|
|
this.hasSus = true;
|
|
|
|
return `<mark>${m}</mark>`;
|
|
|
|
});
|
2022-04-06 04:52:14 -07:00
|
|
|
}
|
|
|
|
this.$refs.marked.innerHTML = html;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|