-
Notifications
You must be signed in to change notification settings - Fork 30
/
deadname-remover.require.js
5 lines (5 loc) · 3.5 KB
/
deadname-remover.require.js
1
2
3
4
5
const DeadnameRemover = (() => {
const x = Object.defineProperty; const D = (e) => x(e, '__esModule', { value: !0 }); const O = (e, t) => () => (t || (t = { exports: {} }, e(t.exports, t)), t.exports); const C = (e, t) => { D(e); for (const r in t)x(e, r, { get: t[r], enumerable: !0 }); }; const A = O((H) => { C(H, { start: () => S }); const h = new Map(); let p = null; let s = null; let a = null; let l = []; let i = []; let c = !1; let g; function S(e = y) { if (U(), !e.enabled) return; g = e.highlight, s = e.name, a = e.deadname, W(), E(); } function U() { if (l.length === 0 || i.length === 0) return; p && p.disconnect(), c = !0, [l, i] = [i, l], E(), [l, i] = [i, l], c = !1, h.clear(); } function W() { l = [], i = []; const e = !!s.first; const t = !!s.middle; const r = !!s.last; for (let n = 0, d = a.length; n < d; n++) { const m = !!a[n].first; const f = !!a[n].middle; const u = !!a[n].last; if (e && m && t && f && r && u) { const o = `${s.first} ${s.middle} ${s.last}`; const T = `${a[n].first} ${a[n].middle} ${a[n].last}`; l.push(o), i.push(T); }e && m && (l.push(s.first), i.push(a[n].first)), f && (l.push(t ? s.middle : ''), i.push(a[n].middle)), r && u && (l.push(s.last), i.push(a[n].last)), e && m && r && u && (l.push(s.first + s.last), i.push(a[n].first + a[n].last)); } } const M = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_'; function w(e, t) { let r = 0; let n; let d; const m = (o, T) => n = e.toLowerCase().indexOf(o, T); const f = (o) => { for (n = m(i[r], o); n === -1;) { if (r + 1 === i.length) return !1; r++, n = m(i[r]); } return !0; }; i = i.map((o) => o.toLowerCase()), g && !t && (c || (l = (c ? i : l).map((o) => `<mark replaced="">${o}</mark>`))); const u = i.map((o) => o.length); for (;f(d);)d = n + u[r], M.indexOf(e[d]) === -1 && M.indexOf(e[n - 1]) === -1 && (e = e.substring(0, n) + l[r] + e.substring(d)); return e; } function N(e) { if (!e || !c && e.replaced) return; if (c) { if (g) { const t = h.get(e.innerHTML); t && (e.innerHTML = t.toString()); } else { const t = h.get(e.nodeValue); t && (e.parentElement && e.parentElement.replaceChild(document.createTextNode(t.toString()), e)); } return; } if (e.nodeType === 3) { const t = e.nodeValue; let r = e.nodeValue; r = w(r), r !== t && (h.set(r, t), e.parentElement && (e.parentElement.innerHTML = r)); } else if (e.hasChildNodes()) for (let t = 0, r = e.childNodes.length; t < r; t++)N(e.childNodes[t]); } function I() { p = new MutationObserver((e) => { for (let t = 0, r = e.length; t < r; t++) { const n = e[t]; n.type === 'childList' && n.addedNodes.forEach((d) => { N(d); }); } }), p.observe(document, { childList: !0, subtree: !0 }); } function R() { if (c && g) { const r = document.body.querySelectorAll('mark[replaced]'); for (let n = 0, d = r.length; n < d; n++)N(r[n].parentElement); } const e = document.createNodeIterator(document.body, NodeFilter.SHOW_TEXT); let t; for (;t = e.nextNode();)N(t); !c && I(); } function E() { document.title = w(document.title, !0), v(() => R()); } }); const y = {
name: { first: '', middle: '', last: '' }, deadname: [{ first: '', middle: '', last: '' }], enabled: !0, stealthMode: !1, highlight: !1,
}; function b() { return document.readyState === 'complete' || document.readyState === 'interactive'; } const L = new Set(); function F(e) { L.add(e); } const v = (e) => { b() ? e() : F(e); }; if (!b()) { const e = () => { b() && (document.removeEventListener('readystatechange', e), L.forEach((t) => t()), L.clear()); }; document.addEventListener('readystatechange', e); } return A();
})();