Skip to content

Instantly share code, notes, and snippets.

@jruels
Created May 30, 2020 19:21
Show Gist options
  • Save jruels/c38e4af806799dbfff67c30690a6c712 to your computer and use it in GitHub Desktop.
Save jruels/c38e4af806799dbfff67c30690a6c712 to your computer and use it in GitHub Desktop.
Profanity filter
!function(e){var t={};function i(s){if(t[s])return t[s].exports;var o=t[s]={i:s,l:!1,exports:{}};return e[s].call(o.exports,o,o.exports,i),o.l=!0,o.exports}i.m=e,i.c=t,i.d=function(e,t,s){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)i.d(s,o,function(t){return e[t]}.bind(null,o));return s},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=2)}([function(e,t,i){"use strict";function s(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class o{static allLowerCase(e){return e.toLowerCase()===e}static allUpperCase(e){return e.toUpperCase()===e}static capitalize(e){return e.charAt(0).toUpperCase()+e.substr(1)}static capitalized(e){return e.charAt(0).toUpperCase()===e.charAt(0)}static containsDoubleByte(e){return!!e.length&&(e.charCodeAt(0)>127||o._unicodeRegExp.test(e))}static escapeRegExp(e){return e.replace(o._escapeRegExp,"\\$&")}constructor(e,t,i){s(this,"_filterMethod",void 0),s(this,"escaped",void 0),s(this,"lists",void 0),s(this,"matchMethod",void 0),s(this,"matchRepeated",void 0),s(this,"matchSeparators",void 0),s(this,"regExp",void 0),s(this,"sub",void 0),s(this,"unicode",void 0),s(this,"value",void 0),this.value=e,this.lists=void 0===t.lists?[]:t.lists,this.matchMethod=void 0===t.matchMethod?i.defaultWordMatchMethod:t.matchMethod,this.matchRepeated=void 0===t.repeat?i.defaultWordRepeat:t.repeat,this.matchSeparators=void 0===t.separators?i.defaultWordSeparators:t.separators,this.sub=void 0===t.sub?i.defaultSubstitution:t.sub,this._filterMethod=void 0===t._filterMethod?i.filterMethod:t._filterMethod,this.unicode=o.containsDoubleByte(e),this.escaped=o.escapeRegExp(this.value),this.regExp=this.buildRegExp()}buildRegExp(){let e=this;try{switch(e.matchMethod){case 0:return 2===e._filterMethod?e.unicode?new RegExp("(^|"+o._unicodeWordBoundary+")("+e.processedPhrase()+")("+o._unicodeWordBoundary+"|$)",e.regexOptions()):e.hasEdgePunctuation()?new RegExp("(^|\\s)("+e.processedPhrase()+")(\\s|$)",e.regexOptions()):new RegExp("\\s?\\b"+e.processedPhrase()+"\\b\\s?",e.regexOptions()):e.unicode?new RegExp("(^|"+o._unicodeWordBoundary+"+)("+e.processedPhrase()+")("+o._unicodeWordBoundary+"+|$)",e.regexOptions()):e.hasEdgePunctuation()?new RegExp("(^|\\s)("+e.processedPhrase()+")(\\s|$)",e.regexOptions()):new RegExp("\\b"+e.processedPhrase()+"\\b",e.regexOptions());case 2:return e.unicode?new RegExp("(^|"+o._unicodeWordBoundary+"*)([\\S]*"+e.processedPhrase()+"[\\S]*)("+o._unicodeWordBoundary+"*|$)",e.regexOptions()):e.hasEdgePunctuation()?new RegExp("(^|\\s)([\\S]*"+e.processedPhrase()+"[\\S]*)(\\s|$)",e.regexOptions()):new RegExp("\\b[\\w-]*"+e.processedPhrase()+"[\\w-]*\\b",e.regexOptions());case 4:return new RegExp(e.value,e.regexOptions());case 1:default:return 2===e._filterMethod?e.unicode?new RegExp("(^|"+o._unicodeWordBoundary+"?)([\\w-]*"+e.processedPhrase()+"[\\w-]*)("+o._unicodeWordBoundary+"?|$)",e.regexOptions()):e.hasEdgePunctuation()?new RegExp("(^|\\s)([\\w-]*"+e.processedPhrase()+"[\\w-]*)(\\s|$)",e.regexOptions()):new RegExp("\\s?\\b[\\w-]*"+e.processedPhrase()+"[\\w-]*\\b\\s?",e.regexOptions()):new RegExp(e.processedPhrase(),e.regexOptions())}}catch(t){throw new Error('Failed to create RegExp for "'+e.value+'" - '+t.name+" "+t.message)}}hasEdgePunctuation(){return o._edgePunctuationRegExp.test(this.value)}processedPhrase(){let e=this,t=e.escaped.includes("\\"),i="",s=e.escaped.length-1;for(let r=0;r<e.escaped.length;r++)t&&"\\"===e.escaped[r]&&(i+=e.escaped[r],r++),i+=e.escaped[r],e.matchRepeated&&(i+="+"),e.matchSeparators&&r!=s&&(i+=o.separatorsRegExp);return i}regexOptions(){let e="gi";return this.unicode&&(e+="u"),e}}t.default=o,s(o,"_edgePunctuationRegExp",/(^[,.'"!?%$]|[,.'"!?%$]$)/),s(o,"_escapeRegExp",/[\/\\^$*+?.()|[\]{}]/g),s(o,"_unicodeRegExp",/[^\u0000-\u00ff]/),s(o,"_unicodeWordBoundary","[\\s.,'\"+!?|-]"),s(o,"nonWordRegExp",new RegExp("^\\s*[^\\w]+\\s*$","g")),s(o,"separatorsRegExp","[-_ ]*"),s(o,"whitespaceRegExp",/^\s+$/)},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s,o=(s=i(0))&&s.__esModule?s:{default:s};function r(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}t.default=class{constructor(e,t){r(this,"all",void 0),r(this,"list",void 0),r(this,"regExps",void 0);let i=this;this.all=[],this.list=[],this.regExps=[],Object.keys(e.words).sort((e,t)=>t.length-e.length).forEach(s=>{if(0===t||!Array.isArray(e.words[s].lists)||e.words[s].lists.includes(t)){i.list.push(s);let t=new o.default(s,e.words[s],e);i.all.push(t),i.regExps.push(t.regExp)}})}find(e){return"string"==typeof e?this.all[this.list.indexOf(e)]:"number"==typeof e?this.all[e]:void 0}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=l(i(3)),o=l(i(4)),r=l(i(5)),a=l(i(6)),n=l(i(8)),d=l(i(1));function l(e){return e&&e.__esModule?e:{default:e}}function u(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}i(10);let c={runtime:{}};c.runtime.sendMessage=function(e){};
/* @preserve - Start User Config */
let h={"audioWordlistId":0,"censorCharacter":"*","censorFixedLength":0,"customAudioSites":null,"defaultSubstitution":"censored","defaultWordMatchMethod":0,"defaultWordRepeat":false,"defaultWordSeparators":false,"domains":{},"enabledDomainsOnly":false,"filterMethod":1,"filterWordList":true,"iWordWhitelist":[],"muteAudio":true,"muteAudioOnly":true,"muteCueRequireShowing":true,"muteMethod":0,"password":null,"preserveCase":true,"preserveFirst":true,"preserveLast":false,"showCounter":true,"showSubtitles":0,"showSummary":true,"showUpdateNotification":true,"substitutionMark":false,"wordWhitelist":[],"wordlistId":0,"wordlists":["Wordlist 1","Wordlist 2","Wordlist 3","Wordlist 4","Wordlist 5","Wordlist 6"],"wordlistsEnabled":true,"words":{"ass":{"lists":[],"matchMethod":0,"repeat":true,"separators":false,"sub":"butt"},"asses":{"lists":[],"matchMethod":0,"repeat":false,"separators":false,"sub":"butts"},"asshole":{"lists":[],"matchMethod":1,"repeat":true,"separators":false,"sub":"jerk"},"badass":{"lists":[],"matchMethod":1,"repeat":true,"separators":true,"sub":"cool"},"bastard":{"lists":[],"matchMethod":1,"repeat":true,"separators":false,"sub":"idiot"},"bitch":{"lists":[],"matchMethod":1,"repeat":true,"separators":false,"sub":"bench"},"cocksucker":{"lists":[],"matchMethod":1,"repeat":true,"separators":true,"sub":"suckup"},"cunt":{"lists":[],"matchMethod":1,"repeat":true,"separators":false,"sub":"expletive"},"dammit":{"lists":[],"matchMethod":1,"repeat":false,"separators":true,"sub":"dangit"},"damn":{"lists":[],"matchMethod":1,"repeat":false,"separators":false,"sub":"dang"},"dumbass":{"lists":[],"matchMethod":1,"repeat":true,"separators":false,"sub":"idiot"},"fag":{"lists":[],"matchMethod":0,"repeat":true,"separators":false,"sub":"gay"},"faggot":{"lists":[],"matchMethod":1,"repeat":true,"separators":false,"sub":"gay"},"fags":{"lists":[],"matchMethod":0,"repeat":true,"separators":false,"sub":"gays"},"fuck":{"lists":[],"matchMethod":1,"repeat":true,"separators":true,"sub":"freak"},"goddammit":{"lists":[],"matchMethod":1,"repeat":true,"separators":true,"sub":"dangit"},"hell":{"lists":[],"matchMethod":0,"repeat":false,"separators":false,"sub":"heck"},"jackass":{"lists":[],"matchMethod":1,"repeat":true,"separators":true,"sub":"jerk"},"nigga":{"lists":[],"matchMethod":0,"repeat":true,"separators":false,"sub":"bruh"},"nigger":{"lists":[],"matchMethod":0,"repeat":true,"separators":false,"sub":"man"},"niggers":{"lists":[],"matchMethod":0,"repeat":true,"separators":false,"sub":"people"},"piss":{"lists":[],"matchMethod":1,"repeat":true,"separators":false,"sub":"pee"},"pissed":{"lists":[],"matchMethod":1,"repeat":true,"separators":false,"sub":"ticked"},"pussies":{"lists":[],"matchMethod":0,"repeat":true,"separators":false,"sub":"softies"},"pussy":{"lists":[],"matchMethod":0,"repeat":true,"separators":false,"sub":"softie"},"shit":{"lists":[],"matchMethod":1,"repeat":true,"separators":false,"sub":"crap"},"slut":{"lists":[],"matchMethod":1,"repeat":true,"separators":false,"sub":"tramp"},"tits":{"lists":[],"matchMethod":1,"repeat":true,"separators":false,"sub":"chest"},"twat":{"lists":[],"matchMethod":0,"repeat":true,"separators":false,"sub":"dumbo"},"twats":{"lists":[],"matchMethod":0,"repeat":true,"separators":false,"sub":"dumbos"},"whore":{"lists":[],"matchMethod":1,"repeat":true,"separators":false,"sub":"tramp"}},"youTubeAutoSubsMax":0,"youTubeAutoSubsMin":0}
/* @preserve - End User Config */
class p extends o.default{constructor(){super(),u(this,"advanced",void 0),u(this,"audio",void 0),u(this,"audioOnly",void 0),u(this,"audioWordlistId",void 0),u(this,"cfg",void 0),u(this,"domain",void 0),u(this,"hostname",void 0),u(this,"iframe",void 0),u(this,"location",void 0),u(this,"mutePage",void 0),u(this,"summary",void 0),this.advanced=!1,this.audioWordlistId=0,this.mutePage=!1,this.summary={}}advancedReplaceText(e,t,i=!0){g.wordlists[t].regExps.forEach(s=>{findAndReplaceDOMText(e,{preset:"prose",find:s,replace:function(e,s){return 0===e.index?g.replaceText(s[0],t,i):""}})})}checkMutationForProfanity(e){e.addedNodes.forEach(e=>{r.default.isForbiddenNode(e)||(g.mutePage?g.cleanAudio(e):g.audioOnly||g.cleanNodeText(e))}),g.mutePage&&g.audio.muted&&e.removedNodes.forEach(e=>{(!1!==g.audio.supportedNode(e)||e==g.audio.lastFilteredNode||g.audio.simpleUnmute&&g.audio.lastFilteredText&&g.audio.lastFilteredText.includes(e.textContent))&&g.audio.unmute()}),e.target&&"#text"===e.target.nodeName&&g.checkMutationTargetTextForProfanity(e)}checkMutationTargetTextForProfanity(e){if(!r.default.isForbiddenNode(e.target)){let t=!!g.mutePage&&g.audio.supportedNode(e.target);if(!1!==t&&g.audio.simpleUnmute)g.audio.muted&&e.oldValue&&g.audio.lastFilteredText&&g.audio.lastFilteredText.includes(e.oldValue)&&g.audio.unmute(),g.audio.clean(e.target,t);else if(g.mutePage&&g.audio.simpleUnmute&&g.audio.muted&&!e.target.parentElement)g.audio.lastFilteredText&&g.audio.lastFilteredText.includes(e.target.textContent)&&g.audio.unmute();else if(!g.audioOnly){let t=this.replaceTextResult(e.target.data,this.wordlistId);t.modified&&(e.target.data=t.filtered)}}}cleanAudio(e){if(g.audio.youTube&&g.audio.youTubeAutoSubsPresent())g.audio.youTubeAutoSubsSupportedNode(e)?g.audio.youTubeAutoSubsCurrentRow(e)?g.audio.cleanYouTubeAutoSubs(e):g.audioOnly||g.cleanNodeText(e):g.audioOnly||g.audio.youTubeAutoSubsNodeIsSubtitleText(e)||g.cleanNodeText(e);else{let t=g.audio.supportedNode(e);!1!==t?g.audio.clean(e,t):g.audioOnly||g.cleanNodeText(e)}}cleanNode(e,t=!0){if(r.default.isForbiddenNode(e))return!1;if(e.childElementCount>0){let i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;i.nextNode();)i.currentNode.childNodes.length>0?i.currentNode.childNodes.forEach(e=>{this.cleanNode(e,t)}):this.cleanNode(i.currentNode,t)}else if(e.nodeName)if(e.textContent&&""!=e.textContent.trim()){let i=this.replaceTextResult(e.textContent,this.wordlistId,t);i.modified&&(e.textContent=i.filtered)}else"IMG"==e.nodeName?(""!=e.alt&&(e.alt=this.replaceText(e.alt,this.wordlistId,t)),""!=e.title&&(e.title=this.replaceText(e.title,this.wordlistId,t))):null!=e.shadowRoot&&m.observe(e.shadowRoot,b)}cleanNodeText(e){g.advanced&&(e.parentNode||e===document)?g.advancedReplaceText(e,this.wordlistId,!0):g.cleanNode(e)}cleanPage(){this.cfg=new n.default(h),this.domain=s.default.byHostname(this.hostname,this.cfg.domains),this.cfg.muteMethod=1;let e={disabled:this.cfg.enabledDomainsOnly&&!this.domain.enabled||this.domain.disabled};if(e.disabled)return c.runtime.sendMessage(e),!1;this.domain.advanced&&(this.advanced=this.domain.advanced),void 0!==this.domain.wordlistId&&(this.wordlistId=this.domain.wordlistId),void 0!==this.domain.audioWordlistId&&(this.audioWordlistId=this.domain.audioWordlistId),this.cfg.muteAudio&&(this.audio=new a.default(this),this.mutePage=this.audio.supportedPage,this.mutePage&&this.cfg.wordlistsEnabled&&this.wordlistId!=this.audio.wordlistId&&(this.wordlists[this.audio.wordlistId]=new d.default(this.cfg,this.audio.wordlistId))),this.init(),this.audioOnly||this.cleanNodeText(document),f.observe(document,b)}processMutations(e){e.forEach((function(e){g.checkMutationForProfanity(e)}))}updateCounterBadge(){}}t.default=p;let f,m,g=new p,b={characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0};if("undefined"!=typeof window){if(f=new MutationObserver(g.processMutations),m=new MutationObserver(g.processMutations),window!=window.top){g.iframe=document.location;try{g.hostname=window.parent.location.hostname}catch(e){document.referrer?g.hostname=new URL(document.referrer).hostname:g.hostname=document.location.hostname}}else g.hostname=document.location.hostname;g.cleanPage()}},function(e,t,i){"use strict";function s(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class o{static byHostname(e,t){let i=o.findDomainKey(e,t)||e,s=o.byKey(i,t);return s.hostname=e,s}static byKey(e,t){return new o(e,t[e])}static findDomainKey(e,t){return Object.keys(t).sort((e,t)=>t.length-e.length).find(t=>new RegExp(`(^|.)${t}$`).test(e))}static getCurrentTab(){return new Promise((function(e,t){chrome.tabs.query({active:!0,currentWindow:!0},(function(t){e(t[0])}))}))}static sortedKeys(e){return Object.keys(e).sort((function(e,t){let i=e.match(/\w*\.\w*$/)[0],s=t.match(/\w*\.\w*$/)[0];return i<s?-1:i>s?1:0}))}constructor(e,t){s(this,"advanced",void 0),s(this,"audioWordlistId",void 0),s(this,"cfg",void 0),s(this,"cfgKey",void 0),s(this,"disabled",void 0),s(this,"enabled",void 0),s(this,"hostname",void 0),s(this,"tab",void 0),s(this,"wordlistId",void 0),this.cfgKey=e,this.cfg={},t?this.cfg=t:Object.assign(this.cfg,o._domainCfgDefaults),this.updateFromCfg()}async save(e){if(e.domains)return this.updateCfg(),"{}"===JSON.stringify(this.cfg)?delete e.domains[this.cfgKey]:e.domains[this.cfgKey]=this.cfg,await e.save("domains")}updateCfg(){this.cfg.adv=!0===this.advanced||void 0,this.cfg.disabled=!0===this.disabled||void 0,this.cfg.enabled=!0===this.enabled||void 0,this.cfg.wordlist=this.wordlistId>=0?this.wordlistId:void 0,this.cfg.audioList=this.audioWordlistId>=0?this.audioWordlistId:void 0}updateFromCfg(){this.advanced=this.cfg.adv,this.disabled=this.cfg.disabled,this.enabled=this.cfg.enabled,this.wordlistId=this.cfg.wordlist,this.audioWordlistId=this.cfg.audioList}}t.default=o,s(o,"_domainCfgDefaults",{adv:void 0,audioList:void 0,disabled:void 0,enabled:void 0,wordlist:void 0})},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=r(i(0)),o=r(i(1));function r(e){return e&&e.__esModule?e:{default:e}}function a(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}t.default=class{constructor(){a(this,"cfg",void 0),a(this,"counter",void 0),a(this,"iWhitelist",void 0),a(this,"whitelist",void 0),a(this,"wordlistId",void 0),a(this,"wordlists",void 0),this.counter=0,this.iWhitelist=[],this.whitelist=[],this.wordlists={}}buildWordlist(e,t=!1){return!1===e&&(e=this.wordlistId),!t&&this.wordlists[e]||(this.wordlists[e]=new o.default(this.cfg,e)),e}checkWhitelist(e,t,i,o,r){let a=this,n=a.whitelist.length,d=a.iWhitelist.length;if(n||d){if(n&&a.whitelist.includes(e))return!0;if(d&&a.iWhitelist.includes(e.toLowerCase()))return!0;if(1===this.wordlists[r].find(o).matchMethod){let o,r={matchMethod:2,repeat:!1,separators:!1,sub:""},l=new s.default(e,r,this.cfg).regExp;for(;null!==(o=l.exec(t));){let t=4==o.length?o[2]:o[0],s=4==o.length?o.index+o[1].length:o.index;if(s<=i&&s+t.length>=i+e.length){if(n&&a.whitelist.includes(t))return!0;if(d&&a.iWhitelist.includes(t.toLowerCase()))return!0}}}}return!1}foundMatch(e){this.counter++}init(e=!1){this.iWhitelist=this.cfg.iWordWhitelist,this.whitelist=this.cfg.wordWhitelist,void 0===this.wordlistId&&(this.wordlistId=null==this.cfg.wordlistId?0:this.cfg.wordlistId),this.buildWordlist(e)}rebuildWordlists(){let e=this;Object.keys(this.wordlists).forEach((function(t){e.buildWordlist(parseInt(t),!0)}))}replaceText(e,t=!1,i=!0){let o=this;t=o.buildWordlist(t);let r=o.wordlists[t].regExps,a=o.wordlists[t].list;switch(o.cfg.filterMethod){case 0:r.forEach((s,r)=>{e=e.replace(s,(function(e,...s){let n=s.pop(),d=s.pop(),l=s,u=l.length>0;if(u&&(e=l[1]),o.checkWhitelist(e,n,d,r,t))return e;i&&o.foundMatch(a[r]);let c="",h=o.cfg.censorFixedLength>0?o.cfg.censorFixedLength:e.length;return c=o.cfg.preserveFirst&&o.cfg.preserveLast?e[0]+o.cfg.censorCharacter.repeat(h-2)+e.slice(-1):o.cfg.preserveFirst?e[0]+o.cfg.censorCharacter.repeat(h-1):o.cfg.preserveLast?o.cfg.censorCharacter.repeat(h-1)+e.slice(-1):o.cfg.censorCharacter.repeat(h),u&&(c=l[0]+c+l[2]),c}))});break;case 1:r.forEach((r,n)=>{e=e.replace(r,(function(e,...r){let d=r.pop(),l=r.pop(),u=r,c=u.length>0;if(c&&(e=u[1]),o.checkWhitelist(e,d,l,n,t))return e;i&&o.foundMatch(a[n]);let h=o.cfg.words[a[n]].sub||o.cfg.defaultSubstitution;return o.cfg.preserveCase&&(s.default.allUpperCase(e)?h=h.toUpperCase():s.default.capitalized(e)&&(h=s.default.capitalize(h))),o.cfg.substitutionMark&&(h="["+h+"]"),c&&(h=u[0]+h+u[2]),h}))});break;case 2:r.forEach((r,n)=>{e=e.replace(r,(function(e,...r){let d=r.pop(),l=r.pop(),u=r,c=u.length>0;return c&&(e=u[1]),o.checkWhitelist(e.trim(),d,l,n,t)?e:(i&&o.foundMatch(a[n]),c?(e=u[1],s.default.whitespaceRegExp.test(u[0])&&s.default.whitespaceRegExp.test(u[2])?u[0]:s.default.nonWordRegExp.test(u[0])||s.default.nonWordRegExp.test(u[2])?(u[0]+u[2]).trim():""):s.default.whitespaceRegExp.test(e[0])&&s.default.whitespaceRegExp.test(e[e.length-1])?e[0]:"")}))})}return e}replaceTextResult(e,t=!1,i=!0){let s={original:e,filtered:this.replaceText(e,t,i),modified:!1};return s.modified=s.filtered!=e,s}}},function(e,t,i){"use strict";function s(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class o{constructor(){s(this,"xpathDocText",void 0),s(this,"xpathNodeText",void 0)}static isForbiddenNode(e){return!!e.isContentEditable||(!(!e.parentNode||!e.parentNode.isContentEditable&&!o.forbiddenTags.includes(e.parentNode.nodeName))||o.forbiddenTags.includes(e.nodeName))}}t.default=o,s(o,"disabledProtocols",new RegExp("(^chrome:|^about:|^[a-zA-Z]+-extension:)","i")),s(o,"forbiddenNodeRegExp",new RegExp("^s*(<[a-z].+?/?>|{.+?:.+?;.*}|https?://[^s]+$)")),s(o,"forbiddenTags",["SCRIPT","STYLE","INPUT","TEXTAREA","IFRAME","LINK"])},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s,o=(s=i(7))&&s.__esModule?s:{default:s};function r(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class a{constructor(e){r(this,"cueRuleIds",void 0),r(this,"enabledRuleIds",void 0),r(this,"filter",void 0),r(this,"lastFilteredNode",void 0),r(this,"lastFilteredText",void 0),r(this,"lastProcessed",void 0),r(this,"muted",void 0),r(this,"rules",void 0),r(this,"simpleUnmute",void 0),r(this,"sites",void 0),r(this,"supportedPage",void 0),r(this,"unmuteDelay",void 0),r(this,"volume",void 0),r(this,"watcherRuleIds",void 0),r(this,"wordlistId",void 0),r(this,"youTube",void 0),r(this,"youTubeAutoSubsMin",void 0),r(this,"youTubeAutoSubsMax",void 0),r(this,"youTubeAutoSubsTimeout",void 0),this.cueRuleIds=[],this.enabledRuleIds=[],this.watcherRuleIds=[],this.filter=e,this.lastFilteredNode=null,this.lastFilteredText="",this.lastProcessed=[],this.muted=!1,e.cfg.customAudioSites&&"object"==typeof e.cfg.customAudioSites||(e.cfg.customAudioSites={}),this.sites=o.default.combineSites(e.cfg.customAudioSites),this.unmuteDelay=0,this.volume=1,this.wordlistId=e.audioWordlistId,this.youTubeAutoSubsMin=e.cfg.youTubeAutoSubsMin,this.youTubeAutoSubsMax=1e3*e.cfg.youTubeAutoSubsMax,this.rules=this.sites[e.hostname],this.rules&&(Array.isArray(this.rules)||(this.rules=[this.rules]),this.initRules(),this.enabledRuleIds.length>0&&(this.supportedPage=!0,["tv.youtube.com","www.youtube.com"].includes(e.hostname)&&(this.youTube=!0),this.watcherRuleIds.length>0&&this.watcherRuleIds.forEach(e=>{setInterval(this.watcher,this.rules[e].checkInterval,this,e)}),this.cueRuleIds.length>0&&setInterval(this.watchForVideo,250,this)))}clean(e,t=0){let i=this.rules[t];if("watcher"===i.mode)return;let s=!1;e.nodeName&&"#text"===e.nodeName&&e.parentElement&&(e=e.parentElement);let o=i.subtitleSelector&&e.querySelectorAll?e.querySelectorAll(i.subtitleSelector):[e];if(0!==o.length)switch(o.forEach(e=>{let t="#text"===e.nodeName?"textContent":"innerText";!0===i.convertBreaks&&"#text"!==e.nodeName&&!a.brTagRegExp.test(e[t])&&a.brTagRegExp.test(e.innerHTML)&&("pre"!==e.style.whiteSpace&&(e.style.whiteSpace="pre"),e.textContent=e.innerHTML.replace(a.brTagRegExp,"\n"));let o=this.replaceTextResult(e[t]);o.modified&&(s=!0,this.mute(i.muteMethod),i.filterSubtitles&&(e[t]=o.filtered),this.lastFilteredNode=e,this.lastFilteredText=e[t])}),i.showSubtitles){case 1:s?this.showSubtitles(i):this.hideSubtitles(o,i);break;case 2:s?this.hideSubtitles(o,i):this.showSubtitles(i);break;case 3:this.hideSubtitles(o,i)}}cleanYouTubeAutoSubs(e){null!=this.youTubeAutoSubsTimeout&&(clearTimeout(this.youTubeAutoSubsTimeout),this.youTubeAutoSubsTimeout=null);let t=this.replaceTextResult(e.textContent);if(t.modified)e.textContent=t.filtered,this.mute(),this.unmuteDelay=null,this.filter.updateCounterBadge(),this.youTubeAutoSubsMax&&(this.youTubeAutoSubsTimeout=window.setTimeout(this.youTubeAutoSubsMuteTimeout,this.youTubeAutoSubsMax,this));else if(this.muted)if(this.youTubeAutoSubsMin>0){let e=document.getElementsByTagName("video")[0].currentTime;null==this.unmuteDelay?this.unmuteDelay=e:(e<this.unmuteDelay&&(this.unmuteDelay=0),e>this.unmuteDelay+this.youTubeAutoSubsMin&&this.unmute())}else this.unmute();if(0!=this.filter.cfg.showSubtitles){let e=document.querySelector("div.ytp-caption-window-rollup span.captions-text");"block"==e.style.display&&(e.style.display="none")}}getVideoTextTrack(e,t,i=!0){if(e.textTracks&&e.textTracks.length>0)for(let s=0;s<e.textTracks.length;s++)if(t){if(t==e.textTracks[s].language&&(!i||i&&"showing"===e.textTracks[s].mode))return e.textTracks[s]}else if(!i||i&&"showing"===e.textTracks[s].mode)return e.textTracks[s]}hideSubtitles(e,t){if(t.displaySelector){let e=document.querySelector(t.displaySelector);e&&(e.style.display=t.displayHide)}else e.forEach(e=>{e.innerText="",t.removeSubtitleSpacing&&e.style&&(e.style.padding&&(e.style.padding=0),e.style.margin&&(e.style.margin=0))})}initCueRule(e){void 0===e.videoSelector&&(e.videoSelector="video"),void 0===e.videoCueRequireShowing&&(e.videoCueRequireShowing=this.filter.cfg.muteCueRequireShowing)}initElementChildRule(e){void 0!==e.displaySelector&&(void 0===e.displayHide&&(e.displayHide="none"),void 0===e.displayShow&&(e.displayShow=""))}initRules(){this.rules.forEach((e,t)=>{if((void 0===e.mode||("element"==e.mode||"elementChild"==e.mode)&&!e.tagName||!0===e.iframe&&null==this.filter.iframe||!1===e.iframe&&null!=this.filter.iframe)&&(e.disabled=!0),!e.disabled)switch(this.enabledRuleIds.push(t),null==e.filterSubtitles&&(e.filterSubtitles=!0),null!=e.simpleUnmute&&(this.simpleUnmute=!0),null==e.muteMethod&&(e.muteMethod=this.filter.cfg.muteMethod),null==e.showSubtitles&&(e.showSubtitles=this.filter.cfg.showSubtitles),null!=e.tagName&&"#text"!=e.tagName&&(e.tagName=e.tagName.toUpperCase()),e.mode){case"cue":this.initCueRule(e),this.cueRuleIds.push(t);break;case"text":this.initTextRule(e);break;case"elementChild":this.initElementChildRule(e);break;case"watcher":this.initWatcherRule(e),this.watcherRuleIds.push(t)}})}initTextRule(e){e.tagName="#text"}initWatcherRule(e){void 0===e.checkInterval&&(e.checkInterval=20),void 0===e.trackProcessed&&(e.trackProcessed=!0),void 0===e.videoSelector&&(e.videoSelector="video")}mute(e=this.filter.cfg.muteMethod,t){if(!this.muted)switch(this.muted=!0,e){case 0:chrome.runtime.sendMessage({mute:!0});break;case 1:t||(t=document.querySelector("video")),t&&null!=t.volume&&(this.volume=t.volume,t.volume=0)}}playing(e){return!!(e&&e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>2)}processCues(e,t){for(let i=0;i<e.length;i++){let s=e[i];if(s.hasOwnProperty("filtered"))continue;t.videoCueSync&&(s.startTime+=t.videoCueSync,s.endTime+=t.videoCueSync);let o=this.replaceTextResult(s.text);o.modified?(s.filtered=!0,s.originalText=s.text,s.text=o.filtered):s.filtered=!1}}replaceTextResult(e,t=!0){return this.filter.replaceTextResult(e,this.wordlistId,t)}showSubtitles(e){if(e.displaySelector){let t=document.querySelector(e.displaySelector);t&&(t.style.display=e.displayShow)}}supportedNode(e){for(let t=0;t<this.enabledRuleIds.length;t++){let i=this.enabledRuleIds[t],s=this.rules[i];switch(s.mode){case"element":if(e.nodeName==s.tagName){let t=!1;if(t||!s.className||e.className&&e.classList.contains(s.className)||(t=!0),t||!s.dataPropPresent||e.dataset&&e.dataset.hasOwnProperty(s.dataPropPresent)||(t=!0),t||!s.hasChildrenElements||"number"==typeof e.childElementCount&&0!=e.childElementCount||(t=!0),t||!s.subtitleSelector||"function"==typeof e.querySelector&&e.querySelector(s.subtitleSelector)||(t=!0),t||!s.containsSelector||"function"==typeof e.querySelector&&e.querySelector(s.containsSelector)||(t=!0),!t)return i}break;case"elementChild":case"text":if(e.nodeName===s.tagName){let t=document.querySelector(s.parentSelector);if(t&&t.contains(e))return i}break;case"watcher":if(e.parentElement&&e.parentElement==document.querySelector(s.subtitleSelector))return i;if(null!=s.parentSelector){let t=document.querySelector(s.parentSelector);if(t&&t.contains(e))return i}}}return!1}unmute(e=this.filter.cfg.muteMethod,t){if(this.muted)switch(this.muted=!1,e){case 0:chrome.runtime.sendMessage({mute:!1});break;case 1:t||(t=document.querySelector("video")),t&&null!=t.volume&&(t.volume=this.volume)}}watcher(e,t=0){let i=e.rules[t],s=document.querySelector(i.videoSelector);if(s&&e.playing(s)){let t=document.querySelector(i.subtitleSelector);if(t&&t.textContent){let s=!1,o=!i.trackProcessed;if(t.hasChildNodes()){if(t.childNodes.forEach((r,a)=>{let n="#text"===(r&&r.nodeName)?"textContent":"innerText";if(!o)if(t.childNodes.length===e.lastProcessed.length){if(e.lastProcessed[a]===r[n])return!1;o=!0,e.lastProcessed.slice(0,a)}else o=!0,e.lastProcessed=[];if(r[n]){let t=e.replaceTextResult(r[n]);t.modified&&(e.mute(i.muteMethod),s=!0,i.filterSubtitles&&(r[n]=t.filtered),e.lastFilteredNode=r,e.lastFilteredText=r[n])}i.trackProcessed&&e.lastProcessed.push(r[n])}),!o)return!1}else{let r="#text"===(t&&t.nodeName)?"textContent":"innerText";if(!o&&e.lastProcessed.includes(t[r]))return!1;if(t[r]&&e.lastFilteredText&&!t[r].contains(e.lastFilteredText)){let o=e.replaceTextResult(t[r]);o.modified&&(e.mute(i.muteMethod),s=!0,i.filterSubtitles&&(t[r]=o.filtered),e.lastFilteredNode=t,e.lastFilteredText=t[r])}i.trackProcessed&&(e.lastProcessed=[t[r]])}let r="#text"===(t&&t.nodeName)?"textContent":"innerText";if(s||t[r].includes(e.lastFilteredText)||e.unmute(i.muteMethod),"#text"!==t.nodeName)switch(i.showSubtitles){case 1:t.style.display=s?"":"none";break;case 2:t.style.display=s?"none":"";break;case 3:t.style.display="none"}s&&e.filter.updateCounterBadge()}}}watchForVideo(e){e.cueRuleIds.forEach(t=>{let i=e.rules[t],s=document.querySelector(i.videoSelector);if(s&&s.textTracks&&e.playing(s)){let t=e.getVideoTextTrack(s,i.videoCueLanguage,i.videoCueRequireShowing);t&&!t.oncuechange&&(i.videoCueHideCues||3!=i.showSubtitles||(t.mode="hidden"),t.oncuechange=()=>{if(t.activeCues&&t.activeCues.length>0){let o=!1;for(let r=0;r<t.activeCues.length;r++){let a=t.activeCues[r];if(!a.hasOwnProperty("filtered")){let s=t.cues;e.processCues(s,i)}a.filtered&&(o=!0,e.mute(i.muteMethod,s))}if(o||e.unmute(i.muteMethod,s),i.videoCueHideCues){if(1===i.showSubtitles&&!o||2===i.showSubtitles&&o||3===i.showSubtitles)for(let e=0;e<t.activeCues.length;e++){let i=t.activeCues[e];i.text="",i.position=100,i.size=0}}else if(o)switch(i.showSubtitles){case 1:t.mode="showing";break;case 2:t.mode="hidden"}else switch(i.showSubtitles){case 1:t.mode="hidden";break;case 2:t.mode="showing"}}else e.unmute(i.muteMethod,s)})}})}youTubeAutoSubsCurrentRow(e){return!(e.parentElement.parentElement!=e.parentElement.parentElement.parentElement.lastChild)}youTubeAutoSubsMuteTimeout(e){let t=window.document.querySelector("video");t&&e.playing(t)&&e.unmute(),e.youTubeAutoSubsTimeout=null}youTubeAutoSubsNodeIsSubtitleText(e){let t=document.querySelector("div.caption-window");return!(!t||!t.contains(e))}youTubeAutoSubsPresent(){return!!document.querySelector("div.ytp-caption-window-rollup")}youTubeAutoSubsSupportedNode(e){return"#text"==e.nodeName&&""!=e.textContent&&!!this.youTubeAutoSubsNodeIsSubtitleText(e)}}t.default=a,r(a,"brTagRegExp",new RegExp("<br>","i"))},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class s{static combineSites(e={}){return Object.assign({},s.sites,e)}}var o,r,a;t.default=s,a={"abc.com":[{mode:"element",className:"akamai-caption-text",tagName:"DIV"}],"www.amazon.com":[{mode:"watcher",iframe:!1,parentSelector:"div.webPlayerContainer div p > span",showSubtitles:0,simpleUnmute:!0,subtitleSelector:"div.webPlayerContainer div span > span",videoSelector:"div.webPlayerElement video[src]"}],"www.amc.com":[{mode:"element",className:"ttr-container",subtitleSelector:"span.ttr-cue",tagName:"DIV"},{mode:"cue",videoCueLanguage:"en",videoSelector:"video"}],"www.att.tv":[{mode:"cue",videoSelector:"video#quickplayPlayer"}],"www.attwatchtv.com":[{mode:"cue",videoSelector:"video#quickplayPlayer"}],"gem.cbc.ca":[{className:"jw-text-track-container",mode:"element",subtitleSelector:"div.jw-text-track-cue",tagName:"DIV"}],"www.cbs.com":[{mode:"cue",videoCueLanguage:"en",videoCueRequireShowing:!1}],"www.dishanywhere.com":[{mode:"element",className:"bmpui-ui-subtitle-label",tagName:"SPAN"},{mode:"element",className:"bmpui-subtitle-region-container",subtitleSelector:"div.bmpui-container-wrapper > span.bmpui-ui-subtitle-label",tagName:"div"}],"www.disneyplus.com":[{mode:"cue",videoSelector:"video.btm-media-client-element"}],"www.fox.com":[{mode:"element",className:"jw-text-track-container",subtitleSelector:"div.jw-text-track-cue",tagName:"DIV"}],"www.funimation.com":[{mode:"elementChild",iframe:!0,parentSelector:"div.vjs-text-track-display",simpleUnmute:!0,subtitleSelector:":scope div > div",tagName:"DIV"}],"www.hulu.com":[{mode:"element",className:"caption-text-box",subtitleSelector:"p",tagName:"DIV"}],"www.nbc.com":[{mode:"element",className:"ttr-line",subtitleSelector:"span.ttr-cue",tagName:"DIV"},{mode:"cue",videoCueLanguage:"en"}],"www.netflix.com":[{mode:"element",className:"player-timedtext-text-container",subtitleSelector:"span",tagName:"DIV"}],"www.philo.com":[{mode:"cue"}],"app.plex.tv":[{mode:"element",dataPropPresent:"dialogueId",subtitleSelector:"span > span",tagName:"DIV"},{mode:"element",containsSelector:"div[data-dialogue-id]",subtitleSelector:"span > span",tagName:"DIV"}],"watch.redeemtv.com":[{mode:"elementChild",convertBreaks:!0,displaySelector:"div.vp-captions",parentSelector:"div.vp-captions",tagName:"SPAN"}],"www.sonycrackle.com":[{mode:"text",parentSelector:"div.clpp-subtitles-container"}],"play.stan.com.au":[{mode:"text",parentSelector:"div.clpp-subtitles-container"}],"www.syfy.com":[{mode:"element",className:"ttr-line",subtitleSelector:"span.ttr-cue",tagName:"DIV"}],"www.tntdrama.com":[{mode:"cue",videoCueLanguage:"en",videoSelector:"video.top-media-element"}],"www.universalkids.com":[{mode:"element",subtitleSelector:"div.gwt-HTML",tagName:"DIV"}],"www.usanetwork.com":[{mode:"element",className:"ttr-line",subtitleSelector:"span.ttr-cue",tagName:"DIV"}],"www.vudu.com":[{mode:"element",subtitleSelector:"span.subtitles",tagName:"DIV"}],"tv.youtube.com":[{mode:"element",className:"caption-window",subtitleSelector:"span.ytp-caption-segment",tagName:"DIV"}],"www.youtube.com":[{mode:"element",className:"caption-window",subtitleSelector:"span.ytp-caption-segment",tagName:"DIV"}]},(r="sites")in(o=s)?Object.defineProperty(o,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):o[r]=a},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s,o=(s=i(9))&&s.__esModule?s:{default:s};function r(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class a extends o.default{static async build(e=[]){"string"==typeof e&&(e=[e]);let t=await a.getConfig(e);return new a(t)}constructor(e){if(void 0===e)throw new Error("Cannot be called directly. call build()");super(),r(this,"_splitContainerKeys",void 0),r(this,"audioWordlistId",void 0),r(this,"customAudioSites",void 0),r(this,"domains",void 0),r(this,"enabledDomainsOnly",void 0),r(this,"muteAudio",void 0),r(this,"muteAudioOnly",void 0),r(this,"muteCueRequireShowing",void 0),r(this,"muteMethod",void 0),r(this,"password",void 0),r(this,"showSubtitles",void 0),r(this,"showUpdateNotification",void 0),r(this,"youTubeAutoSubsMax",void 0),r(this,"youTubeAutoSubsMin",void 0),this._splitContainerKeys={},Object.assign(this,a._classDefaults,e)}static combineData(e,t){if(e[t]={},void 0!==e[`_${t}0`]){let i=a.getDataContainerKeys(e,t);return i.forEach((function(i){Object.assign(e[t],e[i]),delete e[i]})),i}}static getConfig(e){return new Promise((function(t,i){let s=null;e.length>0&&!e.some(e=>a._splittingKeys.includes(e))&&(s={},e.forEach(e=>{s[e]=a._defaults[e]})),chrome.storage.sync.get(s,(function(i){i._splitContainerKeys={},Object.keys(a._defaults).forEach((function(t){null!=s&&!e.includes(t)||void 0!==i[t]||(i[t]=a._defaults[t])})),(0===e.length||e.includes("words"))&&(void 0!==i._words0&&0!=Object.keys(i._words0).length||(i._words0=o.default._defaultWords)),a._splittingKeys.forEach((function(e){let t=a.combineData(i,e);t&&(i._splitContainerKeys[e]=t)})),null!==s&&e.length>0&&Object.keys(i).forEach((function(t){e.includes(t)||delete i[t]})),t(i)}))}))}static getDataContainerKeys(e,t){let i=new RegExp(`^_${t}\\d+`);return Object.keys(e).filter((function(e){return i.test(e)}))}ordered(){let e=this;return Object.keys(e).sort().reduce((t,i)=>("_"!=i[0]&&(t[i]=e[i]),t),{})}remove(e){let t=this;"string"==typeof e&&(e=[e]),chrome.storage.sync.remove(e),e.forEach((function(e){delete t[e]}))}reset(){return new Promise((function(e,t){chrome.storage.sync.clear((function(){e(chrome.runtime.lastError?1:0)}))}))}save(e=[]){let t=this;"string"==typeof e&&(e=[e]);let i={};return 0===e.length&&(e=Object.keys(a._defaults)).push("words"),e.forEach((function(e){a._splittingKeys.includes(e)?Object.assign(i,t.splitData(e)):i[e]=t[e]})),0!==Object.keys(t._splitContainerKeys).length&&e.some(e=>a._splittingKeys.includes(e))&&a._splittingKeys.forEach((function(s){if(e.includes(s)){let e=a.getDataContainerKeys(i,s);if(t._splitContainerKeys[s]){let i=t._splitContainerKeys[s].filter(t=>!e.includes(t));0!==i.length&&(t.remove(i),t._splitContainerKeys[s]=e)}}})),new Promise((function(e,t){chrome.storage.sync.set(i,(function(){e(chrome.runtime.lastError?1:0)}))}))}splitData(e){let t=this;const i=new TextEncoder;let s=0,o=2,r={},n=`_${e}${s}`;return r[n]={},o+=i.encode(`{"${n}":{}}`).length,Object.keys(t[e]).sort().forEach((function(d){let l=i.encode(`",${d}":`).length;l+=i.encode(JSON.stringify(t[e][d])).length,o+l>=a._maxBytes&&(s++,n=`_${e}${s}`,r[n]={},o=i.encode(`"${n}":{}`).length),o+=l,r[n][d]=t[e][d]})),r}}t.default=a,r(a,"_classDefaults",{domains:{},audioWordlistId:0,customAudioSites:null,enabledDomainsOnly:!1,muteAudio:!1,muteAudioOnly:!1,muteCueRequireShowing:!0,muteMethod:0,password:null,showSubtitles:0,showUpdateNotification:!0,youTubeAutoSubsMax:0,youTubeAutoSubsMin:0}),r(a,"QUOTA_BYTES_PER_ITEM",8192),r(a,"_defaults",Object.assign({},o.default._defaults,a._classDefaults)),r(a,"_splittingKeys",["domains","words"]),r(a,"_maxBytes",8e3)},function(e,t,i){"use strict";function s(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class o{constructor(e={}){s(this,"censorCharacter",void 0),s(this,"censorFixedLength",void 0),s(this,"defaultSubstitution",void 0),s(this,"defaultWordMatchMethod",void 0),s(this,"defaultWordRepeat",void 0),s(this,"defaultWordSeparators",void 0),s(this,"filterMethod",void 0),s(this,"filterWordList",void 0),s(this,"iWordWhitelist",void 0),s(this,"preserveCase",void 0),s(this,"preserveFirst",void 0),s(this,"preserveLast",void 0),s(this,"showCounter",void 0),s(this,"showSummary",void 0),s(this,"substitutionMark",void 0),s(this,"wordlistId",void 0),s(this,"wordlists",void 0),s(this,"wordlistsEnabled",void 0),s(this,"words",void 0),s(this,"wordWhitelist",void 0),Object.assign(this,o._defaults,e)}addWord(e,t){if(e=e.trim().toLowerCase(),Object.keys(this.words).includes(e))return!1;if(t)return t.sub=t.sub.trim().toLowerCase(),this.words[e]=t,!0;{let t=[];return this.wordlistsEnabled&&t.push(this.wordlistId),this.words[e]={matchMethod:this.defaultWordMatchMethod,repeat:this.defaultWordRepeat,separators:this.defaultWordSeparators,lists:t,sub:""},!0}}removeWord(e){return e=e.trim().toLowerCase(),!!Object.keys(this.words).includes(e)&&(delete this.words[e],!0)}repeatForWord(e){return!0===this.words[e].repeat||!1===this.words[e].repeat?this.words[e].repeat:this.defaultWordRepeat}sanitizeWords(){let e={};Object.keys(this.words).sort().forEach(t=>{e[t.trim().toLowerCase()]=this.words[t]}),this.words=e}}t.default=o,s(o,"_allWordlists",["All words"]),s(o,"_defaults",{censorCharacter:"*",censorFixedLength:0,defaultSubstitution:"censored",defaultWordMatchMethod:0,defaultWordRepeat:!1,defaultWordSeparators:!1,filterMethod:1,filterWordList:!0,iWordWhitelist:[],preserveCase:!0,preserveFirst:!0,preserveLast:!1,showCounter:!0,showSummary:!0,substitutionMark:!1,wordlistId:0,wordlists:["Wordlist 1","Wordlist 2","Wordlist 3","Wordlist 4","Wordlist 5","Wordlist 6"],wordlistsEnabled:!0,wordWhitelist:[]}),s(o,"_defaultWords",{ass:{lists:[],matchMethod:0,repeat:!0,separators:!1,sub:"butt"},asses:{lists:[],matchMethod:0,repeat:!1,separators:!1,sub:"butts"},asshole:{lists:[],matchMethod:1,repeat:!0,separators:!1,sub:"jerk"},badass:{lists:[],matchMethod:1,repeat:!0,separators:!0,sub:"cool"},bastard:{lists:[],matchMethod:1,repeat:!0,separators:!1,sub:"idiot"},bitch:{lists:[],matchMethod:1,repeat:!0,separators:!1,sub:"bench"},cocksucker:{lists:[],matchMethod:1,repeat:!0,separators:!0,sub:"suckup"},cunt:{lists:[],matchMethod:1,repeat:!0,separators:!1,sub:"expletive"},dammit:{lists:[],matchMethod:1,repeat:!1,separators:!0,sub:"dangit"},damn:{lists:[],matchMethod:1,repeat:!1,separators:!1,sub:"dang"},dumbass:{lists:[],matchMethod:1,repeat:!0,separators:!1,sub:"idiot"},fag:{lists:[],matchMethod:0,repeat:!0,separators:!1,sub:"gay"},faggot:{lists:[],matchMethod:1,repeat:!0,separators:!1,sub:"gay"},fags:{lists:[],matchMethod:0,repeat:!0,separators:!1,sub:"gays"},fuck:{lists:[],matchMethod:1,repeat:!0,separators:!0,sub:"freak"},goddammit:{lists:[],matchMethod:1,repeat:!0,separators:!0,sub:"dangit"},hell:{lists:[],matchMethod:0,repeat:!1,separators:!1,sub:"heck"},jackass:{lists:[],matchMethod:1,repeat:!0,separators:!0,sub:"jerk"},nigga:{lists:[],matchMethod:0,repeat:!0,separators:!1,sub:"bruh"},nigger:{lists:[],matchMethod:0,repeat:!0,separators:!1,sub:"man"},niggers:{lists:[],matchMethod:0,repeat:!0,separators:!1,sub:"people"},piss:{lists:[],matchMethod:1,repeat:!0,separators:!1,sub:"pee"},pissed:{lists:[],matchMethod:1,repeat:!0,separators:!1,sub:"ticked"},pussies:{lists:[],matchMethod:0,repeat:!0,separators:!1,sub:"softies"},pussy:{lists:[],matchMethod:0,repeat:!0,separators:!1,sub:"softie"},shit:{lists:[],matchMethod:1,repeat:!0,separators:!1,sub:"crap"},slut:{lists:[],matchMethod:1,repeat:!0,separators:!1,sub:"tramp"},tits:{lists:[],matchMethod:1,repeat:!0,separators:!1,sub:"chest"},twat:{lists:[],matchMethod:0,repeat:!0,separators:!1,sub:"dumbo"},twats:{lists:[],matchMethod:0,repeat:!0,separators:!1,sub:"dumbos"},whore:{lists:[],matchMethod:1,repeat:!0,separators:!1,sub:"tramp"}}),s(o,"_filterMethodNames",["Censor","Substitute","Remove"]),s(o,"_matchMethodNames",["Exact","Partial","Whole","Regular-Expression"])},function(e,t){"undefined"!=typeof window&&(window.findAndReplaceDOMText=function(){var e="retain",t=document,i={}.hasOwnProperty;function s(){return o.apply(null,arguments)||r.apply(null,arguments)}function o(e,t,i,o,a){if(t&&!t.nodeType&&arguments.length<=2)return!1;var n,d="function"==typeof i;d&&(n=i,i=function(e,t){return n(e.text,t.startIndex)});var l=r(t,{find:e,wrap:d?null:i,replace:d?i:"$"+(o||"&"),prepMatch:function(e,t){if(!e[0])throw"findAndReplaceDOMText cannot handle zero-length matches";if(o>0){var i=e[o];e.index+=e[0].indexOf(i),e[0]=i}return e.endIndex=e.index+e[0].length,e.startIndex=e.index,e.index=t,e},filterElements:a});return s.revert=function(){return l.revert()},!0}function r(e,t){return new a(e,t)}function a(t,o){var r=o.preset&&s.PRESETS[o.preset];if(o.portionMode=o.portionMode||e,r)for(var a in r)i.call(r,a)&&!i.call(o,a)&&(o[a]=r[a]);this.node=t,this.options=o,this.prepMatch=o.prepMatch||this.prepMatch,this.reverts=[],this.matches=this.search(),this.matches.length&&this.processMatches()}return s.NON_PROSE_ELEMENTS={br:1,hr:1,script:1,style:1,img:1,video:1,audio:1,canvas:1,svg:1,map:1,object:1,input:1,textarea:1,select:1,option:1,optgroup:1,button:1},s.NON_CONTIGUOUS_PROSE_ELEMENTS={address:1,article:1,aside:1,blockquote:1,dd:1,div:1,dl:1,fieldset:1,figcaption:1,figure:1,footer:1,form:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,header:1,hgroup:1,hr:1,main:1,nav:1,noscript:1,ol:1,output:1,p:1,pre:1,section:1,ul:1,br:1,li:1,summary:1,dt:1,details:1,rp:1,rt:1,rtc:1,script:1,style:1,img:1,video:1,audio:1,canvas:1,svg:1,map:1,object:1,input:1,textarea:1,select:1,option:1,optgroup:1,button:1,table:1,tbody:1,thead:1,th:1,tr:1,td:1,caption:1,col:1,tfoot:1,colgroup:1},s.NON_INLINE_PROSE=function(e){return i.call(s.NON_CONTIGUOUS_PROSE_ELEMENTS,e.nodeName.toLowerCase())},s.PRESETS={prose:{forceContext:s.NON_INLINE_PROSE,filterElements:function(e){return!i.call(s.NON_PROSE_ELEMENTS,e.nodeName.toLowerCase())}}},s.Finder=a,a.prototype={search:function(){var e,t=0,i=0,s=this.options.find,o=this.getAggregateText(),r=[],a=this;return s="string"==typeof s?RegExp(String(s).replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1"),"g"):s,function o(n){for(var d=0,l=n.length;d<l;++d){var u=n[d];if("string"==typeof u){if(s.global)for(;e=s.exec(u);)r.push(a.prepMatch(e,t++,i));else(e=u.match(s))&&r.push(a.prepMatch(e,0,i));i+=u.length}else o(u)}}(o),r},prepMatch:function(e,t,i){if(!e[0])throw new Error("findAndReplaceDOMText cannot handle zero-length matches");return e.endIndex=i+e.index+e[0].length,e.startIndex=i+e.index,e.index=t,e},getAggregateText:function(){var e=this.options.filterElements,t=this.options.forceContext;return function i(s){if(s.nodeType===Node.TEXT_NODE)return[s.data];if(e&&!e(s))return[];var o=[""],r=0;if(s=s.firstChild)do{if(s.nodeType!==Node.TEXT_NODE){var a=i(s);t&&s.nodeType===Node.ELEMENT_NODE&&(!0===t||t(s))?(o[++r]=a,o[++r]=""):("string"==typeof a[0]&&(o[r]+=a.shift()),a.length&&(o[++r]=a,o[++r]=""))}else o[r]+=s.data}while(s=s.nextSibling);return o}(this.node)},processMatches:function(){var e,t,i,s=this.matches,o=this.node,r=this.options.filterElements,a=[],n=o,d=s.shift(),l=0,u=0,c=[o];e:for(;;){if(n.nodeType===Node.TEXT_NODE&&(!t&&n.length+l>=d.endIndex?t={node:n,index:u++,text:n.data.substring(d.startIndex-l,d.endIndex-l),indexInMatch:0===l?0:l-d.startIndex,indexInNode:d.startIndex-l,endIndexInNode:d.endIndex-l,isEnd:!0}:e&&a.push({node:n,index:u++,text:n.data,indexInMatch:l-d.startIndex,indexInNode:0}),!e&&n.length+l>d.startIndex&&(e={node:n,index:u++,indexInMatch:0,indexInNode:d.startIndex-l,endIndexInNode:d.endIndex-l,text:n.data.substring(d.startIndex-l,d.endIndex-l)}),l+=n.data.length),i=n.nodeType===Node.ELEMENT_NODE&&r&&!r(n),e&&t){if(n=this.replaceMatch(d,e,a,t),l-=t.node.data.length-t.endIndexInNode,e=null,t=null,a=[],u=0,!(d=s.shift()))break}else if(!i&&(n.firstChild||n.nextSibling)){n.firstChild?(c.push(n),n=n.firstChild):n=n.nextSibling;continue}for(;;){if(n.nextSibling){n=n.nextSibling;break}if((n=c.pop())===o)break e}}},revert:function(){for(var e=this.reverts.length;e--;)this.reverts[e]();this.reverts=[]},prepareReplacementString:function(e,t,i){var s=this.options.portionMode;return"first"===s&&t.indexInMatch>0?"":(e=e.replace(/\$(\d+|&|`|')/g,(function(e,t){var s;switch(t){case"&":s=i[0];break;case"`":s=i.input.substring(0,i.startIndex);break;case"'":s=i.input.substring(i.endIndex);break;default:s=i[+t]||""}return s})),"first"===s?e:t.isEnd?e.substring(t.indexInMatch):e.substring(t.indexInMatch,t.indexInMatch+t.text.length))},getPortionReplacementNode:function(e,i){var s=this.options.replace||"$&";if("function"==typeof s)return(s=s(e,i))&&s.nodeType?s:t.createTextNode(String(s))},replaceMatch:function(e,i,s,o){var r,a,n=i.node,d=o.node;if(n===d){var l=n;i.indexInNode>0&&(r=t.createTextNode(l.data.substring(0,i.indexInNode)),l.parentNode.insertBefore(r,l));var u=this.getPortionReplacementNode(o,e);return l.parentNode.insertBefore(u,l),o.endIndexInNode<l.length&&(a=t.createTextNode(l.data.substring(o.endIndexInNode)),l.parentNode.insertBefore(a,l)),l.parentNode.removeChild(l),this.reverts.push((function(){r===u.previousSibling&&r.parentNode.removeChild(r),a===u.nextSibling&&a.parentNode.removeChild(a),u.parentNode.replaceChild(l,u)})),u}r=t.createTextNode(n.data.substring(0,i.indexInNode)),a=t.createTextNode(d.data.substring(o.endIndexInNode));for(var c=this.getPortionReplacementNode(i,e),h=[],p=0,f=s.length;p<f;++p){var m=s[p],g=this.getPortionReplacementNode(m,e);m.node.parentNode.replaceChild(g,m.node),this.reverts.push(function(e,t){return function(){t.parentNode.replaceChild(e.node,t)}}(m,g)),h.push(g)}var b=this.getPortionReplacementNode(o,e);return n.parentNode.insertBefore(r,n),n.parentNode.insertBefore(c,n),n.parentNode.removeChild(n),d.parentNode.insertBefore(b,d),d.parentNode.insertBefore(a,d),d.parentNode.removeChild(d),this.reverts.push((function(){r.parentNode.removeChild(r),c.parentNode.replaceChild(n,c),a.parentNode.removeChild(a),b.parentNode.replaceChild(d,b)})),b}},s}())}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment