diff --git a/bookmarklet.js b/bookmarklet.js index 8d03ebc0..ccb7267c 100644 --- a/bookmarklet.js +++ b/bookmarklet.js @@ -1,7 +1,7 @@ /*! For license information please see bookmarkletFilter.js.LICENSE.txt */ -(()=>{var e={50:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s,o=(s=i(357))&&s.__esModule?s:{default:s};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}class r{static byHostname(e,t){const i=r.findDomainKey(e,t)||e,s=r.byKey(i,t);return s.hostname=e,s}static byKey(e,t){return new r(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(((e,t)=>{chrome.tabs.query({active:!0,currentWindow:!0},(t=>{e(t[0])}))}))}static sortedKeys(e){const t=new RegExp("(\\w+?[.]|)\\w+?$");return Object.keys(e).sort(((e,i)=>{const s=e.match(t),o=i.match(t),a=s?s[0]:e,r=o?o[0]:i;return ar?1:0}))}constructor(e,t){a(this,"advanced",void 0),a(this,"audioWordlistId",void 0),a(this,"cfg",void 0),a(this,"cfgKey",void 0),a(this,"deep",void 0),a(this,"disabled",void 0),a(this,"enabled",void 0),a(this,"hostname",void 0),a(this,"tab",void 0),a(this,"wordlistId",void 0),this.cfgKey=e,this.cfg={},t?this.cfg=t:Object.assign(this.cfg,r._domainCfgDefaults),this.updateFromCfg()}getModeIndex(){return this.advanced?o.default.DOMAIN_MODES.ADVANCED:this.deep?o.default.DOMAIN_MODES.DEEP:o.default.DOMAIN_MODES.NORMAL}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.deep=!0===this.deep||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.deep=this.cfg.deep,this.disabled=this.cfg.disabled,this.enabled=this.cfg.enabled,this.wordlistId=this.cfg.wordlist,this.audioWordlistId=this.cfg.audioList}updateFromModeIndex(e){switch(e){case o.default.DOMAIN_MODES.NORMAL:this.advanced=!1,this.deep=!1;break;case o.default.DOMAIN_MODES.ADVANCED:this.advanced=!0,this.deep=!1;break;case o.default.DOMAIN_MODES.DEEP:this.advanced=!1,this.deep=!0}}}t.default=r,a(r,"_domainCfgDefaults",{adv:void 0,audioList:void 0,deep:void 0,disabled:void 0,enabled:void 0,wordlist:void 0})},513:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s,o=(s=i(357))&&s.__esModule?s:{default:s};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}class r{constructor(e={}){a(this,"censorCharacter",void 0),a(this,"censorFixedLength",void 0),a(this,"defaultSubstitution",void 0),a(this,"defaultWordMatchMethod",void 0),a(this,"defaultWordRepeat",void 0),a(this,"defaultWordSeparators",void 0),a(this,"filterMethod",void 0),a(this,"filterWordList",void 0),a(this,"iWordWhitelist",void 0),a(this,"loggingLevel",void 0),a(this,"preserveCase",void 0),a(this,"preserveFirst",void 0),a(this,"preserveLast",void 0),a(this,"showCounter",void 0),a(this,"showSummary",void 0),a(this,"substitutionMark",void 0),a(this,"wordlistId",void 0),a(this,"wordlists",void 0),a(this,"wordlistsEnabled",void 0),a(this,"words",void 0),a(this,"wordWhitelist",void 0),Object.assign(this,r._defaults,e)}addWord(e,t=this.defaultWordOptions()){return e=e.trim(),(t=Object.assign({},this.defaultWordOptions(),t)).matchMethod!==o.default.MATCH_METHODS.REGEX&&(e=e.toLowerCase()),!Object.keys(this.words).includes(e)&&(t.sub=t.case?t.sub.trim():t.sub.trim().toLowerCase(),this.words[e]=t,!0)}defaultWordOptions(){return{lists:[],matchMethod:this.defaultWordMatchMethod,repeat:this.defaultWordRepeat,separators:this.defaultWordSeparators,sub:""}}removeWord(e){const t=(e=e.trim()).toLowerCase();return Object.keys(this.words).includes(t)?(delete this.words[t],!0):!!this.words[e]&&(delete this.words[e],!0)}repeatForWord(e){return this.words[e].repeat===o.default.TRUE||this.words[e].repeat===o.default.FALSE?this.words[e].repeat:this.defaultWordRepeat}sanitizeWords(){const e={};Object.keys(this.words).sort().forEach((t=>{e[t.trim().toLowerCase()]=this.words[t]})),this.words=e}}t.default=r,a(r,"_allWordlists",["All words"]),a(r,"_defaults",{censorCharacter:"*",censorFixedLength:0,defaultSubstitution:"censored",defaultWordMatchMethod:o.default.MATCH_METHODS.EXACT,defaultWordRepeat:o.default.FALSE,defaultWordSeparators:o.default.FALSE,filterMethod:o.default.FILTER_METHODS.SUBSTITUTE,filterWordList:!0,iWordWhitelist:[],loggingLevel:o.default.LOGGING_LEVELS.WARN,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:[]}),a(r,"_defaultWords",{ass:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"butt"},asses:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.FALSE,separators:o.default.FALSE,sub:"butts"},asshole:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"jerk"},badass:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.TRUE,sub:"cool"},bastard:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"idiot"},bitch:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"bench"},cocksucker:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.TRUE,sub:"suckup"},cunt:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"expletive"},dammit:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.FALSE,separators:o.default.TRUE,sub:"dangit"},damn:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.FALSE,separators:o.default.FALSE,sub:"dang"},dumbass:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"idiot"},fag:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"gay"},faggot:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"gay"},fags:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"gays"},fuck:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.TRUE,sub:"freak"},goddammit:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.TRUE,sub:"dangit"},hell:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.FALSE,separators:o.default.FALSE,sub:"heck"},jackass:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.TRUE,sub:"jerk"},nigga:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"bruh"},nigger:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"man"},niggers:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"people"},piss:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"pee"},pissed:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"ticked"},pussies:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"softies"},pussy:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"softie"},shit:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"crap"},slut:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"tramp"},tits:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"chest"},twat:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"dumbo"},twats:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"dumbos"},whore:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"tramp"}})},357:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=i(582);function o(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{static filterMethodName(e){return this.nameById(this.FILTER_METHODS,e)}static loggingLevelName(e){return this.nameByValue(this.LOGGING_LEVELS,e)}static matchMethodName(e){return this.nameById(this.MATCH_METHODS,e)}static nameById(e,t){return(0,s.upperCaseFirst)(Object.entries(e).filter((e=>e[1]===t))[0][0])}static nameByValue(e,t){return Object.keys(e).find((i=>e[i]==t))}static orderedArray(e){const t=[];return Object.values(e).sort().forEach((i=>{t.push(a.nameById(e,i))})),t}}t.default=a,o(a,"ALL_WORDS_WORDLIST_ID",0),o(a,"DOMAIN_MODES",{NORMAL:0,ADVANCED:1,DEEP:2}),o(a,"FALSE",0),o(a,"FILTER_METHODS",{CENSOR:0,SUBSTITUTE:1,REMOVE:2,OFF:3}),o(a,"LOGGING_LEVELS",{DEBUG:0,INFO:1,WARN:2,ERROR:3}),o(a,"MATCH_METHODS",{EXACT:0,PARTIAL:1,WHOLE:2,REGEX:3}),o(a,"MUTE_METHODS",{TAB:0,VIDEO_VOLUME:1,VIDEO_MUTE:2,NONE:9}),o(a,"SHOW_SUBTITLES",{ALL:0,FILTERED:1,UNFILTERED:2,NONE:3}),o(a,"STATS_TYPE_AUDIO","audio"),o(a,"STATS_TYPE_TEXT","text"),o(a,"TRUE",1)},394:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=r(i(357)),o=r(i(812)),a=r(i(709));function r(e){return e&&e.__esModule?e:{default:e}}function n(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(){n(this,"cfg",void 0),n(this,"counter",void 0),n(this,"iWhitelist",void 0),n(this,"whitelist",void 0),n(this,"wordlistId",void 0),n(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 a.default(this.cfg,e)),e}checkWhitelist(e,t,i,a){const r=this.whitelist.length,n=this.iWhitelist.length;if(r||n){if(r&&this.whitelist.includes(e))return!0;if(n&&this.iWhitelist.includes(e.toLowerCase()))return!0;if(a.matchMethod===s.default.MATCH_METHODS.PARTIAL){const a={matchMethod:s.default.MATCH_METHODS.WHOLE,repeat:s.default.FALSE,separators:s.default.FALSE,sub:""},l=new o.default(e,a,this.cfg).regExp;let d;for(;null!==(d=l.exec(t));){const t=4==d.length?d[2]:d[0],s=4==d.length?d.index+d[1].length:d.index;if(s<=i&&s+t.length>=i+e.length){if(r&&this.whitelist.includes(t))return!0;if(n&&this.iWhitelist.includes(t.toLowerCase()))return!0}}}}return!1}foundMatch(e,t){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?s.default.ALL_WORDS_WORDLIST_ID:this.cfg.wordlistId),this.buildWordlist(e)}matchData(e,t,i,o){const a=e.find(t),r=o.pop(),n=o.pop(),l=o,d=l.length>0&&a.matchMethod!==s.default.MATCH_METHODS.REGEX;return d&&(i=l[1]),{word:a,string:r,match:i,matchStartIndex:n,captureGroups:l,internalCaptureGroups:d}}rebuildWordlists(){Object.keys(this.wordlists).forEach((e=>{this.buildWordlist(parseInt(e),!0)}))}replaceText(e,t=!1,i=s.default.STATS_TYPE_TEXT){t=this.buildWordlist(t);const a=this.wordlists[t];switch(this.cfg.filterMethod){case s.default.FILTER_METHODS.OFF:case s.default.FILTER_METHODS.CENSOR:a.regExps.forEach(((t,s)=>{e=e.replace(t,((e,...t)=>{const{word:o,string:r,match:n,matchStartIndex:l,captureGroups:d,internalCaptureGroups:u}=this.matchData(a,s,e,t);if(this.checkWhitelist(n,r,l,o))return n;i&&this.foundMatch(o,i);let c="";const h=this.cfg.censorFixedLength>0?this.cfg.censorFixedLength:n.length;return c=this.cfg.preserveFirst&&this.cfg.preserveLast?n[0]+this.cfg.censorCharacter.repeat(h-2)+n.slice(-1):this.cfg.preserveFirst?n[0]+this.cfg.censorCharacter.repeat(h-1):this.cfg.preserveLast?this.cfg.censorCharacter.repeat(h-1)+n.slice(-1):this.cfg.censorCharacter.repeat(h),u&&(c=d[0]+c+d[2]),c}))}));break;case s.default.FILTER_METHODS.SUBSTITUTE:a.regExps.forEach(((t,r)=>{e=e.replace(t,((e,...t)=>{const{word:n,string:l,match:d,matchStartIndex:u,captureGroups:c,internalCaptureGroups:h}=this.matchData(a,r,e,t);if(this.checkWhitelist(d,l,u,n))return d;if(i&&this.foundMatch(n,i),n.matchMethod==s.default.MATCH_METHODS.REGEX&&c.length&&n.sub.includes("\\1")){let e=n.sub;if(c.forEach(((t,i)=>{e=e.replace(`\\${i+1}`,t)})),e!==n.sub)return e}let p=n.sub||this.cfg.defaultSubstitution;return!n.case&&this.cfg.preserveCase&&(o.default.allUpperCase(d)?p=p.toUpperCase():o.default.eachWordCapitalized(d)?p=o.default.capitalizeEachWord(p):o.default.firstCapitalized(d)&&(p=o.default.capitalizeFirst(p))),this.cfg.substitutionMark&&(p="["+p+"]"),h&&(p=c[0]+p+c[2]),p}))}));break;case s.default.FILTER_METHODS.REMOVE:a.regExps.forEach(((t,s)=>{e=e.replace(t,((e,...t)=>{const{word:r,string:n,match:l,matchStartIndex:d,captureGroups:u,internalCaptureGroups:c}=this.matchData(a,s,e,t);return this.checkWhitelist(l.trim(),n,d,r)?l:(i&&this.foundMatch(r,i),c?o.default.whitespaceRegExp.test(u[0])&&o.default.whitespaceRegExp.test(u[2])?u[0]:o.default.nonWordRegExp.test(u[0])||o.default.nonWordRegExp.test(u[2])?(u[0]+u[2]).trim():"":o.default.whitespaceRegExp.test(l[0])&&o.default.whitespaceRegExp.test(l[l.length-1])?l[0]:"")}))}))}return e}replaceTextResult(e,t=!1,i=s.default.STATS_TYPE_TEXT){const o={original:e,filtered:this.replaceText(e,t,i),modified:!1};return o.modified=o.filtered!=e,o}}},582:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.booleanToNumber=function(e){return e?o.default.TRUE:o.default.FALSE},t.dynamicList=function(e,t,i=!1,s){n(t);(void 0!==s?[s].concat(e):e).forEach((e=>{const o=document.createElement("option");o.value=s&&e===s?"":e,o.textContent=i?l(e):e,t.appendChild(o)}))},t.exportToFile=function(e,t="data.txt"){const i="data:application/json;charset=utf-8,"+encodeURIComponent(e),s=document.createElement("a");s.setAttribute("href",i),s.setAttribute("download",t),s.click(),s.remove()},t.formatNumber=function(e){const t=e.toString().length;if(t<=3)return e.toString();if(t<=6){const t=(e/1e3).toPrecision(),i=t.indexOf(".");return(i>=-1&&i<=1?t.substr(0,3):t.substr(0,i))+"k"}if(t<=9){const t=(e/1e6).toPrecision(),i=t.indexOf(".");return(i>=-1&&i<=1?t.substr(0,3):t.substr(0,i))+"M"}return"1G+"},t.getGlobalVariable=function(e,t="APFData"){const i=document.createElement("script");i.id=t,i.textContent=`document.getElementById("${t}").textContent = JSON.stringify(${e})`,document.documentElement.appendChild(i);const s=document.querySelector(`script#${t}`).textContent;return i.remove(),JSON.parse(s)},t.getGlobalVariableFromBackground=function(e){return new Promise(((t,i)=>{chrome.runtime.sendMessage({globalVariable:e},(e=>{t(e)}))}))},t.getParent=function e(t,i=1){return t?i>0?e(t.parentElement,i-1):t:null},t.getVersion=function(e){const t=e.split(".");return{major:parseInt(t[0]),minor:parseInt(t[1]),patch:parseInt(t[2])}},t.hmsToSeconds=function(e,t=3){const[i="0",s="0",o="0"]=(e||"0:0:0").split(":"),a=parseInt(i,10)||0,r=parseInt(s,10)||0,n=parseFloat(o)||0;return parseFloat((3600*a+60*r+n).toFixed(t))},t.injectScript=function(e,t,i=""){const s=document.getElementsByTagName(t)[0],o=document.createElement("script");o.setAttribute("type","text/javascript"),i&&(o.id=i);o.setAttribute("src",e),s.appendChild(o)},t.isVersionOlder=function(e,t){if(e.major{chrome.runtime.sendMessage({fetch:e,fetchMethod:t.toUpperCase()},(e=>{i(e)}))}))},t.makeFetchRequest=a,t.makeRequest=async function(e,t){return fetch?await a(e,t):await r(e,t)},t.makeXMLHttpRequest=r,t.numberToBoolean=function(e){return e>o.default.FALSE},t.numberWithCommas=function(e){if("object"==typeof Intl&&"function"==typeof Intl.NumberFormat)return"string"==typeof e&&(e=parseInt(e).toString()),e.toLocaleString();{const t=(e=e.toString()).indexOf(".");let i=-1===t?e:e.slice(0,t);for(let e=i.length-3;e>0;e-=3)i=i.slice(0,e)+","+i.slice(e);return-1!==t&&(i+=e.slice(t)),i}},t.prettyPrintArray=function(e){return`[${e.toString().replace(/,/g,", ")}]`},t.readFile=function(e){return new Promise(((t,i)=>{const s=new FileReader;s.onload=()=>{t(s.result)},s.readAsText(e)}))},t.removeChildren=n,t.removeFromArray=function(e,t){return e.filter((e=>e!==t))},t.secondsToHMS=function(e){return new Date(1e3*e).toISOString().substr(11,12)},t.stringArray=function(e){"string"==typeof e&&(e=[e]);return e},t.upperCaseFirst=l;var s,o=(s=i(357))&&s.__esModule?s:{default:s};async function a(e,t="GET"){const i=await fetch(e,{method:t});return await i.text()}function r(e,t){return new Promise(((i,s)=>{const o=new XMLHttpRequest;o.open(t,e),o.onload=function(){this.status>=200&&this.status<300?i(this.response):s({status:this.status,statusText:this.statusText})},o.onerror=function(){s({status:this.status,statusText:this.statusText})},o.send()}))}function n(e){if(e.hasChildNodes)for(;e.firstChild;)e.firstChild.remove()}function l(e,t=!0){let i=e.charAt(0).toUpperCase();return i+=t?e.toLowerCase().slice(1):e.slice(1),i}},167:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s,o=(s=i(357))&&s.__esModule?s:{default:s};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}class r{static debug(e,...t){this.log(this.debugName,e,t)}static debugTime(e,t=[]){this.logTime(this.debugName,e,t)}static error(e,...t){this.log(this.errorName,e,t)}static errorTime(e,t=[]){this.logTime(this.errorName,e,t)}static info(e,...t){this.log(this.infoName,e,t)}static infoTime(e,t=[]){this.logTime(this.infoName,e,t)}static log(e,t,i=[]){t=`[${r.app}] ${t}`,i.length?console[e](t,i):console[e](t)}static logTime(e,t,i=[]){const s=(new Date).toLocaleString();t=`[${r.app}] ${t}`,i.length?console[e](t,s,i):console[e](t,s)}static warn(e,...t){this.log(this.warnName,e,t)}static warnTime(e,t=[]){this.logTime(this.warnName,e,t)}constructor(e){a(this,"level",void 0),a(this,"prefix",void 0),this.level=r.defaultLevel,this.prefix="",e&&(this.prefix=`[${e}] `)}debug(e,...t){r.debugLevel>=this.level&&r.log(r.debugName,`${this.prefix}${e}`,t)}debugTime(e,...t){r.debugLevel>=this.level&&r.logTime(r.debugName,`${this.prefix}${e}`,t)}error(e,...t){r.errorLevel>=this.level&&r.log(r.errorName,`${this.prefix}${e}`,t)}errorTime(e,...t){r.errorLevel>=this.level&&r.logTime(r.errorName,`${this.prefix}${e}`,t)}info(e,...t){r.infoLevel>=this.level&&r.log(r.infoName,`${this.prefix}${e}`,t)}infoTime(e,...t){r.infoLevel>=this.level&&r.logTime(r.infoName,`${this.prefix}${e}`,t)}setLevel(e){this.level=e}warn(e,...t){r.warnLevel>=this.level&&r.log(r.warnName,`${this.prefix}${e}`,t)}warnTime(e,...t){r.warnLevel>=this.level&&r.logTime(r.warnName,`${this.prefix}${e}`,t)}}t.default=r,a(r,"app","APF"),a(r,"debugLevel",o.default.LOGGING_LEVELS.DEBUG),a(r,"debugName",o.default.loggingLevelName(r.debugLevel).toLowerCase()),a(r,"defaultLevel",o.default.LOGGING_LEVELS.WARN),a(r,"errorLevel",o.default.LOGGING_LEVELS.ERROR),a(r,"errorName",o.default.loggingLevelName(r.errorLevel).toLowerCase()),a(r,"infoLevel",o.default.LOGGING_LEVELS.INFO),a(r,"infoName",o.default.loggingLevelName(r.infoLevel).toLowerCase()),a(r,"warnLevel",o.default.LOGGING_LEVELS.WARN),a(r,"warnName",o.default.loggingLevelName(r.warnLevel).toLowerCase())},812:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s,o=(s=i(357))&&s.__esModule?s:{default:s};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}class r{static allLowerCase(e){return e.toLowerCase()===e}static allUpperCase(e){return e.toUpperCase()===e}static capitalizeEachWord(e){return e.split(/[-_ ]+/i).forEach((t=>{e=e.replace(t,this.capitalizeFirst(t))})),e}static capitalizeFirst(e){return e.charAt(0).toUpperCase()+e.substr(1)}static containsDoubleByte(e){return!!e.length&&(e.charCodeAt(0)>127||r._unicodeRegExp.test(e))}static eachWordCapitalized(e){return e.split(/[-_ ]+/i).every((e=>this.firstCapitalized(e)))}static escapeRegExp(e){return e.replace(r._escapeRegExp,"\\$&")}static firstCapitalized(e){return e.charAt(0).toUpperCase()===e.charAt(0)}constructor(e,t,i){a(this,"_filterMethod",void 0),a(this,"case",void 0),a(this,"escaped",void 0),a(this,"lists",void 0),a(this,"matchMethod",void 0),a(this,"matchRepeated",void 0),a(this,"matchSeparators",void 0),a(this,"regExp",void 0),a(this,"sub",void 0),a(this,"unicode",void 0),a(this,"value",void 0),this.value=e,this.case=t.case>o.default.FALSE?o.default.TRUE:o.default.FALSE,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=r.containsDoubleByte(e),this.escaped=this.matchMethod===o.default.MATCH_METHODS.REGEX?this.value:r.escapeRegExp(this.value),this.regExp=this.buildRegExp()}buildRegExp(){try{switch(this.matchMethod){case o.default.MATCH_METHODS.PARTIAL:return this._filterMethod===o.default.FILTER_METHODS.REMOVE?this.unicode?new RegExp("(^|"+r._unicodeWordBoundary+"?)([\\w-]*"+this.processedPhrase()+"[\\w-]*)("+r._unicodeWordBoundary+"?|$)",this.regexOptions()):this.hasEdgePunctuation()?new RegExp("(^|\\s)([\\w-]*"+this.processedPhrase()+"[\\w-]*)(\\s|$)",this.regexOptions()):new RegExp("\\s?\\b[\\w-]*"+this.processedPhrase()+"[\\w-]*\\b\\s?",this.regexOptions()):new RegExp(this.processedPhrase(),this.regexOptions());case o.default.MATCH_METHODS.WHOLE:return this.unicode?new RegExp("(^|"+r._unicodeWordBoundary+"*)([\\S]*"+this.processedPhrase()+"[\\S]*)("+r._unicodeWordBoundary+"*|$)",this.regexOptions()):this.hasEdgePunctuation()?new RegExp("(^|\\s)([\\S]*"+this.processedPhrase()+"[\\S]*)(\\s|$)",this.regexOptions()):new RegExp("\\b[\\w-]*"+this.processedPhrase()+"[\\w-]*\\b",this.regexOptions());case o.default.MATCH_METHODS.REGEX:return new RegExp(this.value,this.regexOptions());case o.default.MATCH_METHODS.EXACT:default:return this._filterMethod===o.default.FILTER_METHODS.REMOVE?this.unicode?new RegExp("(^|"+r._unicodeWordBoundary+")("+this.processedPhrase()+")("+r._unicodeWordBoundary+"|$)",this.regexOptions()):this.hasEdgePunctuation()?new RegExp("(^|\\s)("+this.processedPhrase()+")(\\s|$)",this.regexOptions()):new RegExp("\\s?\\b"+this.processedPhrase()+"\\b\\s?",this.regexOptions()):this.unicode?new RegExp("(^|"+r._unicodeWordBoundary+"+)("+this.processedPhrase()+")("+r._unicodeWordBoundary+"+|$)",this.regexOptions()):this.hasEdgePunctuation()?new RegExp("(^|\\s)("+this.processedPhrase()+")(\\s|$)",this.regexOptions()):new RegExp("\\b"+this.processedPhrase()+"\\b",this.regexOptions())}}catch(e){throw new Error(`Failed to create RegExp for '${this.value}'. [${e.name}: ${e.message}]`)}}hasEdgePunctuation(){return r._edgePunctuationRegExp.test(this.value)}processedPhrase(){const e=this.escaped.includes("\\");let t="";const i=this.escaped.length-1;for(let s=0;s{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=a(i(357)),o=a(i(812));function a(e){return e&&e.__esModule?e:{default:e}}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}const n=new(a(i(167)).default)("Wordlist");t.default=class{constructor(e,t){r(this,"all",void 0),r(this,"list",void 0),r(this,"regExps",void 0),this.all=[],this.list=[],this.regExps=[],n.setLevel(e.loggingLevel);Object.keys(e.words).sort(((e,t)=>t.length-e.length)).forEach((i=>{if(t===s.default.ALL_WORDS_WORDLIST_ID||!Array.isArray(e.words[i].lists)||e.words[i].lists.includes(t))try{const t=new o.default(i,e.words[i],e);this.list.push(i),this.all.push(t),this.regExps.push(t.regExp)}catch(e){n.warn(`Failed to add '${i}' to wordlist.`,e)}}))}find(e){return"string"==typeof e?this.all[this.list.indexOf(e)]:"number"==typeof e?this.all[e]:void 0}}},470:(e,t)=>{"use strict";function i(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 s{constructor(){i(this,"xpathDocText",void 0),i(this,"xpathNodeText",void 0)}static isForbiddenNode(e){return!!e.isContentEditable||(!(!e.parentNode||!e.parentNode.isContentEditable&&!s.forbiddenTags.includes(e.parentNode.nodeName))||s.forbiddenTags.includes(e.nodeName))}}t.default=s,i(s,"disabledProtocols",new RegExp("(^chrome:|^about:|^[a-zA-Z]+-extension:)","i")),i(s,"forbiddenNodeRegExp",new RegExp("^s*(<[a-z].+?/?>|{.+?:.+?;.*}|https?://[^s]+$)")),i(s,"forbiddenTags",["SCRIPT","STYLE","INPUT","TEXTAREA","IFRAME","LINK"])},210:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=l(i(357)),o=l(i(502)),a=i(582),r=l(i(167)),n=l(i(863));function l(e){return e&&e.__esModule?e:{default:e}}function d(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const u=new r.default("WebAudio");class c{constructor(e){d(this,"cueRuleIds",void 0),d(this,"enabledRuleIds",void 0),d(this,"fetching",void 0),d(this,"fillerAudio",void 0),d(this,"fillerAudioPauseHandler",void 0),d(this,"fillerAudioPlayHandler",void 0),d(this,"filter",void 0),d(this,"lastFilteredNode",void 0),d(this,"lastFilteredText",void 0),d(this,"lastProcessedText",void 0),d(this,"muted",void 0),d(this,"rules",void 0),d(this,"sites",void 0),d(this,"siteKey",void 0),d(this,"supportedPage",void 0),d(this,"unmuteTimeout",void 0),d(this,"volume",void 0),d(this,"watcherRuleIds",void 0),d(this,"wordlistId",void 0),d(this,"youTube",void 0),d(this,"youTubeAutoSubsMax",void 0),d(this,"youTubeAutoSubsMin",void 0),d(this,"youTubeAutoSubsRule",void 0),d(this,"youTubeAutoSubsTimeout",void 0),d(this,"youTubeAutoSubsUnmuteDelay",void 0),this.filter=e,u.setLevel(this.filter.cfg.loggingLevel),this.cueRuleIds=[],this.enabledRuleIds=[],this.watcherRuleIds=[],this.filter.extension&&(this.fillerAudio=this.initFillerAudio(this.filter.cfg.fillerAudio)),this.lastFilteredNode=null,this.lastFilteredText="",this.lastProcessedText="",this.muted=!1,e.cfg.customAudioSites&&"object"==typeof e.cfg.customAudioSites||(e.cfg.customAudioSites={}),this.sites=o.default.combineSites(e.cfg.customAudioSites),this.volume=1,this.wordlistId=e.audioWordlistId,this.youTubeAutoSubsMax=1e3*e.cfg.youTubeAutoSubsMax,this.youTubeAutoSubsMin=e.cfg.youTubeAutoSubsMin,this.youTubeAutoSubsUnmuteDelay=0,this.siteKey=this.getSiteKey(),this.rules=this.sites[this.siteKey],this.rules&&(Array.isArray(this.rules)||(this.rules=[this.rules]),this.rules.forEach((e=>{this.initRule(e)})),this.enabledRuleIds.length>0&&(this.supportedPage=!0,this.initYouTube()))}apfCaptionLine(e,t){const i=document.createElement("span");return i.classList.add("APF-subtitle-line"),i.style.background="black",i.style.color="white",i.style.fontSize="3.5vw",i.style.paddingLeft="4px",i.style.paddingRight="4px",i.style.height="18px",i.textContent=t,i}apfCaptionLines(e,t){const i=document.createElement("div");return i.classList.add("APF-subtitles"),i.style.bottom="10px",i.style.position="absolute",i.style.textAlign="center",i.style.width="100%",t.forEach((e=>{i.appendChild(e),i.appendChild(document.createElement("br"))})),i}clean(e,t=0){const i=this.rules[t];if("watcher"===i.mode)return;let s=!1;e.nodeName&&"#text"===e.nodeName&&e.parentElement&&(e=e.parentElement);const o=i.subtitleSelector&&e.querySelectorAll?e.querySelectorAll(i.subtitleSelector):[e];if(0===o.length)return;o.forEach((e=>{const t="#text"===e.nodeName?"textContent":"innerText";!0===i.convertBreaks&&"#text"!==e.nodeName&&!c.brTagRegExp.test(e[t])&&c.brTagRegExp.test(e.innerHTML)&&("pre"!==e.style.whiteSpace&&(e.style.whiteSpace="pre"),e.textContent=e.innerHTML.replace(c.brTagRegExp,"\n"));const o=this.replaceTextResult(e[t]);o.modified&&(s=!0,this.mute(i),i.filterSubtitles&&(i.preserveWhiteSpace&&"pre"!==e.style.whiteSpace&&(e.style.whiteSpace="pre"),i.ignoreMutations&&this.filter.stopObserving(),e[t]=o.filtered,i.ignoreMutations&&this.filter.startObserving()),this.lastFilteredNode=e,this.lastFilteredText=e[t]),s||this.lastFilteredNode!=e||this.lastFilteredText!=e[t]||(s=!0)})),s||this.lastFilteredNode&&document.body.contains(this.lastFilteredNode)&&this.lastFilteredNode.textContent===this.lastFilteredText&&(s=!0);this.subtitlesShouldBeShown(i,s)?this.showSubtitles(i,o):this.hideSubtitles(i,o)}cleanYouTubeAutoSubs(e){null!=this.youTubeAutoSubsTimeout&&(clearTimeout(this.youTubeAutoSubsTimeout),this.youTubeAutoSubsTimeout=null);const t=this.replaceTextResult(e.textContent);if(t.modified)this.youTubeAutoSubsRule.filterSubtitles&&(e.textContent=t.filtered),this.mute(this.youTubeAutoSubsRule),this.youTubeAutoSubsUnmuteDelay=null,this.filter.updateCounterBadge(),this.youTubeAutoSubsMax&&(this.youTubeAutoSubsTimeout=window.setTimeout(this.youTubeAutoSubsMuteTimeout,this.youTubeAutoSubsMax,this));else if(this.muted)if(this.youTubeAutoSubsMin>0){const e=document.getElementsByTagName(c.defaultVideoSelector)[0].currentTime;null==this.youTubeAutoSubsUnmuteDelay?this.youTubeAutoSubsUnmuteDelay=e:(ethis.youTubeAutoSubsUnmuteDelay+this.youTubeAutoSubsMin&&this.unmute(this.youTubeAutoSubsRule))}else this.unmute(this.youTubeAutoSubsRule);if(this.filter.cfg.showSubtitles!==s.default.SHOW_SUBTITLES.ALL){const e=document.querySelector("div.ytp-caption-window-rollup span.captions-text");"block"==e.style.display&&(e.style.display="none")}}clearUnmuteTimeout(e){e.unmuteDelay&&null!=this.unmuteTimeout&&(clearTimeout(this.unmuteTimeout),this.unmuteTimeout=null)}delayedUnmute(e,t){e.unmute(t,null,!0),this.unmuteTimeout=null}fillerAudioHandlePause(){this.fillerAudio.pause()}fillerAudioHandlePlay(){this.muted&&this.fillerAudio.play()}getSiteKey(){return this.sites.hasOwnProperty(this.filter.hostname)?this.filter.hostname:this.filter.iframe&&this.filter.iframe.hostname&&this.sites.hasOwnProperty(this.filter.iframe.hostname)?this.filter.iframe.hostname:""}getVideoTextTrack(e,t,i){let s=0,o=0,a=!1,r=0;i&&t[i]&&(r+=1e3),t.videoCueLabel&&(r+=100),t.videoCueLanguage&&(r+=10),t.videoCueKind&&(r+=1);for(let n=0;no||!a)&&(o=d,s=n,a=!0)}if(a)return e[s]}hideCue(e,t){t.text="",t.position=100,t.size=0}hideSubtitles(e,t){if(e.displayVisibility&&e._displayElement)e._displayElement.style.visibility="hidden";else if(e.displaySelector){const i=e.rootNode&&t&&t[0]?t[0].getRootNode():document;if(i){const t=i.querySelector(e.displaySelector);t&&(""===e.displayShow&&""!==t.style.display&&t.style.display!==e.displayHide&&(e.displayShow=t.style.display),t.style.setProperty("display",e.displayHide))}}else t&&t.forEach((t=>{t.innerText="",e.removeSubtitleSpacing&&t.style&&(t.style.padding&&(t.style.padding=0),t.style.margin&&(t.style.margin=0))}))}initCueRule(e){!0===e.apfCaptions&&(e.videoCueHideCues=!0),void 0===e.videoSelector&&(e.videoSelector=c.defaultVideoSelector),void 0===e.videoCueRequireShowing&&(e.videoCueRequireShowing=this.filter.cfg.muteCueRequireShowing),e.externalSub&&(void 0===e.externalSubTrackMode&&(e.externalSubTrackMode="showing"),void 0===e.externalSubURLKey&&(e.externalSubURLKey="url"),void 0===e.externalSubFormatKey&&(e.externalSubFormatKey="format"),void 0===e.externalSubTrackLabel&&(e.externalSubTrackLabel="APF"))}initDisplaySelector(e){void 0!==e.displaySelector&&(void 0===e.displayHide&&(e.displayHide="none"),void 0===e.displayShow&&(e.displayShow=""))}initDynamicRule(e){e._dynamic=!0,null==e.dynamicTargetMode&&e.disabled}initElementChildRule(e){e.parentSelector||e.parentSelectorAll||(e.disabled=!0)}initElementRule(e){}initFillerAudio(e=""){const t=c.fillerConfig[e];if(t){const e=chrome.runtime.getURL(t.fileName),i=new Audio;return i.src=e,i.loop=!0,t.volume&&(i.volume=t.volume),t.loopAfter&&(i.ontimeupdate=()=>{i.currentTime>t.loopAfter&&(i.currentTime=0)}),this.fillerAudioPauseHandler=this.fillerAudioHandlePause.bind(this),this.fillerAudioPlayHandler=this.fillerAudioHandlePlay.bind(this),i}}initRule(e){const t=this.rules.indexOf(e);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(null==e.filterSubtitles&&(e.filterSubtitles=!0),0==this.filter.filterText&&(e.filterSubtitles=!1),this.initDisplaySelector(e),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),e.disabled||this.cueRuleIds.push(t);break;case"dynamic":this.initDynamicRule(e);break;case"elementChild":this.initElementChildRule(e);break;case"element":this.initElementRule(e);break;case"text":this.initTextRule(e);break;case"watcher":this.initWatcherRule(e),e.disabled||this.watcherRuleIds.push(t)}e.disabled||(this.enabledRuleIds.push(t),"cue"==e.mode&&1===this.cueRuleIds.length?setInterval(this.watchForVideo,250,this):"watcher"==e.mode&&setInterval(this.watcher,e.checkInterval,this,t))}}initTextRule(e){e.tagName="#text",void 0===e.simpleUnmute&&(e.simpleUnmute=!0)}initWatcherRule(e){void 0===e.checkInterval&&(e.checkInterval=20),void 0===e.ignoreMutations&&(e.ignoreMutations=!0),void 0===e.simpleUnmute&&(e.simpleUnmute=!0),void 0===e.videoSelector&&(e.videoSelector=c.defaultVideoSelector)}initYouTube(){if(["m.youtube.com","tv.youtube.com","www.youtube.com"].includes(this.siteKey)){this.youTube=!0;const e="[ __ ]",t={lists:this.wordlistId===s.default.ALL_WORDS_WORDLIST_ID?[]:[this.wordlistId],matchMethod:s.default.MATCH_METHODS.PARTIAL,repeat:s.default.FALSE,separators:s.default.FALSE,sub:""};this.filter.cfg.addWord(e,t),this.youTubeAutoSubsRule={filterSubtitles:!0,mode:"ytauto",muteMethod:this.filter.cfg.muteMethod}}}mute(e,t){if(!this.muted){switch(this.muted=!0,this.filter.cfg.collectStats&&this.filter.stats.mutes++,e.muteMethod){case s.default.MUTE_METHODS.TAB:chrome.runtime.sendMessage({mute:!0});break;case s.default.MUTE_METHODS.VIDEO_MUTE:t||(t=document.querySelector(e&&e.videoSelector?e.videoSelector:c.defaultVideoSelector)),t&&!t.muted&&(t.muted=!0),this.fillerAudio&&this.playFillerAudio(t);break;case s.default.MUTE_METHODS.VIDEO_VOLUME:t||(t=document.querySelector(e&&e.videoSelector?e.videoSelector:c.defaultVideoSelector)),t&&null!=t.volume&&(this.volume=t.volume,t.volume=0),this.fillerAudio&&this.playFillerAudio(t)}u.debugTime("mute()")}e&&e.unmuteDelay&&this.unmuteTimeout&&this.clearUnmuteTimeout(e)}newCue(e,t,i,s={}){try{const o=new VTTCue((0,a.hmsToSeconds)(e),(0,a.hmsToSeconds)(t),i);return s.align&&(o.align=s.align),s.line&&(o.line=this.parseLineAndPositionSetting(s.line)),s.position&&(o.position=this.parseLineAndPositionSetting(s.position)),o}catch(s){u.error(`Failed to add cue: ( start: ${e}, end: ${t}, text: ${i} )`,s)}}newTextTrack(e,t,i){if(t.textTracks){const s=t.addTextTrack("captions",e.externalSubTrackLabel,e.videoCueLanguage);s.mode=e.externalSubTrackMode;for(let e=0;ee.trim())),i=[];let s=null,o=null,a=null;for(let e=0;e=0){const i=t[e].split(/[ \t]+-->[ \t]+/);if(2!=i.length)throw new Error(`Error when splitting "--\x3e": ${t[e]}.`);s=i[0],o=i[1]}else if(""==t[e]){if(s&&o){const e=this.newCue(s,o,a);i.push(e),s=null,o=null,a=null}}else s&&o&&(null==a?a=t[e]:a+="\n"+t[e]);if(s&&o){const e=this.newCue(s,o,a);i.push(e)}return i}parseSSA(e){const t=[];let i,s,o,a=!1;const r=e.split("\n");for(let e=0;ee.split(":"))).reduce(((e,t)=>(e[t[0]]=t[1],e)),{}),c=i[e-1].trim(),h=i[e+1].trim(),p=new RegExp(`^<[cs]\\.${c}>`),m=new RegExp("$");let f;if(f=h.match(p)?h.replace(p,"").replace(m,""):h,c&&!c.match(/_1$/)){const e=t[t.length-1];e.startTime!=(0,a.hmsToSeconds)(n)&&e.endTime==(0,a.hmsToSeconds)(l)&&(n=(0,a.secondsToHMS)(e.startTime))}const g=this.newCue(n,l,f,u);if(c&&!c.match(/_1$/)){const e=parseInt(c.match(/_([2-9])$/)[1]),i=t.length-e+1;t.splice(i,0,g)}else t.push(g);e++}}return t}playFillerAudio(e){this.playing(e)&&(this.fillerAudio.play(),e.addEventListener("pause",this.fillerAudioPauseHandler),e.addEventListener("play",this.fillerAudioPlayHandler))}playing(e){return!!(e&&e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>2)}processCues(e,t){for(let i=0;ie.language===t.videoCueLanguage));if(!s)throw new Error(`Failed to find subtitle for language: ${t.videoCueLanguage}.`);let o;if(this.fetching=!0,o="bookmarklet"==n.default.BUILD.target?await(0,a.makeRequest)(s[t.externalSubURLKey],"GET"):await(0,a.makeBackgroundRequest)(s[t.externalSubURLKey],"GET"),"string"!=typeof o||!o)throw new Error(`Failed to download external subtitles from '${s[t.externalSubURLKey]}'.`);{let i;switch(s[t.externalSubFormatKey]){case"ass":i=this.parseSSA(o);break;case"srt":i=this.parseSRT(o);break;case"vtt":i=this.parseVTT(o);break;default:throw new Error(`Unsupported subtitle type: ${s[t.externalSubFormatKey]}.`)}if(i){const s=this.newTextTrack(t,e,i).cues;if(this.processCues(s,t),this.fetching=!1,t.displaySelector){const e=document.querySelector(t.displaySelector);e&&(e.style.display="none")}}}}}catch(e){u.error(`Error using external subtitles for ${this.siteKey}.`,e)}}processWatcherCaptions(e,t,i){const s=i.initialCall;if(s){if(this.lastProcessedText&&this.lastProcessedText===t.textContent)return i.skipped=!0,!1;this.unmute(e),this.lastProcessedText="",i.initialCall=!1,i.filtered=!1}if(t.hasChildNodes())t.childNodes.forEach((t=>{this.processWatcherCaptions(e,t,i)}));else{const s="#text"===(t&&t.nodeName)?"textContent":"innerText";if(t[s]&&t[s].trim()){const o=this.replaceTextResult(t[s]);o.modified&&(this.mute(e),i.filtered=!0,e.filterSubtitles&&(t[s]=o.filtered))}}s&&(this.lastProcessedText=t.textContent)}processWatcherCaptionsArray(e,t,i){const s=t.map((e=>e.textContent)).join(" ");if(this.lastProcessedText&&this.lastProcessedText===s)return i.skipped=!0,!1;this.unmute(e),this.lastProcessedText="",i.filtered=!1,t.forEach((t=>{if(t.textContent&&t.textContent.trim()){const s=this.replaceTextResult(t.textContent);s.modified&&(this.mute(e),i.filtered=!0,e.filterSubtitles&&(t.textContent=s.filtered))}}));this.subtitlesShouldBeShown(e,i.filtered)?this.showSubtitles(e):this.hideSubtitles(e),this.lastProcessedText=t.map((e=>e.textContent)).join(" ")}replaceTextResult(e,t=this.wordlistId,i=s.default.STATS_TYPE_AUDIO){return this.filter.replaceTextResult(e,t,i)}showSubtitles(e,t){if(e.displayVisibility&&e._displayElement)e._displayElement.style.visibility="visible";else if(e.displaySelector){const i=e.rootNode&&t&&t[0]?t[0].getRootNode():document;if(i){const t=i.querySelector(e.displaySelector);t&&t.style.setProperty("display",e.displayShow)}}}stopFillerAudio(){this.fillerAudio.pause(),this.fillerAudio.currentTime=0}subtitlesShouldBeShown(e,t=!1){switch(e.showSubtitles){case s.default.SHOW_SUBTITLES.ALL:return!0;case s.default.SHOW_SUBTITLES.FILTERED:return t;case s.default.SHOW_SUBTITLES.UNFILTERED:return!t;case s.default.SHOW_SUBTITLES.NONE:return!1}}supportedNode(e){for(let t=0;t=0)return null==this.unmuteTimeout&&this.clearUnmuteTimeout(e),void(this.unmuteTimeout=window.setTimeout(this.delayedUnmute,e.unmuteDelay,this,e));switch(this.muted=!1,e.muteMethod){case s.default.MUTE_METHODS.TAB:chrome.runtime.sendMessage({mute:!1});break;case s.default.MUTE_METHODS.VIDEO_MUTE:this.fillerAudio&&this.stopFillerAudio(),t||(t=document.querySelector(e&&e.videoSelector?e.videoSelector:c.defaultVideoSelector)),t&&t.muted&&(t.muted=!1);break;case s.default.MUTE_METHODS.VIDEO_VOLUME:this.fillerAudio&&this.stopFillerAudio(),t||(t=document.querySelector(e&&e.videoSelector?e.videoSelector:c.defaultVideoSelector)),t&&null!=t.volume&&(t.volume=this.volume)}u.debugTime("unmute()")}}watcher(e,t=0){const i=e.rules[t],s=document.querySelector(i.videoSelector);if(s&&e.playing(s)){i.ignoreMutations&&e.filter.stopObserving();const t={initialCall:!0};let o,r;if(i.parentSelectorAll?(i._dynamic?(r=Array.from(document.querySelectorAll(i.parentSelectorAll)).filter((e=>e.textContent!==i.dynamicTextKey)),!i.displayVisibility||i._displayElement&&document.body.contains(i._displayElement)||(i._displayElement=(0,a.getParent)(r[0],i.getParentLevel))):r=Array.from(document.querySelectorAll(i.parentSelectorAll)),o=r.map((e=>e.querySelector(i.subtitleSelector))),o.length?e.processWatcherCaptionsArray(i,o,t):e.watcherSimpleUnmute(i,s)):i.parentSelector?(o=document.querySelector(i.parentSelector),o&&o.textContent&&o.textContent.trim()?e.processWatcherCaptions(i,o,t):e.watcherSimpleUnmute(i,s)):i.subtitleSelector&&(o=Array.from(document.querySelectorAll(i.subtitleSelector)),o&&o.length?(!i.displayVisibility||i._displayElement&&document.body.contains(i._displayElement)||(i._displayElement=(0,a.getParent)(o[0],i.displayElementLevels)),e.processWatcherCaptionsArray(i,o,t)):e.watcherSimpleUnmute(i,s)),t.skipped)return!1;e.subtitlesShouldBeShown(i,t.filtered)?e.showSubtitles(i):e.hideSubtitles(i),t.filtered&&e.filter.updateCounterBadge()}else i.ignoreMutations&&e.filter.startObserving()}watchForVideo(e){for(let t=0;t{if(t.activeCues&&t.activeCues.length>0){const s=Array.from(t.activeCues),a=[];if(!s.some((e=>e.hasOwnProperty("filtered")))){const s=Array.from(t.cues);e.processCues(s,i)}const r=s.some((e=>e.filtered));r?e.mute(i,o):e.unmute(i,o);const n=e.subtitlesShouldBeShown(i,r);for(let t=0;ts.default.SHOW_SUBTITLES.ALL&&this.hideSubtitles(e)}youTubeAutoSubsCurrentRow(e){return!(e.parentElement.parentElement!=e.parentElement.parentElement.parentElement.lastChild)}youTubeAutoSubsMuteTimeout(e){const t=window.document.querySelector(c.defaultVideoSelector);t&&e.playing(t)&&e.unmute(e.youTubeAutoSubsRule),e.youTubeAutoSubsTimeout=null}youTubeAutoSubsNodeIsSubtitleText(e){const 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=c,d(c,"brTagRegExp",new RegExp("
","i")),d(c,"defaultVideoSelector","video"),d(c,"fillerConfig",{beep:{fileName:"audio/beep.mp3",volume:.2},crickets:{fileName:"audio/crickets.mp3",volume:.4},static:{fileName:"audio/static.mp3",volume:.3}}),d(c,"textTrackRuleMappings",{externalSubTrackLabel:"label",videoCueKind:"kind",videoCueLabel:"label",videoCueLanguage:"language"})},502:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s,o=(s=i(357))&&s.__esModule?s:{default:s};class a{static combineSites(e={}){return Object.assign({},a.sites,e)}}t.default=a,function(e,t,i){t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i}(a,"sites",{"abc.com":[{className:"akamai-caption-text",mode:"element",tagName:"DIV"},{className:"amp-caption-area",displaySelector:"div.amp-caption-area",mode:"element",muteMethod:o.default.MUTE_METHODS.VIDEO_VOLUME,subtitleSelector:"div.amp-caption > p",tagName:"DIV"}],"iview.abc.net.au":[{mode:"element",subtitleSelector:"div.jw-text-track-cue",tagName:"div"}],"acorn.tv":[{iframe:!0,mode:"elementChild",parentSelector:"div.vjs-text-track-display",simpleUnmute:!0,subtitleSelector:":scope div > div",tagName:"DIV"}],"smile.amazon.com":[{displayHide:"none",displaySelector:"div.webPlayerContainer div.f35bt6a",displayShow:"",iframe:!1,mode:"watcher",parentSelector:"div.webPlayerContainer div span > span",videoSelector:"div.webPlayerElement video[src]"}],"www.amazon.co.uk":[{displayHide:"none",displaySelector:"div.webPlayerContainer div.f35bt6a",displayShow:"",iframe:!1,mode:"watcher",parentSelector:"div.webPlayerContainer div span > span",videoSelector:"div.webPlayerElement video[src]"}],"www.amazon.com":[{displayHide:"none",displaySelector:"div.webPlayerContainer div.f35bt6a",displayShow:"",iframe:!1,mode:"watcher",parentSelector:"div.webPlayerContainer div span > span",videoSelector:"div.webPlayerElement video[src]"}],"www.amc.com":[{className:"ttr-container",mode:"element",subtitleSelector:"span.ttr-cue",tagName:"DIV"},{mode:"cue",videoCueLanguage:"en",videoSelector:"video"}],"tv.apple.com":[{displaySelector:"div.video-container > div > div > div",mode:"elementChild",muteMethod:o.default.MUTE_METHODS.TAB,parentSelector:"div.video-container",preserveWhiteSpace:!0,rootNode:!0,subtitleSelector:"div > div > div > div > div",tagName:"DIV"},{displaySelector:"div.video-container > div > div > div",mode:"elementChild",muteMethod:o.default.MUTE_METHODS.TAB,parentSelector:"div.video-container",preserveWhiteSpace:!0,rootNode:!0,subtitleSelector:"div > div > div > div > span",tagName:"DIV"}],"www.att.tv":[{mode:"cue",videoSelector:"video#quickplayPlayer"}],"www.attwatchtv.com":[{mode:"cue",videoSelector:"video#quickplayPlayer"}],"www.bbc.co.uk":[{mode:"element",subtitleSelector:"div.p_cueDirUniWrapper span",tagName:"div"}],"www.britbox.com":[{className:"bmpui-ui-subtitle-label",mode:"element",tagName:"SPAN"},{className:"bmpui-subtitle-region-container",mode:"element",subtitleSelector:"div.bmpui-container-wrapper > span.bmpui-ui-subtitle-label",tagName:"div"}],"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.channel4.com":[{displaySelector:"div.subtitles-container",mode:"elementChild",parentSelector:"div.subtitles-container",tagName:"SPAN"}],"www.crackle.com":[{ignoreMutations:!0,mode:"elementChild",parentSelector:"div.clpp-subtitles-container",simpleUnmute:!0,tagName:"#text"}],"www.criterionchannel.com":[{iframe:!0,mode:"cue",videoCueHideCues:!0,videoCueRequireShowing:!1}],"beta.crunchyroll.com":[{apfCaptions:!0,apfCaptionsSelector:"vilosVttJs",displaySelector:"canvas#velocity-canvas",externalSub:!0,externalSubTrackMode:"hidden",externalSubVar:"window.v1config.media.subtitles",iframe:!0,mode:"cue",videoCueLanguage:"en-US",videoCueRequireShowing:!1}],"www.crunchyroll.com":[{apfCaptions:!0,apfCaptionsSelector:"vilosVttJs",displaySelector:"canvas#velocity-canvas",externalSub:!0,externalSubTrackMode:"hidden",externalSubVar:"window.v1config.media.subtitles",iframe:!0,mode:"cue",videoCueLanguage:"enUS",videoCueRequireShowing:!1,videoSelector:"video#player0"}],"www.cwtv.com":[{className:"ttr-container",convertBreaks:!0,mode:"element",subtitleSelector:"span.ttr-cue",tagName:"DIV"},{className:"ttr-line",convertBreaks:!0,mode:"element",note:"[CC]",subtitleSelector:"span.ttr-cue",tagName:"DIV"}],"www.discoveryplus.com":[{displaySelector:"div.cjRVXG",mode:"cue",videoCueKind:"captions",videoCueLanguage:"en"}],"www.dishanywhere.com":[{className:"bmpui-ui-subtitle-label",mode:"element",tagName:"SPAN"},{className:"bmpui-subtitle-region-container",mode:"element",subtitleSelector:"div.bmpui-container-wrapper > span.bmpui-ui-subtitle-label",tagName:"div"}],"www.disneyplus.com":[{className:"dss-subtitle-renderer-wrapper",mode:"element",subtitleSelector:"div.dss-subtitle-renderer-cue-window span.dss-subtitle-renderer-line",tagName:"DIV"}],"www.fox.com":[{className:"jw-text-track-container",mode:"element",subtitleSelector:"div.jw-text-track-cue",tagName:"DIV"}],"www.fubo.tv":[{displayHide:"none",displaySelector:"div.bmpui-ui-subtitle-overlay",iframe:!1,mode:"watcher",parentSelector:"div.bmpui-ui-subtitle-overlay",subtitleSelector:"div.bmpui-ui-subtitle-overlay span"}],"www.funimation.com":[{displaySelector:"div > div.vjs-text-track-cue",mode:"element",subtitleSelector:"div.vjs-text-track-cue > div",tagName:"DIV"},{iframe:!0,mode:"elementChild",note:"Embedded videos",parentSelector:"div.vjs-text-track-display",simpleUnmute:!0,subtitleSelector:":scope div > div",tagName:"DIV"}],"play.google.com":[{className:"lava-timed-text-window",mode:"element",subtitleSelector:"span.lava-timed-text-caption",tagName:"DIV"}],"play.hbomax.com":[{displayElementLevels:5,displayVisibility:!0,mode:"watcher",showSubtitles:o.default.SHOW_SUBTITLES.ALL,subtitleSelector:"span[style^='font-family: font']"}],"www.hulu.com":[{className:"caption-text-box",displaySelector:"div.caption-text-box",mode:"element",subtitleSelector:"p",tagName:"DIV"},{displaySelector:"div.CaptionBox",mode:"elementChild",parentSelector:"div.CaptionBox",tagName:"P"}],"www.itv.com":[{mode:"cue",videoCueLanguage:"en"}],"www.nbc.com":[{className:"ttr-line",mode:"element",subtitleSelector:"span.ttr-cue",tagName:"DIV"},{mode:"cue",videoCueLanguage:"en"}],"www.netflix.com":[{className:"player-timedtext-text-container",mode:"element",subtitleSelector:"span",tagName:"DIV"}],"www.paramountplus.com":[{mode:"cue",videoCueHideCues:!0,videoCueLanguage:"en",videoCueRequireShowing:!1}],"www.pbs.org":[{iframe:!0,mode:"element",subtitleSelector:"div.vjs-text-track-cue > div",tagName:"DIV"}],"www.peacocktv.com":[{displaySelector:"div.video-player__subtitles",mode:"elementChild",parentSelector:"div.video-player__subtitles > div",simpleUnmute:!0,tagName:"#text"},{displaySelector:"div.video-player__subtitles",mode:"elementChild",parentSelector:"div.video-player__subtitles > div",subtitleSelector:"SPAN > SPAN",tagName:"DIV"},{displaySelector:"div.video-player__subtitles",mode:"elementChild",parentSelector:"div.video-player__subtitles > div",tagName:"SPAN"}],"www.philo.com":[{mode:"cue"}],"app.plex.tv":[{dataPropPresent:"dialogueId",mode:"element",subtitleSelector:"span > span",tagName:"DIV"},{containsSelector:"div[data-dialogue-id]",mode:"element",subtitleSelector:"span > span",tagName:"DIV"}],"pluto.tv":[{mode:"cue",videoCueHideCues:!0,videoCueRequireShowing:!1}],"www.primevideo.com":[{displayHide:"none",displaySelector:"div.webPlayerContainer div.f35bt6a",displayShow:"",iframe:!1,mode:"watcher",parentSelector:"div.webPlayerContainer div span > span",videoSelector:"div.webPlayerElement video[src]"}],"www.redbox.com":[{mode:"elementChild",parentSelector:"div.rb-text-container",subtitleSelector:"SPAN > SPAN",tagName:"DIV"}],"watch.redeemtv.com":[{convertBreaks:!0,displaySelector:"div.vp-captions",mode:"elementChild",parentSelector:"div.vp-captions",tagName:"SPAN"}],"therokuchannel.roku.com":[{mode:"element",subtitleSelector:"div.vjs-text-track-cue > div",tagName:"DIV"}],"www.sbs.com.au":[{className:"bmpui-subtitle-region-container",mode:"element",subtitleSelector:"DIV.bmpui-container-wrapper > SPAN.bmpui-ui-subtitle-label > SPAN",tagName:"DIV"}],"www.showmax.com":[{ignoreMutations:!0,mode:"elementChild",parentSelector:"div.contentWrapper > div.subtitles--3EXhT",simpleUnmute:!0,tagName:"#text"}],"www.showtime.com":[{mode:"cue",videoCueHideCues:!0,videoCueLanguage:"en",videoCueRequireShowing:!1}],"play.stan.com.au":[{ignoreMutations:!0,mode:"elementChild",parentSelector:"div.clpp-subtitles-container",simpleUnmute:!0,tagName:"#text"}],"www.starz.com":[{mode:"elementChild",parentSelector:"starz-captions > div.cue-list",tagName:"SPAN"}],"www.syfy.com":[{className:"ttr-line",mode:"element",subtitleSelector:"span.ttr-cue",tagName:"DIV"}],"www.tntdrama.com":[{mode:"cue",videoCueLanguage:"en",videoSelector:"video.top-media-element"}],"tubitv.com":[{mode:"elementChild",parentSelector:"div#captionsComponent",tagName:"SPAN"}],"www.universalkids.com":[{mode:"element",subtitleSelector:"div.gwt-HTML",tagName:"DIV"}],"www.usanetwork.com":[{className:"ttr-line",mode:"element",subtitleSelector:"span.ttr-cue",tagName:"DIV"}],"www.vudu.com":[{mode:"element",subtitleSelector:"span.subtitles",tagName:"DIV"}],"vrv.co":[{displaySelector:"div.libassjs-canvas-parent",externalSub:!0,externalSubVar:"window.vilos.content.captions",iframe:!0,mode:"cue",videoCueLanguage:"en-US",videoCueRequireShowing:!1},{displaySelector:"div.libassjs-canvas-parent",externalSub:!0,externalSubVar:"window.vilos.content.subtitles",iframe:!0,mode:"cue",videoCueLanguage:"en-US",videoCueRequireShowing:!1}],"m.youtube.com":[{className:"caption-window",mode:"element",subtitleSelector:"span.ytp-caption-segment",tagName:"DIV"}],"tv.youtube.com":[{className:"caption-window",mode:"element",subtitleSelector:"span.ytp-caption-segment",tagName:"DIV"}],"www.youtube.com":[{className:"caption-window",mode:"element",subtitleSelector:"span.ytp-caption-segment",tagName:"DIV"}]})},863:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=d(i(357)),o=d(i(513)),a=i(582),r=d(i(167)),n=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var i=l(t);if(i&&i.has(e))return i.get(e);var s={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var r=o?Object.getOwnPropertyDescriptor(e,a):null;r&&(r.get||r.set)?Object.defineProperty(s,a,r):s[a]=e[a]}s.default=e,i&&i.set(e,s);return s}(i(178));function l(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(l=function(e){return e?i:t})(e)}function d(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}const c=new r.default("WebConfig");class h extends o.default{static get _maxBytes(){try{if(chrome.storage.sync.QUOTA_BYTES_PER_ITEM)return Math.round(.98*chrome.storage.sync.QUOTA_BYTES_PER_ITEM);throw"QUOTA_BYTES_PER_ITEM not defined, using default"}catch(e){return 8028}}static chromeStorageAvailable(){return!!(chrome&&chrome.storage&&chrome.storage.sync&&chrome.storage.local)}static combineData(e,t){if(e[t]={},void 0!==e[`_${t}0`]){const i=h.getDataContainerKeys(e,t);return i.forEach((i=>{Object.assign(e[t],e[i]),delete e[i]})),i}}static getDataContainerKeys(e,t){const i=new RegExp(`^_${t}\\d+`);return Object.keys(e).filter((e=>i.test(e))).sort()}static getLocalStorage(e){return"string"==typeof e&&(e=[e]),new Promise(((t,i)=>{chrome.storage.local.get(e,(e=>{chrome.runtime.lastError?i(chrome.runtime.lastError):t(e)}))}))}static getMaxSplitKeyFromArray(e=[]){if(Array.isArray(e)){const t=e.sort()[e.length-1];if(t){const e=new RegExp("\\d+$"),i=t.match(e);if(i)return parseInt(i[0])}}}static getMaxSplitKeyFromData(e,t){const i=h.getDataContainerKeys(e,t);return h.getMaxSplitKeyFromArray(i)}static getSyncStorage(e){return"string"==typeof e&&(e=[e]),new Promise(((t,i)=>{chrome.storage.sync.get(e,(e=>{chrome.runtime.lastError?i(chrome.runtime.lastError):t(e)}))}))}static includesLargeKeys(e){return e.some((e=>h._largeKeys.includes(e)))}static async load(e=[]){e=(0,a.stringArray)(e);const t={};let i;const s=[];let o=[];0===e.length&&(e=Object.keys(h._defaults)).push("words");try{if(h.includesLargeKeys(e)?(e.includes("syncLargeKeys")||e.push("syncLargeKeys"),h._localConfigKeys.forEach((t=>{e.includes(t)&&s.push(t)})),i=await h.getLocalStorage(s),t.syncLargeKeys=!1===i.syncLargeKeys?i.syncLargeKeys:h._defaults.syncLargeKeys,!1===t.syncLargeKeys?(s.forEach((e=>{void 0===i[e]?t[e]="words"===e?h._defaultWords:h._defaults[e]:t[e]=i[e]})),o=e.filter((e=>!h._localConfigKeys.includes(e)))):o=e.filter((e=>"syncLargeKeys"!==e))):o=e.filter((e=>"syncLargeKeys"!==e)),o.length){let e=[].concat(o);h._largeKeys.forEach((t=>{o.includes(t)&&(e.splice(e.indexOf(t),1),e=e.concat(h.splitKeyNames(t)))}));const i=await h.getSyncStorage(e);t._lastSplitKeys={},o.forEach((e=>{if(h._largeKeys.includes(e)){const s=h.combineData(i,e);s?(t._lastSplitKeys[e]=h.getMaxSplitKeyFromArray(s),t[e]=i[e]):(t._lastSplitKeys[e]=0,t[e]="words"===e?h._defaultWords:h._defaults[e])}else void 0===i[e]?t[e]=h._defaults[e]:t[e]=i[e]}))}return new h(t)}catch(t){throw c.error("Failed to load items.",e,t),new Error(`Failed to load items: ${(0,a.prettyPrintArray)(e)}. [${t.message}]`)}}static removeLocalStorage(e){return e=(0,a.stringArray)(e),new Promise(((t,i)=>{chrome.storage.local.remove(e,(()=>{chrome.runtime.lastError?i(chrome.runtime.lastError):t(0)}))}))}static removeSyncStorage(e){return e=(0,a.stringArray)(e),new Promise(((t,i)=>{chrome.storage.sync.remove(e,(()=>{chrome.runtime.lastError?i(chrome.runtime.lastError):t(0)}))}))}static resetLocalStorage(){return new Promise(((e,t)=>{chrome.storage.local.clear((()=>{chrome.runtime.lastError?t(chrome.runtime.lastError):e(0)}))}))}static resetSyncStorage(){return new Promise(((e,t)=>{chrome.storage.sync.clear((()=>{chrome.runtime.lastError?t(chrome.runtime.lastError):e(0)}))}))}static saveLocalStorage(e){return new Promise(((t,i)=>{chrome.storage.local.set(e,(()=>{chrome.runtime.lastError?i(chrome.runtime.lastError):t(0)}))}))}static saveSyncStorage(e){return new Promise(((t,i)=>{chrome.storage.sync.set(e,(()=>{chrome.runtime.lastError?i(chrome.runtime.lastError):t(0)}))}))}static splitKeyNames(e,t=0){return Array(this._maxSplitKeys-t).fill(1).map(((i,s)=>"_"+e+(s+t)))}constructor(e){if(void 0===e)throw new Error("Cannot be called directly, call load() instead.");super(),u(this,"_lastSplitKeys",void 0),u(this,"audioWordlistId",void 0),u(this,"collectStats",void 0),u(this,"contextMenu",void 0),u(this,"customAudioSites",void 0),u(this,"darkMode",void 0),u(this,"domains",void 0),u(this,"enabledDomainsOnly",void 0),u(this,"fillerAudio",void 0),u(this,"muteAudio",void 0),u(this,"muteAudioOnly",void 0),u(this,"muteCueRequireShowing",void 0),u(this,"muteMethod",void 0),u(this,"password",void 0),u(this,"showSubtitles",void 0),u(this,"showUpdateNotification",void 0),u(this,"syncLargeKeys",void 0),u(this,"youTubeAutoSubsMax",void 0),u(this,"youTubeAutoSubsMin",void 0),Object.assign(this,h._classDefaults,e)}ordered(){return Object.keys(this).sort().reduce(((e,t)=>("_"!=t[0]&&(e[t]=this[t]),e)),{})}async remove(e){e=(0,a.stringArray)(e);let t=[];const i=[];if(e.length>0){e.forEach((e=>{"syncLargeKeys"==e?i.push(e):h._largeKeys.includes(e)?this.syncLargeKeys?t=t.concat(h.splitKeyNames(e)):i.push(e):t.push(e)}));try{t.length&&await h.removeSyncStorage(t),i.length&&await h.removeLocalStorage(i),e.forEach((e=>{delete this[e]}))}catch(t){throw c.error("Failed to remove items.",e,t),new Error(`Failed to remove items: ${(0,a.prettyPrintArray)(e)}. ${t.message}`)}}}async reset(){try{await h.resetSyncStorage(),await h.resetLocalStorage()}catch(e){throw c.error("Failed to clear storage.",e),new Error(`Failed to clear storage. ${e.message}`)}}async resetPreserveStats(){try{await h.resetSyncStorage(),await h.removeLocalStorage(h._localConfigKeys)}catch(e){throw c.error("Failed to clear storage.",e),new Error(`Failed to clear storage. ${e.message}`)}}async save(e=[]){e=(0,a.stringArray)(e);const t={},i={};0===e.length&&(e=Object.keys(h._defaults)).push("words");let s=[];e.forEach((e=>{if("syncLargeKeys"==e)i[e]=this[e];else if(h._largeKeys.includes(e))if(this.syncLargeKeys){if(Object.assign(t,this.splitData(e)),this._lastSplitKeys){const i=h.getMaxSplitKeyFromData(t,e);this._lastSplitKeys[e]>i?s=s.concat(h.splitKeyNames(e,i+1)):this._lastSplitKeys[e]null==i[e])),s=Object.keys(t).filter((e=>null==t[e]));e.length&&(await h.removeLocalStorage(e),e.forEach((e=>delete i[e]))),s.length&&(await h.removeSyncStorage(s),s.forEach((e=>delete t[e])))}Object.keys(t).length&&await h.saveSyncStorage(t),Object.keys(i).length&&await h.saveLocalStorage(i),s.length&&await this.remove(s)}catch(t){throw c.error("Failed to save items.",e,t),new Error(`Failed to save items: ${(0,a.prettyPrintArray)(e)}. [${t.message}]`)}}splitData(e){const t=new TextEncoder;let i=0,s=2;const o={};let a=`_${e}${i}`;return o[a]={},s+=t.encode(`{"${a}":{}}`).length,Object.keys(this[e]).sort().forEach((r=>{let n=t.encode(`",${r}":`).length;n+=t.encode(JSON.stringify(this[e][r])).length,s+n>=h._maxBytes&&(i++,a=`_${e}${i}`,o[a]={},s=t.encode(`"${a}":{}`).length),s+=n,o[a][r]=this[e][r]})),o}}t.default=h,u(h,"BUILD",n),u(h,"_classDefaults",{audioWordlistId:0,collectStats:!0,contextMenu:!0,customAudioSites:null,darkMode:null,domains:{},enabledDomainsOnly:!1,fillerAudio:"",muteAudio:!1,muteAudioOnly:!1,muteCueRequireShowing:!1,muteMethod:h.BUILD.config.muteMethod||s.default.MUTE_METHODS.TAB,password:null,showSubtitles:s.default.SHOW_SUBTITLES.ALL,showUpdateNotification:!1,syncLargeKeys:!0,youTubeAutoSubsMax:0,youTubeAutoSubsMin:0}),u(h,"_defaults",Object.assign({},o.default._defaults,h._classDefaults)),u(h,"_localConfigKeys",["domains","syncLargeKeys","words"]),u(h,"_localOnlyKeys",["background","stats"]),u(h,"_maxSplitKeys",64),u(h,"_largeKeys",["domains","words"])},894:function(){ +(()=>{var e={50:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s,o=(s=i(357))&&s.__esModule?s:{default:s};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}class r{static byHostname(e,t){const i=r.findDomainKey(e,t)||e,s=r.byKey(i,t);return s.hostname=e,s}static byKey(e,t){return new r(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(((e,t)=>{chrome.tabs.query({active:!0,currentWindow:!0},(t=>{e(t[0])}))}))}static sortedKeys(e){const t=new RegExp("(\\w+?[.]|)\\w+?$");return Object.keys(e).sort(((e,i)=>{const s=e.match(t),o=i.match(t),a=s?s[0]:e,r=o?o[0]:i;return ar?1:0}))}constructor(e,t){a(this,"advanced",void 0),a(this,"audioWordlistId",void 0),a(this,"cfg",void 0),a(this,"cfgKey",void 0),a(this,"deep",void 0),a(this,"disabled",void 0),a(this,"enabled",void 0),a(this,"hostname",void 0),a(this,"tab",void 0),a(this,"wordlistId",void 0),this.cfgKey=e,this.cfg={},t?this.cfg=t:Object.assign(this.cfg,r._domainCfgDefaults),this.updateFromCfg()}getModeIndex(){return this.advanced?o.default.DOMAIN_MODES.ADVANCED:this.deep?o.default.DOMAIN_MODES.DEEP:o.default.DOMAIN_MODES.NORMAL}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.deep=!0===this.deep||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.deep=this.cfg.deep,this.disabled=this.cfg.disabled,this.enabled=this.cfg.enabled,this.wordlistId=this.cfg.wordlist,this.audioWordlistId=this.cfg.audioList}updateFromModeIndex(e){switch(e){case o.default.DOMAIN_MODES.NORMAL:this.advanced=!1,this.deep=!1;break;case o.default.DOMAIN_MODES.ADVANCED:this.advanced=!0,this.deep=!1;break;case o.default.DOMAIN_MODES.DEEP:this.advanced=!1,this.deep=!0}}}t.default=r,a(r,"_domainCfgDefaults",{adv:void 0,audioList:void 0,deep:void 0,disabled:void 0,enabled:void 0,wordlist:void 0})},513:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s,o=(s=i(357))&&s.__esModule?s:{default:s};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}class r{constructor(e={}){a(this,"censorCharacter",void 0),a(this,"censorFixedLength",void 0),a(this,"defaultSubstitution",void 0),a(this,"defaultWordMatchMethod",void 0),a(this,"defaultWordRepeat",void 0),a(this,"defaultWordSeparators",void 0),a(this,"filterMethod",void 0),a(this,"filterWordList",void 0),a(this,"iWordWhitelist",void 0),a(this,"loggingLevel",void 0),a(this,"preserveCase",void 0),a(this,"preserveFirst",void 0),a(this,"preserveLast",void 0),a(this,"showCounter",void 0),a(this,"showSummary",void 0),a(this,"substitutionMark",void 0),a(this,"wordlistId",void 0),a(this,"wordlists",void 0),a(this,"wordlistsEnabled",void 0),a(this,"words",void 0),a(this,"wordWhitelist",void 0),Object.assign(this,r._defaults,e)}addWord(e,t=this.defaultWordOptions()){return e=e.trim(),(t=Object.assign({},this.defaultWordOptions(),t)).matchMethod!==o.default.MATCH_METHODS.REGEX&&(e=e.toLowerCase()),!Object.keys(this.words).includes(e)&&(t.sub=t.case==o.default.TRUE?t.sub.trim():t.sub.trim().toLowerCase(),this.words[e]=t,!0)}defaultWordOptions(){return{lists:[],matchMethod:this.defaultWordMatchMethod,repeat:this.defaultWordRepeat,separators:this.defaultWordSeparators,sub:""}}removeWord(e){const t=(e=e.trim()).toLowerCase();return Object.keys(this.words).includes(t)?(delete this.words[t],!0):!!this.words[e]&&(delete this.words[e],!0)}repeatForWord(e){return this.words[e].repeat===o.default.TRUE||this.words[e].repeat===o.default.FALSE?this.words[e].repeat:this.defaultWordRepeat}sanitizeWords(){const e={};Object.keys(this.words).sort().forEach((t=>{e[t.trim().toLowerCase()]=this.words[t]})),this.words=e}}t.default=r,a(r,"_allWordlists",["All words"]),a(r,"_defaults",{censorCharacter:"*",censorFixedLength:0,defaultSubstitution:"censored",defaultWordMatchMethod:o.default.MATCH_METHODS.EXACT,defaultWordRepeat:o.default.FALSE,defaultWordSeparators:o.default.FALSE,filterMethod:o.default.FILTER_METHODS.SUBSTITUTE,filterWordList:!0,iWordWhitelist:[],loggingLevel:o.default.LOGGING_LEVELS.WARN,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:[]}),a(r,"_defaultWords",{ass:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"butt"},asses:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.FALSE,separators:o.default.FALSE,sub:"butts"},asshole:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"jerk"},badass:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.TRUE,sub:"cool"},bastard:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"idiot"},bitch:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"bench"},cocksucker:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.TRUE,sub:"suckup"},cunt:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"expletive"},dammit:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.FALSE,separators:o.default.TRUE,sub:"dangit"},damn:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.FALSE,separators:o.default.FALSE,sub:"dang"},dumbass:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"idiot"},fag:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"gay"},faggot:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"gay"},fags:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"gays"},fuck:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.TRUE,sub:"freak"},goddammit:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.TRUE,sub:"dangit"},hell:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.FALSE,separators:o.default.FALSE,sub:"heck"},jackass:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.TRUE,sub:"jerk"},nigga:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"bruh"},nigger:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"man"},niggers:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"people"},piss:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"pee"},pissed:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"ticked"},pussies:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"softies"},pussy:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"softie"},shit:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"crap"},slut:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"tramp"},tits:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"chest"},twat:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"dumbo"},twats:{lists:[],matchMethod:o.default.MATCH_METHODS.EXACT,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"dumbos"},whore:{lists:[],matchMethod:o.default.MATCH_METHODS.PARTIAL,repeat:o.default.TRUE,separators:o.default.FALSE,sub:"tramp"}})},357:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=i(582);function o(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{static filterMethodName(e){return this.nameById(this.FILTER_METHODS,e)}static loggingLevelName(e){return this.nameByValue(this.LOGGING_LEVELS,e)}static matchMethodName(e){return this.nameById(this.MATCH_METHODS,e)}static nameById(e,t){return(0,s.upperCaseFirst)(Object.entries(e).filter((e=>e[1]===t))[0][0])}static nameByValue(e,t){return Object.keys(e).find((i=>e[i]==t))}static orderedArray(e){const t=[];return Object.values(e).sort().forEach((i=>{t.push(a.nameById(e,i))})),t}}t.default=a,o(a,"ALL_WORDS_WORDLIST_ID",0),o(a,"DOMAIN_MODES",{NORMAL:0,ADVANCED:1,DEEP:2}),o(a,"FALSE",0),o(a,"FILTER_METHODS",{CENSOR:0,SUBSTITUTE:1,REMOVE:2,OFF:3}),o(a,"LOGGING_LEVELS",{DEBUG:0,INFO:1,WARN:2,ERROR:3}),o(a,"MATCH_METHODS",{EXACT:0,PARTIAL:1,WHOLE:2,REGEX:3}),o(a,"MUTE_METHODS",{TAB:0,VIDEO_VOLUME:1,VIDEO_MUTE:2,NONE:9}),o(a,"SHOW_SUBTITLES",{ALL:0,FILTERED:1,UNFILTERED:2,NONE:3}),o(a,"STATS_TYPE_AUDIO","audio"),o(a,"STATS_TYPE_TEXT","text"),o(a,"TRUE",1)},394:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=r(i(357)),o=r(i(812)),a=r(i(709));function r(e){return e&&e.__esModule?e:{default:e}}function l(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(){l(this,"cfg",void 0),l(this,"counter",void 0),l(this,"iWhitelist",void 0),l(this,"whitelist",void 0),l(this,"wordlistId",void 0),l(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 a.default(this.cfg,e)),e}checkWhitelist(e,t,i,a){const r=this.whitelist.length,l=this.iWhitelist.length;if(r||l){if(r&&this.whitelist.includes(e))return!0;if(l&&this.iWhitelist.includes(e.toLowerCase()))return!0;if(a.matchMethod===s.default.MATCH_METHODS.PARTIAL){const a={matchMethod:s.default.MATCH_METHODS.WHOLE,repeat:s.default.FALSE,separators:s.default.FALSE,sub:""},n=new o.default(e,a,this.cfg).regExp;let d;for(;null!==(d=n.exec(t));){const t=4==d.length?d[2]:d[0],s=4==d.length?d.index+d[1].length:d.index;if(s<=i&&s+t.length>=i+e.length){if(r&&this.whitelist.includes(t))return!0;if(l&&this.iWhitelist.includes(t.toLowerCase()))return!0}}}}return!1}foundMatch(e,t){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?s.default.ALL_WORDS_WORDLIST_ID:this.cfg.wordlistId),this.buildWordlist(e)}matchData(e,t,i,o){const a=e.find(t),r=o.pop(),l=o.pop(),n=o,d=n.length>0&&a.matchMethod!==s.default.MATCH_METHODS.REGEX;return d&&(i=n[1]),{word:a,string:r,match:i,matchStartIndex:l,captureGroups:n,internalCaptureGroups:d}}rebuildWordlists(){Object.keys(this.wordlists).forEach((e=>{this.buildWordlist(parseInt(e),!0)}))}replaceText(e,t=!1,i=s.default.STATS_TYPE_TEXT){t=this.buildWordlist(t);const a=this.wordlists[t];switch(this.cfg.filterMethod){case s.default.FILTER_METHODS.OFF:case s.default.FILTER_METHODS.CENSOR:a.regExps.forEach(((t,s)=>{e=e.replace(t,((e,...t)=>{const{word:o,string:r,match:l,matchStartIndex:n,captureGroups:d,internalCaptureGroups:u}=this.matchData(a,s,e,t);if(this.checkWhitelist(l,r,n,o))return l;i&&this.foundMatch(o,i);let c="";const h=this.cfg.censorFixedLength>0?this.cfg.censorFixedLength:l.length;return c=this.cfg.preserveFirst&&this.cfg.preserveLast?l[0]+this.cfg.censorCharacter.repeat(h-2)+l.slice(-1):this.cfg.preserveFirst?l[0]+this.cfg.censorCharacter.repeat(h-1):this.cfg.preserveLast?this.cfg.censorCharacter.repeat(h-1)+l.slice(-1):this.cfg.censorCharacter.repeat(h),u&&(c=d[0]+c+d[2]),c}))}));break;case s.default.FILTER_METHODS.SUBSTITUTE:a.regExps.forEach(((t,r)=>{e=e.replace(t,((e,...t)=>{const{word:l,string:n,match:d,matchStartIndex:u,captureGroups:c,internalCaptureGroups:h}=this.matchData(a,r,e,t);if(this.checkWhitelist(d,n,u,l))return d;i&&this.foundMatch(l,i);let p=l.sub||this.cfg.defaultSubstitution;return l.matchMethod==s.default.MATCH_METHODS.REGEX&&c.length&&l.sub.includes("\\1")&&(c.forEach(((e,t)=>{p=p.replace(`\\${t+1}`,this.cfg.preserveCase?e:e.toLowerCase())})),p!==l.sub)?(this.cfg.substitutionMark&&(p="["+p+"]"),p):(l.case==s.default.FALSE&&this.cfg.preserveCase&&(o.default.allUpperCase(d)?p=p.toUpperCase():o.default.eachWordCapitalized(d)?p=o.default.capitalizeEachWord(p):o.default.firstCapitalized(d)&&(p=o.default.capitalizeFirst(p))),this.cfg.substitutionMark&&(p="["+p+"]"),h&&(p=c[0]+p+c[2]),p)}))}));break;case s.default.FILTER_METHODS.REMOVE:a.regExps.forEach(((t,s)=>{e=e.replace(t,((e,...t)=>{const{word:r,string:l,match:n,matchStartIndex:d,captureGroups:u,internalCaptureGroups:c}=this.matchData(a,s,e,t);return this.checkWhitelist(n.trim(),l,d,r)?n:(i&&this.foundMatch(r,i),c?o.default.whitespaceRegExp.test(u[0])&&o.default.whitespaceRegExp.test(u[2])?u[0]:o.default.nonWordRegExp.test(u[0])||o.default.nonWordRegExp.test(u[2])?(u[0]+u[2]).trim():"":o.default.whitespaceRegExp.test(n[0])&&o.default.whitespaceRegExp.test(n[n.length-1])?n[0]:"")}))}))}return e}replaceTextResult(e,t=!1,i=s.default.STATS_TYPE_TEXT){const o={original:e,filtered:this.replaceText(e,t,i),modified:!1};return o.modified=o.filtered!=e,o}}},582:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.booleanToNumber=function(e){return e?o.default.TRUE:o.default.FALSE},t.dynamicList=function(e,t,i=!1,s){l(t);(void 0!==s?[s].concat(e):e).forEach((e=>{const o=document.createElement("option");o.value=s&&e===s?"":e,o.textContent=i?n(e):e,t.appendChild(o)}))},t.exportToFile=function(e,t="data.txt"){const i="data:application/json;charset=utf-8,"+encodeURIComponent(e),s=document.createElement("a");s.setAttribute("href",i),s.setAttribute("download",t),s.click(),s.remove()},t.formatNumber=function(e){const t=e.toString().length;if(t<=3)return e.toString();if(t<=6){const t=(e/1e3).toPrecision(),i=t.indexOf(".");return(i>=-1&&i<=1?t.slice(0,3):t.slice(0,i))+"k"}if(t<=9){const t=(e/1e6).toPrecision(),i=t.indexOf(".");return(i>=-1&&i<=1?t.slice(0,3):t.slice(0,i))+"M"}return"1G+"},t.getGlobalVariable=function(e,t="APFData"){const i=document.createElement("script");i.id=t,i.textContent=`document.getElementById("${t}").textContent = JSON.stringify(${e})`,document.documentElement.appendChild(i);const s=document.querySelector(`script#${t}`).textContent;return i.remove(),JSON.parse(s)},t.getGlobalVariableFromBackground=function(e){return new Promise(((t,i)=>{chrome.runtime.sendMessage({globalVariable:e},(e=>{t(e)}))}))},t.getParent=function e(t,i=1){return t?i>0?e(t.parentElement,i-1):t:null},t.getVersion=function(e){const t=e.split(".");return{major:parseInt(t[0]),minor:parseInt(t[1]),patch:parseInt(t[2])}},t.hmsToSeconds=function(e,t=3){const[i="0",s="0",o="0"]=(e||"0:0:0").split(":"),a=parseInt(i,10)||0,r=parseInt(s,10)||0,l=parseFloat(o)||0;return parseFloat((3600*a+60*r+l).toFixed(t))},t.injectScript=function(e,t,i=""){const s=document.getElementsByTagName(t)[0],o=document.createElement("script");o.setAttribute("type","text/javascript"),i&&(o.id=i);o.setAttribute("src",e),s.appendChild(o)},t.isVersionOlder=function(e,t){if(e.major{chrome.runtime.sendMessage({fetch:e,fetchMethod:t.toUpperCase()},(e=>{i(e)}))}))},t.makeFetchRequest=a,t.makeRequest=async function(e,t){return fetch?await a(e,t):await r(e,t)},t.makeXMLHttpRequest=r,t.numberToBoolean=function(e){return e>o.default.FALSE},t.numberWithCommas=function(e){if("object"==typeof Intl&&"function"==typeof Intl.NumberFormat)return"string"==typeof e&&(e=parseInt(e).toString()),e.toLocaleString();{const t=(e=e.toString()).indexOf(".");let i=-1===t?e:e.slice(0,t);for(let e=i.length-3;e>0;e-=3)i=i.slice(0,e)+","+i.slice(e);return-1!==t&&(i+=e.slice(t)),i}},t.prettyPrintArray=function(e){return`[${e.toString().replace(/,/g,", ")}]`},t.readFile=function(e){return new Promise(((t,i)=>{const s=new FileReader;s.onload=()=>{t(s.result)},s.readAsText(e)}))},t.removeChildren=l,t.removeFromArray=function(e,t){return e.filter((e=>e!==t))},t.secondsToHMS=function(e){return new Date(1e3*e).toISOString().slice(11,23)},t.stringArray=function(e){"string"==typeof e&&(e=[e]);return e},t.upperCaseFirst=n;var s,o=(s=i(357))&&s.__esModule?s:{default:s};async function a(e,t="GET"){const i=await fetch(e,{method:t});return await i.text()}function r(e,t){return new Promise(((i,s)=>{const o=new XMLHttpRequest;o.open(t,e),o.onload=function(){this.status>=200&&this.status<300?i(this.response):s({status:this.status,statusText:this.statusText})},o.onerror=function(){s({status:this.status,statusText:this.statusText})},o.send()}))}function l(e){if(e.hasChildNodes)for(;e.firstChild;)e.firstChild.remove()}function n(e,t=!0){let i=e.charAt(0).toUpperCase();return i+=t?e.toLowerCase().slice(1):e.slice(1),i}},167:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s,o=(s=i(357))&&s.__esModule?s:{default:s};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}class r{static debug(e,...t){this.log(this.debugName,e,t)}static debugTime(e,t=[]){this.logTime(this.debugName,e,t)}static error(e,...t){this.log(this.errorName,e,t)}static errorTime(e,t=[]){this.logTime(this.errorName,e,t)}static info(e,...t){this.log(this.infoName,e,t)}static infoTime(e,t=[]){this.logTime(this.infoName,e,t)}static log(e,t,i=[]){t=`[${r.app}] ${t}`,i.length?console[e](t,i):console[e](t)}static logTime(e,t,i=[]){const s=(new Date).toLocaleString();t=`[${r.app}] ${t}`,i.length?console[e](t,s,i):console[e](t,s)}static warn(e,...t){this.log(this.warnName,e,t)}static warnTime(e,t=[]){this.logTime(this.warnName,e,t)}constructor(e){a(this,"level",void 0),a(this,"prefix",void 0),this.level=r.defaultLevel,this.prefix="",e&&(this.prefix=`[${e}] `)}debug(e,...t){r.debugLevel>=this.level&&r.log(r.debugName,`${this.prefix}${e}`,t)}debugTime(e,...t){r.debugLevel>=this.level&&r.logTime(r.debugName,`${this.prefix}${e}`,t)}error(e,...t){r.errorLevel>=this.level&&r.log(r.errorName,`${this.prefix}${e}`,t)}errorTime(e,...t){r.errorLevel>=this.level&&r.logTime(r.errorName,`${this.prefix}${e}`,t)}info(e,...t){r.infoLevel>=this.level&&r.log(r.infoName,`${this.prefix}${e}`,t)}infoTime(e,...t){r.infoLevel>=this.level&&r.logTime(r.infoName,`${this.prefix}${e}`,t)}setLevel(e){this.level=e}warn(e,...t){r.warnLevel>=this.level&&r.log(r.warnName,`${this.prefix}${e}`,t)}warnTime(e,...t){r.warnLevel>=this.level&&r.logTime(r.warnName,`${this.prefix}${e}`,t)}}t.default=r,a(r,"app","APF"),a(r,"debugLevel",o.default.LOGGING_LEVELS.DEBUG),a(r,"debugName",o.default.loggingLevelName(r.debugLevel).toLowerCase()),a(r,"defaultLevel",o.default.LOGGING_LEVELS.WARN),a(r,"errorLevel",o.default.LOGGING_LEVELS.ERROR),a(r,"errorName",o.default.loggingLevelName(r.errorLevel).toLowerCase()),a(r,"infoLevel",o.default.LOGGING_LEVELS.INFO),a(r,"infoName",o.default.loggingLevelName(r.infoLevel).toLowerCase()),a(r,"warnLevel",o.default.LOGGING_LEVELS.WARN),a(r,"warnName",o.default.loggingLevelName(r.warnLevel).toLowerCase())},812:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s,o=(s=i(357))&&s.__esModule?s:{default:s};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}class r{static allLowerCase(e){return e.toLowerCase()===e}static allUpperCase(e){return e.toUpperCase()===e}static capitalizeEachWord(e){return e.split(/[-_ ]+/i).forEach((t=>{e=e.replace(t,this.capitalizeFirst(t))})),e}static capitalizeFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}static containsDoubleByte(e){return!!e.length&&(e.charCodeAt(0)>127||r._unicodeRegExp.test(e))}static eachWordCapitalized(e){return e.split(/[-_ ]+/i).every((e=>this.firstCapitalized(e)))}static escapeRegExp(e){return e.replace(r._escapeRegExp,"\\$&")}static firstCapitalized(e){return e.charAt(0).toUpperCase()===e.charAt(0)}constructor(e,t,i){a(this,"_filterMethod",void 0),a(this,"case",void 0),a(this,"escaped",void 0),a(this,"lists",void 0),a(this,"matchMethod",void 0),a(this,"matchRepeated",void 0),a(this,"matchSeparators",void 0),a(this,"regExp",void 0),a(this,"sub",void 0),a(this,"unicode",void 0),a(this,"value",void 0),this.value=e,this.case=t.case>o.default.FALSE?o.default.TRUE:o.default.FALSE,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=r.containsDoubleByte(e),this.escaped=this.matchMethod===o.default.MATCH_METHODS.REGEX?this.value:r.escapeRegExp(this.value),this.regExp=this.buildRegExp()}buildRegExp(){try{switch(this.matchMethod){case o.default.MATCH_METHODS.PARTIAL:return this._filterMethod===o.default.FILTER_METHODS.REMOVE?this.unicode?new RegExp("(^|"+r._unicodeWordBoundary+"?)([\\w-]*"+this.processedPhrase()+"[\\w-]*)("+r._unicodeWordBoundary+"?|$)",this.regexOptions()):this.hasEdgePunctuation()?new RegExp("(^|\\s)([\\w-]*"+this.processedPhrase()+"[\\w-]*)(\\s|$)",this.regexOptions()):new RegExp("\\s?\\b[\\w-]*"+this.processedPhrase()+"[\\w-]*\\b\\s?",this.regexOptions()):new RegExp(this.processedPhrase(),this.regexOptions());case o.default.MATCH_METHODS.WHOLE:return this.unicode?new RegExp("(^|"+r._unicodeWordBoundary+"*)([\\S]*"+this.processedPhrase()+"[\\S]*)("+r._unicodeWordBoundary+"*|$)",this.regexOptions()):this.hasEdgePunctuation()?new RegExp("(^|\\s)([\\S]*"+this.processedPhrase()+"[\\S]*)(\\s|$)",this.regexOptions()):new RegExp("\\b[\\w-]*"+this.processedPhrase()+"[\\w-]*\\b",this.regexOptions());case o.default.MATCH_METHODS.REGEX:return new RegExp(this.value,this.regexOptions());case o.default.MATCH_METHODS.EXACT:default:return this._filterMethod===o.default.FILTER_METHODS.REMOVE?this.unicode?new RegExp("(^|"+r._unicodeWordBoundary+")("+this.processedPhrase()+")("+r._unicodeWordBoundary+"|$)",this.regexOptions()):this.hasEdgePunctuation()?new RegExp("(^|\\s)("+this.processedPhrase()+")(\\s|$)",this.regexOptions()):new RegExp("\\s?\\b"+this.processedPhrase()+"\\b\\s?",this.regexOptions()):this.unicode?new RegExp("(^|"+r._unicodeWordBoundary+"+)("+this.processedPhrase()+")("+r._unicodeWordBoundary+"+|$)",this.regexOptions()):this.hasEdgePunctuation()?new RegExp("(^|\\s)("+this.processedPhrase()+")(\\s|$)",this.regexOptions()):new RegExp("\\b"+this.processedPhrase()+"\\b",this.regexOptions())}}catch(e){throw new Error(`Failed to create RegExp for '${this.value}'. [${e.name}: ${e.message}]`)}}hasEdgePunctuation(){return r._edgePunctuationRegExp.test(this.value)}processedPhrase(){const e=this.escaped.includes("\\");let t="";const i=this.escaped.length-1;for(let s=0;s{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=a(i(357)),o=a(i(812));function a(e){return e&&e.__esModule?e:{default:e}}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}const l=new(a(i(167)).default)("Wordlist");t.default=class{constructor(e,t){r(this,"all",void 0),r(this,"list",void 0),r(this,"regExps",void 0),this.all=[],this.list=[],this.regExps=[],l.setLevel(e.loggingLevel);Object.keys(e.words).sort(((e,t)=>t.length-e.length)).forEach((i=>{if(t===s.default.ALL_WORDS_WORDLIST_ID||!Array.isArray(e.words[i].lists)||e.words[i].lists.includes(t))try{const t=new o.default(i,e.words[i],e);this.list.push(i),this.all.push(t),this.regExps.push(t.regExp)}catch(e){l.warn(`Failed to add '${i}' to wordlist.`,e)}}))}find(e){return"string"==typeof e?this.all[this.list.indexOf(e)]:"number"==typeof e?this.all[e]:void 0}}},470:(e,t)=>{"use strict";function i(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 s{constructor(){i(this,"xpathDocText",void 0),i(this,"xpathNodeText",void 0)}static isForbiddenNode(e){return!!e.isContentEditable||(!(!e.parentNode||!e.parentNode.isContentEditable&&!s.forbiddenTags.includes(e.parentNode.nodeName))||s.forbiddenTags.includes(e.nodeName))}}t.default=s,i(s,"disabledProtocols",new RegExp("(^chrome:|^about:|^[a-zA-Z]+-extension:)","i")),i(s,"forbiddenNodeRegExp",new RegExp("^s*(<[a-z].+?/?>|{.+?:.+?;.*}|https?://[^s]+$)")),i(s,"forbiddenTags",["SCRIPT","STYLE","INPUT","TEXTAREA","IFRAME","LINK"])},210:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=n(i(357)),o=n(i(502)),a=i(582),r=n(i(167)),l=n(i(863));function n(e){return e&&e.__esModule?e:{default:e}}function d(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const u=new r.default("WebAudio");class c{constructor(e){d(this,"cueRuleIds",void 0),d(this,"enabledRuleIds",void 0),d(this,"fetching",void 0),d(this,"fillerAudio",void 0),d(this,"fillerAudioPauseHandler",void 0),d(this,"fillerAudioPlayHandler",void 0),d(this,"filter",void 0),d(this,"lastFilteredNode",void 0),d(this,"lastFilteredText",void 0),d(this,"lastProcessedText",void 0),d(this,"muted",void 0),d(this,"rules",void 0),d(this,"sites",void 0),d(this,"siteKey",void 0),d(this,"supportedPage",void 0),d(this,"unmuteTimeout",void 0),d(this,"volume",void 0),d(this,"watcherRuleIds",void 0),d(this,"wordlistId",void 0),d(this,"youTube",void 0),d(this,"youTubeAutoSubsMax",void 0),d(this,"youTubeAutoSubsMin",void 0),d(this,"youTubeAutoSubsRule",void 0),d(this,"youTubeAutoSubsTimeout",void 0),d(this,"youTubeAutoSubsUnmuteDelay",void 0),this.filter=e,u.setLevel(this.filter.cfg.loggingLevel),this.cueRuleIds=[],this.enabledRuleIds=[],this.watcherRuleIds=[],this.filter.extension&&(this.fillerAudio=this.initFillerAudio(this.filter.cfg.fillerAudio)),this.lastFilteredNode=null,this.lastFilteredText="",this.lastProcessedText="",this.muted=!1,e.cfg.customAudioSites&&"object"==typeof e.cfg.customAudioSites||(e.cfg.customAudioSites={}),this.sites=o.default.combineSites(e.cfg.customAudioSites),this.volume=1,this.wordlistId=e.audioWordlistId,this.youTubeAutoSubsMax=1e3*e.cfg.youTubeAutoSubsMax,this.youTubeAutoSubsMin=e.cfg.youTubeAutoSubsMin,this.youTubeAutoSubsUnmuteDelay=0,this.siteKey=this.getSiteKey(),this.rules=this.sites[this.siteKey],this.rules&&(Array.isArray(this.rules)||(this.rules=[this.rules]),this.rules.forEach((e=>{this.initRule(e)})),this.enabledRuleIds.length>0&&(this.supportedPage=!0,this.initYouTube()))}apfCaptionLine(e,t){const i=document.createElement("span");return i.classList.add("APF-subtitle-line"),i.style.background="black",i.style.color="white",i.style.fontSize="3.5vw",i.style.paddingLeft="4px",i.style.paddingRight="4px",i.style.height="18px",i.textContent=t,i}apfCaptionLines(e,t){const i=document.createElement("div");return i.classList.add("APF-subtitles"),i.style.bottom="10px",i.style.position="absolute",i.style.textAlign="center",i.style.width="100%",t.forEach((e=>{i.appendChild(e),i.appendChild(document.createElement("br"))})),i}clean(e,t=0){const i=this.rules[t];if("watcher"===i.mode)return;let s=!1;e.nodeName&&"#text"===e.nodeName&&e.parentElement&&(e=e.parentElement);const o=i.subtitleSelector&&e.querySelectorAll?e.querySelectorAll(i.subtitleSelector):[e];if(0===o.length)return;o.forEach((e=>{const t="#text"===e.nodeName?"textContent":"innerText";!0===i.convertBreaks&&"#text"!==e.nodeName&&!c.brTagRegExp.test(e[t])&&c.brTagRegExp.test(e.innerHTML)&&("pre"!==e.style.whiteSpace&&(e.style.whiteSpace="pre"),e.textContent=e.innerHTML.replace(c.brTagRegExp,"\n"));const o=this.replaceTextResult(e[t]);o.modified&&(s=!0,this.mute(i),i.filterSubtitles&&(i.preserveWhiteSpace&&"pre"!==e.style.whiteSpace&&(e.style.whiteSpace="pre"),i.ignoreMutations&&this.filter.stopObserving(),e[t]=o.filtered,i.ignoreMutations&&this.filter.startObserving()),this.lastFilteredNode=e,this.lastFilteredText=e[t]),s||this.lastFilteredNode!=e||this.lastFilteredText!=e[t]||(s=!0)})),s||this.lastFilteredNode&&document.body.contains(this.lastFilteredNode)&&this.lastFilteredNode.textContent===this.lastFilteredText&&(s=!0);this.subtitlesShouldBeShown(i,s)?this.showSubtitles(i,o):this.hideSubtitles(i,o)}cleanYouTubeAutoSubs(e){null!=this.youTubeAutoSubsTimeout&&(clearTimeout(this.youTubeAutoSubsTimeout),this.youTubeAutoSubsTimeout=null);const t=this.replaceTextResult(e.textContent);if(t.modified)this.youTubeAutoSubsRule.filterSubtitles&&(e.textContent=t.filtered),this.mute(this.youTubeAutoSubsRule),this.youTubeAutoSubsUnmuteDelay=null,this.filter.updateCounterBadge(),this.youTubeAutoSubsMax&&(this.youTubeAutoSubsTimeout=window.setTimeout(this.youTubeAutoSubsMuteTimeout,this.youTubeAutoSubsMax,this));else if(this.muted)if(this.youTubeAutoSubsMin>0){const e=document.getElementsByTagName(c.defaultVideoSelector)[0].currentTime;null==this.youTubeAutoSubsUnmuteDelay?this.youTubeAutoSubsUnmuteDelay=e:(ethis.youTubeAutoSubsUnmuteDelay+this.youTubeAutoSubsMin&&this.unmute(this.youTubeAutoSubsRule))}else this.unmute(this.youTubeAutoSubsRule);if(this.filter.cfg.showSubtitles!==s.default.SHOW_SUBTITLES.ALL){const e=document.querySelector("div.ytp-caption-window-rollup span.captions-text");"block"==e.style.display&&(e.style.display="none")}}clearUnmuteTimeout(e){e.unmuteDelay&&null!=this.unmuteTimeout&&(clearTimeout(this.unmuteTimeout),this.unmuteTimeout=null)}delayedUnmute(e,t){e.unmute(t,null,!0),this.unmuteTimeout=null}fillerAudioHandlePause(){this.fillerAudio.pause()}fillerAudioHandlePlay(){this.muted&&this.fillerAudio.play()}getSiteKey(){return this.sites.hasOwnProperty(this.filter.hostname)?this.filter.hostname:this.filter.iframe&&this.filter.iframe.hostname&&this.sites.hasOwnProperty(this.filter.iframe.hostname)?this.filter.iframe.hostname:""}getVideoTextTrack(e,t,i){let s=0,o=0,a=!1,r=0;i&&t[i]&&(r+=1e3),t.videoCueLabel&&(r+=100),t.videoCueLanguage&&(r+=10),t.videoCueKind&&(r+=1);for(let l=0;lo||!a)&&(o=d,s=l,a=!0)}if(a)return e[s]}hideCue(e,t){t.text="",t.position=100,t.size=0}hideSubtitles(e,t){if(e.displayVisibility&&e._displayElement)e._displayElement.style.visibility="hidden";else if(e.displaySelector){const i=e.rootNode&&t&&t[0]?t[0].getRootNode():document;if(i){const t=i.querySelector(e.displaySelector);t&&(""===e.displayShow&&""!==t.style.display&&t.style.display!==e.displayHide&&(e.displayShow=t.style.display),t.style.setProperty("display",e.displayHide))}}else t&&t.forEach((t=>{t.innerText="",e.removeSubtitleSpacing&&t.style&&(t.style.padding&&(t.style.padding=0),t.style.margin&&(t.style.margin=0))}))}initCueRule(e){!0===e.apfCaptions&&(e.videoCueHideCues=!0),void 0===e.videoSelector&&(e.videoSelector=c.defaultVideoSelector),void 0===e.videoCueRequireShowing&&(e.videoCueRequireShowing=this.filter.cfg.muteCueRequireShowing),e.externalSub&&(void 0===e.externalSubTrackMode&&(e.externalSubTrackMode="showing"),void 0===e.externalSubURLKey&&(e.externalSubURLKey="url"),void 0===e.externalSubFormatKey&&(e.externalSubFormatKey="format"),void 0===e.externalSubTrackLabel&&(e.externalSubTrackLabel="APF"))}initDisplaySelector(e){void 0!==e.displaySelector&&(void 0===e.displayHide&&(e.displayHide="none"),void 0===e.displayShow&&(e.displayShow=""))}initDynamicRule(e){e._dynamic=!0,null==e.dynamicTargetMode&&e.disabled}initElementChildRule(e){e.parentSelector||e.parentSelectorAll||(e.disabled=!0)}initElementRule(e){}initFillerAudio(e=""){const t=c.fillerConfig[e];if(t){const e=chrome.runtime.getURL(t.fileName),i=new Audio;return i.src=e,i.loop=!0,t.volume&&(i.volume=t.volume),t.loopAfter&&(i.ontimeupdate=()=>{i.currentTime>t.loopAfter&&(i.currentTime=0)}),this.fillerAudioPauseHandler=this.fillerAudioHandlePause.bind(this),this.fillerAudioPlayHandler=this.fillerAudioHandlePlay.bind(this),i}}initRule(e){const t=this.rules.indexOf(e);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(null==e.filterSubtitles&&(e.filterSubtitles=!0),0==this.filter.filterText&&(e.filterSubtitles=!1),this.initDisplaySelector(e),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),e.disabled||this.cueRuleIds.push(t);break;case"dynamic":this.initDynamicRule(e);break;case"elementChild":this.initElementChildRule(e);break;case"element":this.initElementRule(e);break;case"text":this.initTextRule(e);break;case"watcher":this.initWatcherRule(e),e.disabled||this.watcherRuleIds.push(t)}e.disabled||(this.enabledRuleIds.push(t),"cue"==e.mode&&1===this.cueRuleIds.length?setInterval(this.watchForVideo,250,this):"watcher"==e.mode&&setInterval(this.watcher,e.checkInterval,this,t))}}initTextRule(e){e.tagName="#text",void 0===e.simpleUnmute&&(e.simpleUnmute=!0)}initWatcherRule(e){void 0===e.checkInterval&&(e.checkInterval=20),void 0===e.ignoreMutations&&(e.ignoreMutations=!0),void 0===e.simpleUnmute&&(e.simpleUnmute=!0),void 0===e.videoSelector&&(e.videoSelector=c.defaultVideoSelector)}initYouTube(){if(["m.youtube.com","tv.youtube.com","www.youtube.com"].includes(this.siteKey)){this.youTube=!0;const e="[ __ ]",t={lists:this.wordlistId===s.default.ALL_WORDS_WORDLIST_ID?[]:[this.wordlistId],matchMethod:s.default.MATCH_METHODS.PARTIAL,repeat:s.default.FALSE,separators:s.default.FALSE,sub:""};this.filter.cfg.addWord(e,t),this.youTubeAutoSubsRule={filterSubtitles:!0,mode:"ytauto",muteMethod:this.filter.cfg.muteMethod}}}mute(e,t){if(!this.muted){switch(this.muted=!0,this.filter.cfg.collectStats&&this.filter.stats.mutes++,e.muteMethod){case s.default.MUTE_METHODS.TAB:chrome.runtime.sendMessage({mute:!0});break;case s.default.MUTE_METHODS.VIDEO_MUTE:t||(t=document.querySelector(e&&e.videoSelector?e.videoSelector:c.defaultVideoSelector)),t&&!t.muted&&(t.muted=!0),this.fillerAudio&&this.playFillerAudio(t);break;case s.default.MUTE_METHODS.VIDEO_VOLUME:t||(t=document.querySelector(e&&e.videoSelector?e.videoSelector:c.defaultVideoSelector)),t&&null!=t.volume&&(this.volume=t.volume,t.volume=0),this.fillerAudio&&this.playFillerAudio(t)}u.debugTime("mute()")}e&&e.unmuteDelay&&this.unmuteTimeout&&this.clearUnmuteTimeout(e)}newCue(e,t,i,s={}){try{const o=new VTTCue((0,a.hmsToSeconds)(e),(0,a.hmsToSeconds)(t),i);return s.align&&(o.align=s.align),s.line&&(o.line=this.parseLineAndPositionSetting(s.line)),s.position&&(o.position=this.parseLineAndPositionSetting(s.position)),o}catch(s){u.error(`Failed to add cue: ( start: ${e}, end: ${t}, text: ${i} )`,s)}}newTextTrack(e,t,i){if(t.textTracks){const s=t.addTextTrack("captions",e.externalSubTrackLabel,e.videoCueLanguage);s.mode=e.externalSubTrackMode;for(let e=0;ee.trim())),i=[];let s=null,o=null,a=null;for(let e=0;e=0){const i=t[e].split(/[ \t]+-->[ \t]+/);if(2!=i.length)throw new Error(`Error when splitting "--\x3e": ${t[e]}.`);s=i[0],o=i[1]}else if(""==t[e]){if(s&&o){const e=this.newCue(s,o,a);i.push(e),s=null,o=null,a=null}}else s&&o&&(null==a?a=t[e]:a+="\n"+t[e]);if(s&&o){const e=this.newCue(s,o,a);i.push(e)}return i}parseSSA(e){const t=[];let i,s,o,a=!1;const r=e.split("\n");for(let e=0;ee.split(":"))).reduce(((e,t)=>(e[t[0]]=t[1],e)),{}),c=i[e-1].trim(),h=i[e+1].trim(),p=new RegExp(`^<[cs]\\.${c}>`),m=new RegExp("$");let f;if(f=h.match(p)?h.replace(p,"").replace(m,""):h,c&&!c.match(/_1$/)){const e=t[t.length-1];e.startTime!=(0,a.hmsToSeconds)(l)&&e.endTime==(0,a.hmsToSeconds)(n)&&(l=(0,a.secondsToHMS)(e.startTime))}const g=this.newCue(l,n,f,u);if(c&&!c.match(/_1$/)){const e=parseInt(c.match(/_([2-9])$/)[1]),i=t.length-e+1;t.splice(i,0,g)}else t.push(g);e++}}return t}playFillerAudio(e){this.playing(e)&&(this.fillerAudio.play(),e.addEventListener("pause",this.fillerAudioPauseHandler),e.addEventListener("play",this.fillerAudioPlayHandler))}playing(e){return!!(e&&e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>2)}processCues(e,t){for(let i=0;ie.language===t.videoCueLanguage));if(!s)throw new Error(`Failed to find subtitle for language: ${t.videoCueLanguage}.`);let o;if(this.fetching=!0,o="bookmarklet"==l.default.BUILD.target?await(0,a.makeRequest)(s[t.externalSubURLKey],"GET"):await(0,a.makeBackgroundRequest)(s[t.externalSubURLKey],"GET"),"string"!=typeof o||!o)throw new Error(`Failed to download external subtitles from '${s[t.externalSubURLKey]}'.`);{let i;switch(s[t.externalSubFormatKey]){case"ass":i=this.parseSSA(o);break;case"srt":i=this.parseSRT(o);break;case"vtt":i=this.parseVTT(o);break;default:throw new Error(`Unsupported subtitle type: ${s[t.externalSubFormatKey]}.`)}if(i){const s=this.newTextTrack(t,e,i).cues;if(this.processCues(s,t),this.fetching=!1,t.displaySelector){const e=document.querySelector(t.displaySelector);e&&(e.style.display="none")}}}}}catch(e){u.error(`Error using external subtitles for ${this.siteKey}.`,e)}}processWatcherCaptions(e,t,i){const s=i.initialCall;if(s){if(this.lastProcessedText&&this.lastProcessedText===t.textContent)return i.skipped=!0,!1;this.unmute(e),this.lastProcessedText="",i.initialCall=!1,i.filtered=!1}if(t.hasChildNodes())t.childNodes.forEach((t=>{this.processWatcherCaptions(e,t,i)}));else{const s="#text"===(t&&t.nodeName)?"textContent":"innerText";if(t[s]&&t[s].trim()){const o=this.replaceTextResult(t[s]);o.modified&&(this.mute(e),i.filtered=!0,e.filterSubtitles&&(t[s]=o.filtered))}}s&&(this.lastProcessedText=t.textContent)}processWatcherCaptionsArray(e,t,i){const s=t.map((e=>e.textContent)).join(" ");if(this.lastProcessedText&&this.lastProcessedText===s)return i.skipped=!0,!1;this.unmute(e),this.lastProcessedText="",i.filtered=!1,t.forEach((t=>{if(t.textContent&&t.textContent.trim()){const s=this.replaceTextResult(t.textContent);s.modified&&(this.mute(e),i.filtered=!0,e.filterSubtitles&&(t.textContent=s.filtered))}}));this.subtitlesShouldBeShown(e,i.filtered)?this.showSubtitles(e):this.hideSubtitles(e),this.lastProcessedText=t.map((e=>e.textContent)).join(" ")}replaceTextResult(e,t=this.wordlistId,i=s.default.STATS_TYPE_AUDIO){return this.filter.replaceTextResult(e,t,i)}showSubtitles(e,t){if(e.displayVisibility&&e._displayElement)e._displayElement.style.visibility="visible";else if(e.displaySelector){const i=e.rootNode&&t&&t[0]?t[0].getRootNode():document;if(i){const t=i.querySelector(e.displaySelector);t&&t.style.setProperty("display",e.displayShow)}}}stopFillerAudio(){this.fillerAudio.pause(),this.fillerAudio.currentTime=0}subtitlesShouldBeShown(e,t=!1){switch(e.showSubtitles){case s.default.SHOW_SUBTITLES.ALL:return!0;case s.default.SHOW_SUBTITLES.FILTERED:return t;case s.default.SHOW_SUBTITLES.UNFILTERED:return!t;case s.default.SHOW_SUBTITLES.NONE:return!1}}supportedNode(e){for(let t=0;t=0)return null==this.unmuteTimeout&&this.clearUnmuteTimeout(e),void(this.unmuteTimeout=window.setTimeout(this.delayedUnmute,e.unmuteDelay,this,e));switch(this.muted=!1,e.muteMethod){case s.default.MUTE_METHODS.TAB:chrome.runtime.sendMessage({mute:!1});break;case s.default.MUTE_METHODS.VIDEO_MUTE:this.fillerAudio&&this.stopFillerAudio(),t||(t=document.querySelector(e&&e.videoSelector?e.videoSelector:c.defaultVideoSelector)),t&&t.muted&&(t.muted=!1);break;case s.default.MUTE_METHODS.VIDEO_VOLUME:this.fillerAudio&&this.stopFillerAudio(),t||(t=document.querySelector(e&&e.videoSelector?e.videoSelector:c.defaultVideoSelector)),t&&null!=t.volume&&(t.volume=this.volume)}u.debugTime("unmute()")}}watcher(e,t=0){const i=e.rules[t],s=document.querySelector(i.videoSelector);if(s&&e.playing(s)){i.ignoreMutations&&e.filter.stopObserving();const t={initialCall:!0};let o,r;if(i.parentSelectorAll?(i._dynamic?(r=Array.from(document.querySelectorAll(i.parentSelectorAll)).filter((e=>e.textContent!==i.dynamicTextKey)),!i.displayVisibility||i._displayElement&&document.body.contains(i._displayElement)||(i._displayElement=(0,a.getParent)(r[0],i.getParentLevel))):r=Array.from(document.querySelectorAll(i.parentSelectorAll)),o=r.map((e=>e.querySelector(i.subtitleSelector))),o.length?e.processWatcherCaptionsArray(i,o,t):e.watcherSimpleUnmute(i,s)):i.parentSelector?(o=document.querySelector(i.parentSelector),o&&o.textContent&&o.textContent.trim()?e.processWatcherCaptions(i,o,t):e.watcherSimpleUnmute(i,s)):i.subtitleSelector&&(o=Array.from(document.querySelectorAll(i.subtitleSelector)),o&&o.length?(!i.displayVisibility||i._displayElement&&document.body.contains(i._displayElement)||(i._displayElement=(0,a.getParent)(o[0],i.displayElementLevels)),e.processWatcherCaptionsArray(i,o,t)):e.watcherSimpleUnmute(i,s)),t.skipped)return!1;e.subtitlesShouldBeShown(i,t.filtered)?e.showSubtitles(i):e.hideSubtitles(i),t.filtered&&e.filter.updateCounterBadge()}else i.ignoreMutations&&e.filter.startObserving()}watchForVideo(e){for(let t=0;t{if(t.activeCues&&t.activeCues.length>0){const s=Array.from(t.activeCues),a=[];if(!s.some((e=>e.hasOwnProperty("filtered")))){const s=Array.from(t.cues);e.processCues(s,i)}const r=s.some((e=>e.filtered));r?e.mute(i,o):e.unmute(i,o);const l=e.subtitlesShouldBeShown(i,r);for(let t=0;ts.default.SHOW_SUBTITLES.ALL&&this.hideSubtitles(e)}youTubeAutoSubsCurrentRow(e){return!(e.parentElement.parentElement!=e.parentElement.parentElement.parentElement.lastChild)}youTubeAutoSubsMuteTimeout(e){const t=window.document.querySelector(c.defaultVideoSelector);t&&e.playing(t)&&e.unmute(e.youTubeAutoSubsRule),e.youTubeAutoSubsTimeout=null}youTubeAutoSubsNodeIsSubtitleText(e){const 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=c,d(c,"brTagRegExp",new RegExp("
","i")),d(c,"defaultVideoSelector","video"),d(c,"fillerConfig",{beep:{fileName:"audio/beep.mp3",volume:.2},crickets:{fileName:"audio/crickets.mp3",volume:.4},static:{fileName:"audio/static.mp3",volume:.3}}),d(c,"textTrackRuleMappings",{externalSubTrackLabel:"label",videoCueKind:"kind",videoCueLabel:"label",videoCueLanguage:"language"})},502:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s,o=(s=i(357))&&s.__esModule?s:{default:s};class a{static combineSites(e={}){return Object.assign({},a.sites,e)}}t.default=a,function(e,t,i){t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i}(a,"sites",{"abc.com":[{className:"akamai-caption-text",mode:"element",tagName:"DIV"},{className:"amp-caption-area",displaySelector:"div.amp-caption-area",mode:"element",muteMethod:o.default.MUTE_METHODS.VIDEO_VOLUME,subtitleSelector:"div.amp-caption > p",tagName:"DIV"}],"iview.abc.net.au":[{mode:"element",subtitleSelector:"div.jw-text-track-cue",tagName:"div"}],"acorn.tv":[{iframe:!0,mode:"elementChild",parentSelector:"div.vjs-text-track-display",simpleUnmute:!0,subtitleSelector:":scope div > div",tagName:"DIV"}],"smile.amazon.com":[{displayHide:"none",displaySelector:"div.webPlayerContainer div.f35bt6a",displayShow:"",iframe:!1,mode:"watcher",parentSelector:"div.webPlayerContainer div span > span",videoSelector:"div.webPlayerElement video[src]"}],"www.amazon.co.uk":[{displayHide:"none",displaySelector:"div.webPlayerContainer div.f35bt6a",displayShow:"",iframe:!1,mode:"watcher",parentSelector:"div.webPlayerContainer div span > span",videoSelector:"div.webPlayerElement video[src]"}],"www.amazon.com":[{displayHide:"none",displaySelector:"div.webPlayerContainer div.f35bt6a",displayShow:"",iframe:!1,mode:"watcher",parentSelector:"div.webPlayerContainer div span > span",videoSelector:"div.webPlayerElement video[src]"}],"www.amc.com":[{className:"ttr-container",mode:"element",subtitleSelector:"span.ttr-cue",tagName:"DIV"},{mode:"cue",videoCueLanguage:"en",videoSelector:"video"}],"tv.apple.com":[{displaySelector:"div.video-container > div > div > div",mode:"elementChild",muteMethod:o.default.MUTE_METHODS.TAB,parentSelector:"div.video-container",preserveWhiteSpace:!0,rootNode:!0,subtitleSelector:"div > div > div > div > div",tagName:"DIV"},{displaySelector:"div.video-container > div > div > div",mode:"elementChild",muteMethod:o.default.MUTE_METHODS.TAB,parentSelector:"div.video-container",preserveWhiteSpace:!0,rootNode:!0,subtitleSelector:"div > div > div > div > span",tagName:"DIV"}],"www.att.tv":[{mode:"cue",videoSelector:"video#quickplayPlayer"}],"www.attwatchtv.com":[{mode:"cue",videoSelector:"video#quickplayPlayer"}],"www.bbc.co.uk":[{mode:"element",subtitleSelector:"div.p_cueDirUniWrapper span",tagName:"div"}],"www.britbox.com":[{className:"bmpui-ui-subtitle-label",mode:"element",tagName:"SPAN"},{className:"bmpui-subtitle-region-container",mode:"element",subtitleSelector:"div.bmpui-container-wrapper > span.bmpui-ui-subtitle-label",tagName:"div"}],"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.channel4.com":[{displaySelector:"div.subtitles-container",mode:"elementChild",parentSelector:"div.subtitles-container",tagName:"SPAN"}],"www.crackle.com":[{ignoreMutations:!0,mode:"elementChild",parentSelector:"div.clpp-subtitles-container",simpleUnmute:!0,tagName:"#text"}],"www.criterionchannel.com":[{iframe:!0,mode:"cue",videoCueHideCues:!0,videoCueRequireShowing:!1}],"beta.crunchyroll.com":[{apfCaptions:!0,apfCaptionsSelector:"vilosVttJs",displaySelector:"canvas#velocity-canvas",externalSub:!0,externalSubTrackMode:"hidden",externalSubVar:"window.v1config.media.subtitles",iframe:!0,mode:"cue",videoCueLanguage:"en-US",videoCueRequireShowing:!1}],"www.crunchyroll.com":[{apfCaptions:!0,apfCaptionsSelector:"vilosVttJs",displaySelector:"canvas#velocity-canvas",externalSub:!0,externalSubTrackMode:"hidden",externalSubVar:"window.v1config.media.subtitles",iframe:!0,mode:"cue",videoCueLanguage:"enUS",videoCueRequireShowing:!1,videoSelector:"video#player0"}],"www.cwtv.com":[{className:"ttr-container",convertBreaks:!0,mode:"element",subtitleSelector:"span.ttr-cue",tagName:"DIV"},{className:"ttr-line",convertBreaks:!0,mode:"element",note:"[CC]",subtitleSelector:"span.ttr-cue",tagName:"DIV"}],"www.discoveryplus.com":[{displaySelector:"div.cjRVXG",mode:"cue",videoCueKind:"captions",videoCueLanguage:"en"}],"www.dishanywhere.com":[{className:"bmpui-ui-subtitle-label",mode:"element",tagName:"SPAN"},{className:"bmpui-subtitle-region-container",mode:"element",subtitleSelector:"div.bmpui-container-wrapper > span.bmpui-ui-subtitle-label",tagName:"div"}],"www.disneyplus.com":[{className:"dss-subtitle-renderer-wrapper",mode:"element",subtitleSelector:"div.dss-subtitle-renderer-cue-window span.dss-subtitle-renderer-line",tagName:"DIV"}],"www.fox.com":[{className:"jw-text-track-container",mode:"element",subtitleSelector:"div.jw-text-track-cue",tagName:"DIV"}],"www.fubo.tv":[{displayHide:"none",displaySelector:"div.bmpui-ui-subtitle-overlay",iframe:!1,mode:"watcher",parentSelector:"div.bmpui-ui-subtitle-overlay",subtitleSelector:"div.bmpui-ui-subtitle-overlay span"}],"www.funimation.com":[{displaySelector:"div > div.vjs-text-track-cue",mode:"element",subtitleSelector:"div.vjs-text-track-cue > div",tagName:"DIV"},{iframe:!0,mode:"elementChild",note:"Embedded videos",parentSelector:"div.vjs-text-track-display",simpleUnmute:!0,subtitleSelector:":scope div > div",tagName:"DIV"}],"play.google.com":[{className:"lava-timed-text-window",mode:"element",subtitleSelector:"span.lava-timed-text-caption",tagName:"DIV"}],"play.hbomax.com":[{displayElementLevels:5,displayVisibility:!0,mode:"watcher",showSubtitles:o.default.SHOW_SUBTITLES.ALL,subtitleSelector:"span[style^='font-family: font']"}],"www.hulu.com":[{className:"caption-text-box",displaySelector:"div.caption-text-box",mode:"element",subtitleSelector:"p",tagName:"DIV"},{displaySelector:"div.CaptionBox",mode:"elementChild",parentSelector:"div.CaptionBox",tagName:"P"}],"www.itv.com":[{mode:"cue",videoCueLanguage:"en"}],"www.nbc.com":[{className:"ttr-line",mode:"element",subtitleSelector:"span.ttr-cue",tagName:"DIV"},{mode:"cue",videoCueLanguage:"en"}],"www.netflix.com":[{className:"player-timedtext-text-container",mode:"element",subtitleSelector:"span",tagName:"DIV"}],"www.paramountplus.com":[{mode:"cue",videoCueHideCues:!0,videoCueLanguage:"en",videoCueRequireShowing:!1}],"www.pbs.org":[{iframe:!0,mode:"element",subtitleSelector:"div.vjs-text-track-cue > div",tagName:"DIV"}],"www.peacocktv.com":[{displaySelector:"div.video-player__subtitles",mode:"elementChild",parentSelector:"div.video-player__subtitles > div",simpleUnmute:!0,tagName:"#text"},{displaySelector:"div.video-player__subtitles",mode:"elementChild",parentSelector:"div.video-player__subtitles > div",subtitleSelector:"SPAN > SPAN",tagName:"DIV"},{displaySelector:"div.video-player__subtitles",mode:"elementChild",parentSelector:"div.video-player__subtitles > div",tagName:"SPAN"}],"www.philo.com":[{mode:"cue"}],"app.plex.tv":[{dataPropPresent:"dialogueId",mode:"element",subtitleSelector:"span > span",tagName:"DIV"},{containsSelector:"div[data-dialogue-id]",mode:"element",subtitleSelector:"span > span",tagName:"DIV"}],"pluto.tv":[{mode:"cue",videoCueHideCues:!0,videoCueRequireShowing:!1}],"www.primevideo.com":[{displayHide:"none",displaySelector:"div.webPlayerContainer div.f35bt6a",displayShow:"",iframe:!1,mode:"watcher",parentSelector:"div.webPlayerContainer div span > span",videoSelector:"div.webPlayerElement video[src]"}],"www.redbox.com":[{mode:"elementChild",parentSelector:"div.rb-text-container",subtitleSelector:"SPAN > SPAN",tagName:"DIV"}],"watch.redeemtv.com":[{convertBreaks:!0,displaySelector:"div.vp-captions",mode:"elementChild",parentSelector:"div.vp-captions",tagName:"SPAN"}],"therokuchannel.roku.com":[{mode:"element",subtitleSelector:"div.vjs-text-track-cue > div",tagName:"DIV"}],"www.sbs.com.au":[{className:"bmpui-subtitle-region-container",mode:"element",subtitleSelector:"DIV.bmpui-container-wrapper > SPAN.bmpui-ui-subtitle-label > SPAN",tagName:"DIV"}],"www.showmax.com":[{ignoreMutations:!0,mode:"elementChild",parentSelector:"div.contentWrapper > div.subtitles--3EXhT",simpleUnmute:!0,tagName:"#text"}],"www.showtime.com":[{mode:"cue",videoCueHideCues:!0,videoCueLanguage:"en",videoCueRequireShowing:!1}],"play.stan.com.au":[{ignoreMutations:!0,mode:"elementChild",parentSelector:"div.clpp-subtitles-container",simpleUnmute:!0,tagName:"#text"}],"www.starz.com":[{mode:"elementChild",parentSelector:"starz-captions > div.cue-list",tagName:"SPAN"}],"www.syfy.com":[{className:"ttr-line",mode:"element",subtitleSelector:"span.ttr-cue",tagName:"DIV"}],"www.tntdrama.com":[{mode:"cue",videoCueLanguage:"en",videoSelector:"video.top-media-element"}],"tubitv.com":[{mode:"elementChild",parentSelector:"div#captionsComponent",tagName:"SPAN"}],"www.universalkids.com":[{mode:"element",subtitleSelector:"div.gwt-HTML",tagName:"DIV"}],"www.usanetwork.com":[{className:"ttr-line",mode:"element",subtitleSelector:"span.ttr-cue",tagName:"DIV"}],"www.vudu.com":[{mode:"element",subtitleSelector:"span.subtitles",tagName:"DIV"}],"vrv.co":[{displaySelector:"div.libassjs-canvas-parent",externalSub:!0,externalSubVar:"window.vilos.content.captions",iframe:!0,mode:"cue",videoCueLanguage:"en-US",videoCueRequireShowing:!1},{displaySelector:"div.libassjs-canvas-parent",externalSub:!0,externalSubVar:"window.vilos.content.subtitles",iframe:!0,mode:"cue",videoCueLanguage:"en-US",videoCueRequireShowing:!1}],"m.youtube.com":[{className:"caption-window",mode:"element",subtitleSelector:"span.ytp-caption-segment",tagName:"DIV"}],"tv.youtube.com":[{className:"caption-window",mode:"element",subtitleSelector:"span.ytp-caption-segment",tagName:"DIV"}],"www.youtube.com":[{className:"caption-window",mode:"element",subtitleSelector:"span.ytp-caption-segment",tagName:"DIV"}]})},863:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=d(i(357)),o=d(i(513)),a=i(582),r=d(i(167)),l=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var i=n(t);if(i&&i.has(e))return i.get(e);var s={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var r=o?Object.getOwnPropertyDescriptor(e,a):null;r&&(r.get||r.set)?Object.defineProperty(s,a,r):s[a]=e[a]}s.default=e,i&&i.set(e,s);return s}(i(178));function n(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(n=function(e){return e?i:t})(e)}function d(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}const c=new r.default("WebConfig");class h extends o.default{static get _maxBytes(){try{if(chrome.storage.sync.QUOTA_BYTES_PER_ITEM)return Math.round(.98*chrome.storage.sync.QUOTA_BYTES_PER_ITEM);throw"QUOTA_BYTES_PER_ITEM not defined, using default"}catch(e){return 8028}}static chromeStorageAvailable(){return!!(chrome&&chrome.storage&&chrome.storage.sync&&chrome.storage.local)}static combineData(e,t){if(e[t]={},void 0!==e[`_${t}0`]){const i=h.getDataContainerKeys(e,t);return i.forEach((i=>{Object.assign(e[t],e[i]),delete e[i]})),i}}static getDataContainerKeys(e,t){const i=new RegExp(`^_${t}\\d+`);return Object.keys(e).filter((e=>i.test(e))).sort()}static getLocalStorage(e){return"string"==typeof e&&(e=[e]),new Promise(((t,i)=>{chrome.storage.local.get(e,(e=>{chrome.runtime.lastError?i(chrome.runtime.lastError):t(e)}))}))}static getMaxSplitKeyFromArray(e=[]){if(Array.isArray(e)){const t=e.sort()[e.length-1];if(t){const e=new RegExp("\\d+$"),i=t.match(e);if(i)return parseInt(i[0])}}}static getMaxSplitKeyFromData(e,t){const i=h.getDataContainerKeys(e,t);return h.getMaxSplitKeyFromArray(i)}static getSyncStorage(e){return"string"==typeof e&&(e=[e]),new Promise(((t,i)=>{chrome.storage.sync.get(e,(e=>{chrome.runtime.lastError?i(chrome.runtime.lastError):t(e)}))}))}static includesLargeKeys(e){return e.some((e=>h._largeKeys.includes(e)))}static async load(e=[]){e=(0,a.stringArray)(e);const t={};let i;const s=[];let o=[];0===e.length&&(e=Object.keys(h._defaults)).push("words");try{if(h.includesLargeKeys(e)?(e.includes("syncLargeKeys")||e.push("syncLargeKeys"),h._localConfigKeys.forEach((t=>{e.includes(t)&&s.push(t)})),i=await h.getLocalStorage(s),t.syncLargeKeys=!1===i.syncLargeKeys?i.syncLargeKeys:h._defaults.syncLargeKeys,!1===t.syncLargeKeys?(s.forEach((e=>{void 0===i[e]?t[e]="words"===e?h._defaultWords:h._defaults[e]:t[e]=i[e]})),o=e.filter((e=>!h._localConfigKeys.includes(e)))):o=e.filter((e=>"syncLargeKeys"!==e))):o=e.filter((e=>"syncLargeKeys"!==e)),o.length){let e=[].concat(o);h._largeKeys.forEach((t=>{o.includes(t)&&(e.splice(e.indexOf(t),1),e=e.concat(h.splitKeyNames(t)))}));const i=await h.getSyncStorage(e);t._lastSplitKeys={},o.forEach((e=>{if(h._largeKeys.includes(e)){const s=h.combineData(i,e);s?(t._lastSplitKeys[e]=h.getMaxSplitKeyFromArray(s),t[e]=i[e]):(t._lastSplitKeys[e]=0,t[e]="words"===e?h._defaultWords:h._defaults[e])}else void 0===i[e]?t[e]=h._defaults[e]:t[e]=i[e]}))}return new h(t)}catch(t){throw c.error("Failed to load items.",e,t),new Error(`Failed to load items: ${(0,a.prettyPrintArray)(e)}. [${t.message}]`)}}static removeLocalStorage(e){return e=(0,a.stringArray)(e),new Promise(((t,i)=>{chrome.storage.local.remove(e,(()=>{chrome.runtime.lastError?i(chrome.runtime.lastError):t(0)}))}))}static removeSyncStorage(e){return e=(0,a.stringArray)(e),new Promise(((t,i)=>{chrome.storage.sync.remove(e,(()=>{chrome.runtime.lastError?i(chrome.runtime.lastError):t(0)}))}))}static resetLocalStorage(){return new Promise(((e,t)=>{chrome.storage.local.clear((()=>{chrome.runtime.lastError?t(chrome.runtime.lastError):e(0)}))}))}static resetSyncStorage(){return new Promise(((e,t)=>{chrome.storage.sync.clear((()=>{chrome.runtime.lastError?t(chrome.runtime.lastError):e(0)}))}))}static saveLocalStorage(e){return new Promise(((t,i)=>{chrome.storage.local.set(e,(()=>{chrome.runtime.lastError?i(chrome.runtime.lastError):t(0)}))}))}static saveSyncStorage(e){return new Promise(((t,i)=>{chrome.storage.sync.set(e,(()=>{chrome.runtime.lastError?i(chrome.runtime.lastError):t(0)}))}))}static splitKeyNames(e,t=0){return Array(this._maxSplitKeys-t).fill(1).map(((i,s)=>"_"+e+(s+t)))}constructor(e){if(void 0===e)throw new Error("Cannot be called directly, call load() instead.");super(),u(this,"_lastSplitKeys",void 0),u(this,"audioWordlistId",void 0),u(this,"collectStats",void 0),u(this,"contextMenu",void 0),u(this,"customAudioSites",void 0),u(this,"darkMode",void 0),u(this,"domains",void 0),u(this,"enabledDomainsOnly",void 0),u(this,"fillerAudio",void 0),u(this,"muteAudio",void 0),u(this,"muteAudioOnly",void 0),u(this,"muteCueRequireShowing",void 0),u(this,"muteMethod",void 0),u(this,"password",void 0),u(this,"showSubtitles",void 0),u(this,"showUpdateNotification",void 0),u(this,"syncLargeKeys",void 0),u(this,"youTubeAutoSubsMax",void 0),u(this,"youTubeAutoSubsMin",void 0),Object.assign(this,h._classDefaults,e)}ordered(){return Object.keys(this).sort().reduce(((e,t)=>("_"!=t[0]&&(e[t]=this[t]),e)),{})}async remove(e){e=(0,a.stringArray)(e);let t=[];const i=[];if(e.length>0){e.forEach((e=>{"syncLargeKeys"==e?i.push(e):h._largeKeys.includes(e)?this.syncLargeKeys?t=t.concat(h.splitKeyNames(e)):i.push(e):t.push(e)}));try{t.length&&await h.removeSyncStorage(t),i.length&&await h.removeLocalStorage(i),e.forEach((e=>{delete this[e]}))}catch(t){throw c.error("Failed to remove items.",e,t),new Error(`Failed to remove items: ${(0,a.prettyPrintArray)(e)}. ${t.message}`)}}}async reset(){try{await h.resetSyncStorage(),await h.resetLocalStorage()}catch(e){throw c.error("Failed to clear storage.",e),new Error(`Failed to clear storage. ${e.message}`)}}async resetPreserveStats(){try{await h.resetSyncStorage(),await h.removeLocalStorage(h._localConfigKeys)}catch(e){throw c.error("Failed to clear storage.",e),new Error(`Failed to clear storage. ${e.message}`)}}async save(e=[]){e=(0,a.stringArray)(e);const t={},i={};0===e.length&&(e=Object.keys(h._defaults)).push("words");let s=[];e.forEach((e=>{if("syncLargeKeys"==e)i[e]=this[e];else if(h._largeKeys.includes(e))if(this.syncLargeKeys){if(Object.assign(t,this.splitData(e)),this._lastSplitKeys){const i=h.getMaxSplitKeyFromData(t,e);this._lastSplitKeys[e]>i?s=s.concat(h.splitKeyNames(e,i+1)):this._lastSplitKeys[e]null==i[e])),s=Object.keys(t).filter((e=>null==t[e]));e.length&&(await h.removeLocalStorage(e),e.forEach((e=>delete i[e]))),s.length&&(await h.removeSyncStorage(s),s.forEach((e=>delete t[e])))}Object.keys(t).length&&await h.saveSyncStorage(t),Object.keys(i).length&&await h.saveLocalStorage(i),s.length&&await this.remove(s)}catch(t){throw c.error("Failed to save items.",e,t),new Error(`Failed to save items: ${(0,a.prettyPrintArray)(e)}. [${t.message}]`)}}splitData(e){const t=new TextEncoder;let i=0,s=2;const o={};let a=`_${e}${i}`;return o[a]={},s+=t.encode(`{"${a}":{}}`).length,Object.keys(this[e]).sort().forEach((r=>{let l=t.encode(`",${r}":`).length;l+=t.encode(JSON.stringify(this[e][r])).length,s+l>=h._maxBytes&&(i++,a=`_${e}${i}`,o[a]={},s=t.encode(`"${a}":{}`).length),s+=l,o[a][r]=this[e][r]})),o}}t.default=h,u(h,"BUILD",l),u(h,"_classDefaults",{audioWordlistId:0,collectStats:!0,contextMenu:!0,customAudioSites:null,darkMode:null,domains:{},enabledDomainsOnly:!1,fillerAudio:"",muteAudio:!1,muteAudioOnly:!1,muteCueRequireShowing:!1,muteMethod:h.BUILD.config.muteMethod||s.default.MUTE_METHODS.TAB,password:null,showSubtitles:s.default.SHOW_SUBTITLES.ALL,showUpdateNotification:!1,syncLargeKeys:!0,youTubeAutoSubsMax:0,youTubeAutoSubsMin:0}),u(h,"_defaults",Object.assign({},o.default._defaults,h._classDefaults)),u(h,"_localConfigKeys",["domains","syncLargeKeys","words"]),u(h,"_localOnlyKeys",["background","stats"]),u(h,"_maxSplitKeys",64),u(h,"_largeKeys",["domains","words"])},894:function(){ // @license http://unlicense.org/UNLICENSE -"undefined"!=typeof window&&(window.findAndReplaceDOMText=function(){var e="retain",t="first",i=document,s={}.hasOwnProperty;function o(e){return String(e).replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function a(){return r.apply(null,arguments)||n.apply(null,arguments)}function r(e,t,i,s,o){if(t&&!t.nodeType&&arguments.length<=2)return!1;var r,l="function"==typeof i;l&&(r=i,i=function(e,t){return r(e.text,t.startIndex)});var d=n(t,{find:e,wrap:l?null:i,replace:l?i:"$"+(s||"&"),prepMatch:function(e,t){if(!e[0])throw"findAndReplaceDOMText cannot handle zero-length matches";if(s>0){var i=e[s];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:o});return a.revert=function(){return d.revert()},!0}function n(e,t){return new l(e,t)}function l(t,i){var o=i.preset&&a.PRESETS[i.preset];if(i.portionMode=i.portionMode||e,o)for(var r in o)s.call(o,r)&&!s.call(i,r)&&(i[r]=o[r]);this.node=t,this.options=i,this.prepMatch=i.prepMatch||this.prepMatch,this.reverts=[],this.matches=this.search(),this.matches.length&&this.processMatches()}return a.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},a.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},a.NON_INLINE_PROSE=function(e){return s.call(a.NON_CONTIGUOUS_PROSE_ELEMENTS,e.nodeName.toLowerCase())},a.PRESETS={prose:{forceContext:a.NON_INLINE_PROSE,filterElements:function(e){return!s.call(a.NON_PROSE_ELEMENTS,e.nodeName.toLowerCase())}}},a.Finder=l,l.prototype={search:function(){var e,t=0,i=0,s=this.options.find,a=this.getAggregateText(),r=[],n=this;function l(o){for(var a=0,d=o.length;a=l.endIndex?t={node:n,index:u++,text:n.data.substring(l.startIndex-d,l.endIndex-d),indexInMatch:0===d?0:d-l.startIndex,indexInNode:l.startIndex-d,endIndexInNode:l.endIndex-d,isEnd:!0}:e&&r.push({node:n,index:u++,text:n.data,indexInMatch:d-l.startIndex,indexInNode:0}),!e&&n.length+d>l.startIndex&&(e={node:n,index:u++,indexInMatch:0,indexInNode:l.startIndex-d,endIndexInNode:l.endIndex-d,text:n.data.substring(l.startIndex-d,l.endIndex-d)}),d+=n.data.length),i=n.nodeType===Node.ELEMENT_NODE&&a&&!a(n),e&&t){if(n=this.replaceMatch(l,e,r,t),d-=t.node.data.length-t.endIndexInNode,e=null,t=null,r=[],u=0,!(l=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,i,s){var o=this.options.portionMode;return o===t&&i.indexInMatch>0?"":(e=e.replace(/\$(\d+|&|`|')/g,(function(e,t){var i;switch(t){case"&":i=s[0];break;case"`":i=s.input.substring(0,s.startIndex);break;case"'":i=s.input.substring(s.endIndex);break;default:i=s[+t]||""}return i})),o===t?e:i.isEnd?e.substring(i.indexInMatch):e.substring(i.indexInMatch,i.indexInMatch+i.text.length))},getPortionReplacementNode:function(e,t){var s=this.options.replace||"$&";if("function"==typeof s)return(s=s(e,t))&&s.nodeType?s:i.createTextNode(String(s))},replaceMatch:function(e,t,s,o){var a,r,n=t.node,l=o.node;if(n===l){var d=n;t.indexInNode>0&&(a=i.createTextNode(d.data.substring(0,t.indexInNode)),d.parentNode.insertBefore(a,d));var u=this.getPortionReplacementNode(o,e);return d.parentNode.insertBefore(u,d),o.endIndexInNode{"use strict";e.exports=JSON.parse('{"release":true,"config":{"muteMethod":null},"manifestVersion":0,"target":"bookmarklet","version":"2.33.2"}')}},t={};function i(s){var o=t[s];if(void 0!==o)return o.exports;var a=t[s]={exports:{}};return e[s].call(a.exports,a,a.exports,i),a.exports}(()=>{"use strict";var e=l(i(357)),t=l(i(50)),s=l(i(394)),o=l(i(470)),a=l(i(210)),r=l(i(863)),n=l(i(709));function l(e){return e&&e.__esModule?e:{default:e}}function d(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e} +"undefined"!=typeof window&&(window.findAndReplaceDOMText=function(){var e="retain",t="first",i=document,s={}.hasOwnProperty;function o(e){return String(e).replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function a(){return r.apply(null,arguments)||l.apply(null,arguments)}function r(e,t,i,s,o){if(t&&!t.nodeType&&arguments.length<=2)return!1;var r,n="function"==typeof i;n&&(r=i,i=function(e,t){return r(e.text,t.startIndex)});var d=l(t,{find:e,wrap:n?null:i,replace:n?i:"$"+(s||"&"),prepMatch:function(e,t){if(!e[0])throw"findAndReplaceDOMText cannot handle zero-length matches";if(s>0){var i=e[s];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:o});return a.revert=function(){return d.revert()},!0}function l(e,t){return new n(e,t)}function n(t,i){var o=i.preset&&a.PRESETS[i.preset];if(i.portionMode=i.portionMode||e,o)for(var r in o)s.call(o,r)&&!s.call(i,r)&&(i[r]=o[r]);this.node=t,this.options=i,this.prepMatch=i.prepMatch||this.prepMatch,this.reverts=[],this.matches=this.search(),this.matches.length&&this.processMatches()}return a.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},a.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},a.NON_INLINE_PROSE=function(e){return s.call(a.NON_CONTIGUOUS_PROSE_ELEMENTS,e.nodeName.toLowerCase())},a.PRESETS={prose:{forceContext:a.NON_INLINE_PROSE,filterElements:function(e){return!s.call(a.NON_PROSE_ELEMENTS,e.nodeName.toLowerCase())}}},a.Finder=n,n.prototype={search:function(){var e,t=0,i=0,s=this.options.find,a=this.getAggregateText(),r=[],l=this;function n(o){for(var a=0,d=o.length;a=n.endIndex?t={node:l,index:u++,text:l.data.substring(n.startIndex-d,n.endIndex-d),indexInMatch:0===d?0:d-n.startIndex,indexInNode:n.startIndex-d,endIndexInNode:n.endIndex-d,isEnd:!0}:e&&r.push({node:l,index:u++,text:l.data,indexInMatch:d-n.startIndex,indexInNode:0}),!e&&l.length+d>n.startIndex&&(e={node:l,index:u++,indexInMatch:0,indexInNode:n.startIndex-d,endIndexInNode:n.endIndex-d,text:l.data.substring(n.startIndex-d,n.endIndex-d)}),d+=l.data.length),i=l.nodeType===Node.ELEMENT_NODE&&a&&!a(l),e&&t){if(l=this.replaceMatch(n,e,r,t),d-=t.node.data.length-t.endIndexInNode,e=null,t=null,r=[],u=0,!(n=s.shift()))break}else if(!i&&(l.firstChild||l.nextSibling)){l.firstChild?(c.push(l),l=l.firstChild):l=l.nextSibling;continue}for(;;){if(l.nextSibling){l=l.nextSibling;break}if((l=c.pop())===o)break e}}},revert:function(){for(var e=this.reverts.length;e--;)this.reverts[e]();this.reverts=[]},prepareReplacementString:function(e,i,s){var o=this.options.portionMode;return o===t&&i.indexInMatch>0?"":(e=e.replace(/\$(\d+|&|`|')/g,(function(e,t){var i;switch(t){case"&":i=s[0];break;case"`":i=s.input.substring(0,s.startIndex);break;case"'":i=s.input.substring(s.endIndex);break;default:i=s[+t]||""}return i})),o===t?e:i.isEnd?e.substring(i.indexInMatch):e.substring(i.indexInMatch,i.indexInMatch+i.text.length))},getPortionReplacementNode:function(e,t){var s=this.options.replace||"$&";if("function"==typeof s)return(s=s(e,t))&&s.nodeType?s:i.createTextNode(String(s))},replaceMatch:function(e,t,s,o){var a,r,l=t.node,n=o.node;if(l===n){var d=l;t.indexInNode>0&&(a=i.createTextNode(d.data.substring(0,t.indexInNode)),d.parentNode.insertBefore(a,d));var u=this.getPortionReplacementNode(o,e);return d.parentNode.insertBefore(u,d),o.endIndexInNode{"use strict";e.exports=JSON.parse('{"release":true,"config":{"muteMethod":null},"manifestVersion":0,"target":"bookmarklet","version":"2.33.3"}')}},t={};function i(s){var o=t[s];if(void 0!==o)return o.exports;var a=t[s]={exports:{}};return e[s].call(a.exports,a,a.exports,i),a.exports}(()=>{"use strict";var e=n(i(357)),t=n(i(50)),s=n(i(394)),o=n(i(470)),a=n(i(210)),r=n(i(863)),l=n(i(709));function n(e){return e&&e.__esModule?e:{default:e}}function d(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e} /* @preserve - Start User Config */i(894);const u=r.default._defaults;u.words=r.default._defaultWords; /* @preserve - End User Config */ -class c extends s.default{constructor(){super(),d(this,"audio",void 0),d(this,"audioOnly",void 0),d(this,"audioWordlistId",void 0),d(this,"domain",void 0),d(this,"extension",void 0),d(this,"filterText",void 0),d(this,"hostname",void 0),d(this,"iframe",void 0),d(this,"location",void 0),d(this,"mutePage",void 0),d(this,"observer",void 0),d(this,"processMutationTarget",void 0),d(this,"processNode",void 0),d(this,"shadowObserver",void 0),d(this,"stats",void 0),d(this,"updateCounterBadge",void 0),this.extension=!1,this.filterText=!0,this.audioWordlistId=e.default.ALL_WORDS_WORDLIST_ID,this.mutePage=!1,this.processMutationTarget=!1}advancedReplaceText(t,i,s=e.default.STATS_TYPE_TEXT){t.parentNode||t===document?this.wordlists[i].regExps.forEach((e=>{findAndReplaceDOMText(t,{preset:"prose",find:e,replace:(e,t)=>0===e.index?this.replaceText(t[0],i,s):""})})):this.cleanText(t,i,s)}checkMutationForProfanity(e){e.addedNodes.forEach((e=>{o.default.isForbiddenNode(e)||(this.mutePage?this.cleanAudio(e):this.audioOnly||this.processNode(e,this.wordlistId))})),this.mutePage&&this.audio.muted&&e.removedNodes.forEach((e=>{const t=this.audio.supportedNode(e),i=!1!==t?this.audio.rules[t]:this.audio.rules[0];(!1!==t||e==this.audio.lastFilteredNode||e.contains(this.audio.lastFilteredNode)||i.simpleUnmute&&e.textContent&&this.audio.lastFilteredText&&this.audio.lastFilteredText.includes(e.textContent))&&this.audio.unmute(i)})),e.target&&("#text"===e.target.nodeName?this.checkMutationTargetTextForProfanity(e):this.processMutationTarget&&this.processNode(e.target,this.wordlistId))}checkMutationTargetTextForProfanity(e){if(!o.default.isForbiddenNode(e.target))if(this.mutePage){const t=this.audio.supportedNode(e.target),i=!1!==t?this.audio.rules[t]:this.audio.rules[0];if(!1!==t&&i.simpleUnmute)this.audio.muted&&e.oldValue&&this.audio.lastFilteredText&&this.audio.lastFilteredText.includes(e.oldValue)&&this.audio.unmute(i),this.audio.clean(e.target,t);else if(i.simpleUnmute&&this.audio.muted&&!e.target.parentElement)this.audio.lastFilteredText&&this.audio.lastFilteredText.includes(e.target.textContent)&&this.audio.unmute(i);else if(!this.audioOnly){const t=this.replaceTextResult(e.target.data,this.wordlistId);t.modified&&(e.target.data=t.filtered)}}else if(!this.audioOnly){const t=this.replaceTextResult(e.target.data,this.wordlistId);t.modified&&(e.target.data=t.filtered)}}cleanAudio(e){if(this.audio.youTube&&this.audio.youTubeAutoSubsPresent())this.audio.youTubeAutoSubsSupportedNode(e)?this.audio.youTubeAutoSubsCurrentRow(e)?this.audio.cleanYouTubeAutoSubs(e):this.audioOnly||this.processNode(e,this.wordlistId):this.audioOnly||this.audio.youTubeAutoSubsNodeIsSubtitleText(e)||this.processNode(e,this.wordlistId);else{const t=this.audio.supportedNode(e);!1!==t?this.audio.clean(e,t):this.audioOnly||this.processNode(e,this.wordlistId)}}cleanChildNode(t,i,s=e.default.STATS_TYPE_TEXT){if(t.nodeName)if(t.textContent&&""!=t.textContent.trim()){const e=this.replaceTextResult(t.textContent,i,s);e.modified&&this.filterText&&(t.textContent=e.filtered)}else"IMG"==t.nodeName?(this.cleanNodeAttribute(t,"alt",i,s),this.cleanNodeAttribute(t,"title",i,s)):t.shadowRoot&&this.filterShadowRoot(t.shadowRoot,i,s)}cleanNode(t,i,s=e.default.STATS_TYPE_TEXT){if(o.default.isForbiddenNode(t))return!1;if(t.shadowRoot&&this.filterShadowRoot(t.shadowRoot,i,s),t.childNodes.length>0)for(let e=0;e0){const e=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(;e.nextNode();)e.currentNode.childNodes.length>0?e.currentNode.childNodes.forEach((e=>{this.cleanText(e,i,s)})):o.default.isForbiddenNode(e.currentNode)||this.cleanChildNode(e.currentNode,i,s)}else this.cleanChildNode(t,i,s)}filterShadowRoot(t,i,s=e.default.STATS_TYPE_TEXT){this.shadowObserver.observe(t,p),this.processNode(t,i,s)}init(e=!1){super.init(e),this.domain.advanced?this.processNode=this.advancedReplaceText:this.domain.deep?(this.processMutationTarget=!0,this.processNode=this.cleanNode):this.processNode=this.cleanText}processMutations(e){e.forEach((e=>{h.checkMutationForProfanity(e)}))}startObserving(e=document,t=this.observer){t.observe(e,p)}stopObserving(e=this.observer){const t=e.takeRecords();e.disconnect(),t&&this.processMutations(t)}}const h=new c,p={characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0};if("undefined"!=typeof window){if(h.observer=new MutationObserver(h.processMutations),h.shadowObserver=new MutationObserver(h.processMutations),window!=window.top){h.iframe=document.location;try{h.hostname=window.parent.location.hostname}catch(e){document.referrer?h.hostname=new URL(document.referrer).hostname:h.hostname=document.location.hostname}}else h.hostname=document.location.hostname;h.cleanPage()}})()})(); \ No newline at end of file +class c extends s.default{constructor(){super(),d(this,"audio",void 0),d(this,"audioOnly",void 0),d(this,"audioWordlistId",void 0),d(this,"domain",void 0),d(this,"extension",void 0),d(this,"filterText",void 0),d(this,"hostname",void 0),d(this,"iframe",void 0),d(this,"location",void 0),d(this,"mutePage",void 0),d(this,"observer",void 0),d(this,"processMutationTarget",void 0),d(this,"processNode",void 0),d(this,"shadowObserver",void 0),d(this,"stats",void 0),d(this,"updateCounterBadge",void 0),this.extension=!1,this.filterText=!0,this.audioWordlistId=e.default.ALL_WORDS_WORDLIST_ID,this.mutePage=!1,this.processMutationTarget=!1}advancedReplaceText(t,i,s=e.default.STATS_TYPE_TEXT){t.parentNode||t===document?this.wordlists[i].regExps.forEach((e=>{findAndReplaceDOMText(t,{preset:"prose",find:e,replace:(e,t)=>0===e.index?this.replaceText(t[0],i,s):""})})):this.cleanText(t,i,s)}checkMutationForProfanity(e){e.addedNodes.forEach((e=>{o.default.isForbiddenNode(e)||(this.mutePage?this.cleanAudio(e):this.audioOnly||this.processNode(e,this.wordlistId))})),this.mutePage&&this.audio.muted&&e.removedNodes.forEach((e=>{const t=this.audio.supportedNode(e),i=!1!==t?this.audio.rules[t]:this.audio.rules[0];(!1!==t||e==this.audio.lastFilteredNode||e.contains(this.audio.lastFilteredNode)||i.simpleUnmute&&e.textContent&&this.audio.lastFilteredText&&this.audio.lastFilteredText.includes(e.textContent))&&this.audio.unmute(i)})),e.target&&("#text"===e.target.nodeName?this.checkMutationTargetTextForProfanity(e):this.processMutationTarget&&this.processNode(e.target,this.wordlistId))}checkMutationTargetTextForProfanity(e){if(!o.default.isForbiddenNode(e.target))if(this.mutePage){const t=this.audio.supportedNode(e.target),i=!1!==t?this.audio.rules[t]:this.audio.rules[0];if(!1!==t&&i.simpleUnmute)this.audio.muted&&e.oldValue&&this.audio.lastFilteredText&&this.audio.lastFilteredText.includes(e.oldValue)&&this.audio.unmute(i),this.audio.clean(e.target,t);else if(i.simpleUnmute&&this.audio.muted&&!e.target.parentElement)this.audio.lastFilteredText&&this.audio.lastFilteredText.includes(e.target.textContent)&&this.audio.unmute(i);else if(!this.audioOnly){const t=this.replaceTextResult(e.target.data,this.wordlistId);t.modified&&(e.target.data=t.filtered)}}else if(!this.audioOnly){const t=this.replaceTextResult(e.target.data,this.wordlistId);t.modified&&(e.target.data=t.filtered)}}cleanAudio(e){if(this.audio.youTube&&this.audio.youTubeAutoSubsPresent())this.audio.youTubeAutoSubsSupportedNode(e)?this.audio.youTubeAutoSubsCurrentRow(e)?this.audio.cleanYouTubeAutoSubs(e):this.audioOnly||this.processNode(e,this.wordlistId):this.audioOnly||this.audio.youTubeAutoSubsNodeIsSubtitleText(e)||this.processNode(e,this.wordlistId);else{const t=this.audio.supportedNode(e);!1!==t?this.audio.clean(e,t):this.audioOnly||this.processNode(e,this.wordlistId)}}cleanChildNode(t,i,s=e.default.STATS_TYPE_TEXT){if(t.nodeName)if(t.textContent&&""!=t.textContent.trim()){const e=this.replaceTextResult(t.textContent,i,s);e.modified&&this.filterText&&(t.textContent=e.filtered)}else"IMG"==t.nodeName?(this.cleanNodeAttribute(t,"alt",i,s),this.cleanNodeAttribute(t,"title",i,s)):t.shadowRoot&&this.filterShadowRoot(t.shadowRoot,i,s)}cleanNode(t,i,s=e.default.STATS_TYPE_TEXT){if(o.default.isForbiddenNode(t))return!1;if(t.shadowRoot&&this.filterShadowRoot(t.shadowRoot,i,s),t.childNodes.length>0)for(let e=0;e0){const e=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(;e.nextNode();)e.currentNode.childNodes.length>0?e.currentNode.childNodes.forEach((e=>{this.cleanText(e,i,s)})):o.default.isForbiddenNode(e.currentNode)||this.cleanChildNode(e.currentNode,i,s)}else this.cleanChildNode(t,i,s)}filterShadowRoot(t,i,s=e.default.STATS_TYPE_TEXT){this.shadowObserver.observe(t,p),this.processNode(t,i,s)}init(e=!1){super.init(e),this.domain.advanced?this.processNode=this.advancedReplaceText:this.domain.deep?(this.processMutationTarget=!0,this.processNode=this.cleanNode):this.processNode=this.cleanText}processMutations(e){e.forEach((e=>{h.checkMutationForProfanity(e)}))}startObserving(e=document,t=this.observer){t.observe(e,p)}stopObserving(e=this.observer){const t=e.takeRecords();e.disconnect(),t&&this.processMutations(t)}}const h=new c,p={characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0};if("undefined"!=typeof window){if(h.observer=new MutationObserver(h.processMutations),h.shadowObserver=new MutationObserver(h.processMutations),window!=window.top){h.iframe=document.location;try{h.hostname=window.parent.location.hostname}catch(e){document.referrer?h.hostname=new URL(document.referrer).hostname:h.hostname=document.location.hostname}}else h.hostname=document.location.hostname;h.cleanPage()}})()})(); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 78e0de8c..0768d868 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "advancedprofanityfilter", - "version": "2.33.2", + "version": "2.33.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "advancedprofanityfilter", - "version": "2.33.2", + "version": "2.33.3", "license": "SEE LICENSE IN LICENSE", "devDependencies": { "@babel/cli": "^7.17.0", diff --git a/package.json b/package.json index 1a2f9a7f..dd5c54cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "advancedprofanityfilter", - "version": "2.33.2", + "version": "2.33.3", "description": "A browser extension to filter profanity from webpages.", "node": "^12.20.0 || ^14.13.1 || >=16.0.0", "repository": { diff --git a/src/static/manifest.json b/src/static/manifest.json index fe678a68..99145794 100644 --- a/src/static/manifest.json +++ b/src/static/manifest.json @@ -3,7 +3,7 @@ "short_name": "Profanity Filter", "author": "Richard Frost", "manifest_version": 3, - "version": "2.33.2", + "version": "2.33.3", "description": "Advanced Profanity Filter helps to clean up bad language on the websites you and your family visit.", "icons": { "16": "img/icon16.png",