-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.min.js
1 lines (1 loc) · 2.61 KB
/
main.min.js
1
String.prototype.format||(String.prototype.format=function(){var l=arguments;return this.replace(/{(\d+)}/g,function(e,n){return void 0!==l[n]?l[n]:e})});var enable=!0;function main(l){enable&&json.forEach(e=>{window.location.pathname.match(new RegExp(e.path))&&e.rules.forEach(n=>{var r,u=n.properties,t=n.translate,o=n.format,a=n.contains,c=n.append,i=!!n.ignoreCase,s=n.override,f=n.addClasses,d=null==n.equals||null==n.equals?e.equals:n.equals;r=s||null==e.selector||null==e.selector?s||null==e.selectors||null==e.selectors?n.selectors.map(l=>document.querySelectorAll(l)):e.selectors.map(l=>document.querySelectorAll(l)):[document.querySelectorAll(e.selector)];for(var p=0;p<r.length;p++)r[p].forEach(e=>{null!=l&&null!=l&&null!=e&&!e==l||(u.forEach(l=>{tr(e,t,l,n.replace,o,a,c,i,f,d)}),0==u.length&&null!=o?tr(e,t,null,n.replace,o,a,c,i,f,d):0==u.length&&null==n.replace?tr(e,t,null,null,o,a,c,i,f):null!=n.replace&&tr(e,t,null,n.replace,o,a,c,i,f,d))})})})}var config={childList:!0,subtree:!0,attributeOldValue:!1,attributes:!1,characterData:!1},observer=new MutationObserver(l=>{observer.disconnect(),main(null),observer.observe(document,config)});function cca(l,e,n){var r=!1;return e.forEach(e=>{r||(r=n?l.toLowerCase().includes(e.toLowerCase()):l.includes(e))}),r}function equ(l,e){return null==e||null==e||l.toUpperCase()===e.toUpperCase()}function lower(l,e){return e?l.ignoreCase():l}function tr(l,e,n,r,u,t,o,a,c,i){if(null!=l&&null!=l)if((null==t||t&&!n&&cca(l.innerHTML,t,a)||t&&n&&l[n]&&cca(l[n],t,a)&&equ(l[n],i))&&c&&0!=c.length&&c.forEach(e=>l.classList.add(e)),null==e){if(null!=l&&null!=u&&null!=u)if(null!=n){if(null!=document.querySelector(r)&&null!=t&&null!=t&&null!=l[n]&&null!=l[n]&&cca(l[n],t,a)&&equ(l[n],i)){var s=u.format(document.querySelector(r).outerHTML)+(null!=o&&null!=o?o:"");l[n]!=s&&(l[n]=s)}}else if(null!=document.querySelector(r)&&null!=t&&null!=t&&cca(l.innerHTML,t,a)&&equ(l.innerHTML,i)){var f=u.format(document.querySelector(r).outerHTML)+(null!=o&&null!=o?o:"");f!=l.outerHTML&&(l.outerHTML=f)}}else if(null!=n){if(null!=t&&null!=t&&null!=l[n]&&null!=l[n]&&!cca(l[n],t,a)&&!equ(l[n],i))return;if(null!=r&&null!=l[n]){var d=l[n].replace(r,e)+(null!=o&&null!=o?o:"");d!=l[n]&&(l[n]=d)}else{var p=e+(null!=o&&null!=o?o:"");p!=l[n]&&(l[n]=p)}}else{if(null!=t&&null!=t&&!cca(l.innerHTML,t,a)||!equ(l.innerHTML,i))return;if(null!=r){var m=l.innerHTML.replace(r,e)+(null!=o&&null!=o?o:"");l.innerHTML!=m&&(l.innerHTML=m)}else{var v=e+(null!=o&&null!=o?o:"");l.innerHTML!=v&&(l.innerHTML=v)}}}observer.observe(document,config),document.kill=(()=>{enable=!1}),document.equ=((l,e)=>equ(l,e)),document.update=(()=>{main(null)});