### Dark Reader Mutation Observer Setup Source: https://ru.annas-archive.gl/donate Sets up mutation observers to monitor changes in the DOM and apply Dark Reader's styling dynamically. ```javascript let et=new Map,Ut=new Map; function Ha(e,t){$n(document,e,t),$Le(document.documentElement,n=>{$n(n.shadowRoot,e,t)})} function $n(e,t,n){et.has(e)&&(et.get(e).disconnect(),Ut.get(e).disconnect());let r=new WeakSet; function s(p){Ba(p).forEach(y=>{r.has(y)||(y.style.setProperty("--darkreader-inline-bgcolor", "red"),r.add(y))})}} } ``` -------------------------------- ### Event Listener Setup for Dark Reader Source: https://ru.annas-archive.gl/torrents Sets up event listeners for Dark Reader related events. Use to manage Dark Reader's interaction with the page. ```javascript function xi(e,t){ document.dispatchEvent(new CustomEvent("__darkreader__inlineScriptsAllowed")); let n=\[\]; function r(){ n.forEach(d=>d()), n.splice(0) } function s(d,h,S){ document.addEventListener(d,h,S), n.push(()=>document.removeEventListener(d,h)) } function o(){ (()=>{window?.WPDarkMode?.deactivate&&window.WPDarkMode.deactivate()})() } s("__darkreader__cleanUp",r), s("__darkreader__disableConflictingPlugins",o); ``` -------------------------------- ### Check and Initialize Dark Reader Meta Tag Source: https://ru.annas-archive.gl/contact Checks if the 'darkreader' meta tag exists and has the correct content. If not, it injects the tag and starts the observer. Returns true if the tag was already correct, false otherwise. ```javascript function Ni(){let e=document.querySelector('meta[name="darkreader"]'); return e?e.content!==qn:(Fi(),Ii(),!1) } ``` -------------------------------- ### Manage Loading Styles Source: https://ru.annas-archive.gl/contact Manages the lifecycle of loading styles, including starting, ending, and updating them. It adds and removes style identifiers from a set and updates the fallback style content when necessary. ```javascript function Is(e){let t=++Ti; function n(){if(!pe()||!Ds()){ke.add(t),de(`Current amount of styles loading: ${ke.size}`);let a=document.querySelector(".darkreader--fallback");a.textContent|| (a.textContent=vn(A,{strict:!1})) }} function r(){ke.delete(t),de(`Removed loadingStyle ${t}, now awaiting: ${ke.size}`), ke.size===0&& pe()&& Qn() } function s(){let a=o.details({secondRound:!0}); !a|| (F.addRulesForMatching(a.rules), F.matchVariablesAndDependents()) } let o=ii(e,{update:s,loadingStart:n,loadingEnd:r}); return oe.set(e,o), o } ``` -------------------------------- ### Get Theme Color Function Source: https://ru.annas-archive.gl/llm Retrieves the appropriate background or text color based on the current mode (dark or light scheme). Essential for dynamic theming. ```javascript function hn(e){let n=e.mode===1?"darkSchemeBackgroundColor":"lightSchemeBackgroundColor";return e\[n\]}} ``` ```javascript function gn(e){let n=e.mode===1?"darkSchemeTextColor":"lightSchemeTextColor";return e\[n\]}} ``` -------------------------------- ### Get Membership Parameters from URL Source: https://ru.annas-archive.gl/donate Parses the URL's query string to retrieve membership parameters. This function is essential for dynamically configuring the donation options based on the URL. ```javascript function getMembershipParams() { return Object.fromEntries(new URLSearchParams(location.search)); } ``` -------------------------------- ### Check and Initialize Dark Reader Meta Tag Source: https://ru.annas-archive.gl/faq Checks if the 'darkreader' meta tag exists and has the correct content. If not, it injects the tag and starts the lock meta tag observer. Returns true if the tag is correct, false otherwise. ```javascript function Ni(){let e=document.querySelector('meta[name="darkreader"]'); return e?e.content!==qn:(Fi(),Ii(),!1)} ``` -------------------------------- ### Manage Individual Style Sheet Loading State Source: https://ru.annas-archive.gl/faq Creates an object to manage the loading state of an individual style sheet. It includes methods to signal the start and end of loading, and to re-render styles when changes occur. ```javascript function Is(e){let t=++Ti; function n(){if(!pe()||!Ds()){ke.add(t),de(`Current amount of styles loading: ${ke.size}`);let a=document.querySelector(".darkreader--fallback");a.textContent||(a.textContent=vn(A,{strict:!1}))}} function r(){ke.delete(t),de(`Removed loadingStyle ${t}, now awaiting: ${ke.size}`),ke.size===0&&pe()&&Qn()} function s(){let a=o.details({secondRound:!0});!a||(F.addRulesForMatching(a.rules),F.matchVariablesAndDependents()),o.render(A,se)} let o=ii(e,{update:s,loadingStart:n,loadingEnd:r}); return oe.set(e,o),o} ``` -------------------------------- ### Extract Delimited Content Source: https://ru.annas-archive.gl/donate Finds all occurrences of content enclosed within a start and end delimiter, respecting nested delimiters. Used for parsing complex structures like CSS. ```javascript function at(e,t,n,r=[]){let s=[],o=0,a;for(;a=_r(e,o,t,n,r);)s.push(a),o=a.end;return s} ``` -------------------------------- ### Check if Property is Custom Property Source: https://ru.annas-archive.gl/llm Determines if a given string is a CSS custom property (starts with '--'). ```javascript function Pt(e){return e.startsWith("--")} ``` -------------------------------- ### Handle Theme Switch and Initialize Source: https://ru.annas-archive.gl/torrents Manages theme switching between light and dark modes using local storage. It also updates UI elements to reflect the current theme status and initializes the theme based on stored preference. ```javascript let Js={brightness:100,contrast:90,sepia:0,grayscale:0,useFont:!1,textStroke:0,engine:"dynamicTheme",darkSchemeBackgroundColor:"#181a1b",darkSchemeTextColor:"#e8e6e3",scrollbarColor:"auto",selectionColor:"auto",styleSystemControls:!1,darkColorScheme:"Default",immediateModify:!1},eo=()=>{let O=document.getElementById("light-button");if(!O){setTimeout(()=>eo(),10);return}let B=document.getElementById("dark-button");ge.isEnabled()?(O.classList.remove("hidden"),B.classList.add("hidden")):(O.classList.add("hidden"),B.classList.remove("hidden"))};window.handleThemeSwitch=O=>{switch(O){case"light":localStorage.setItem("theme","light"),ge.disable();break;case"dark":localStorage.setItem("theme","dark"),ge.enable(Js);break;default:ge.auto(Js),localStorage.setItem("theme",ge.isEnabled()?"dark":"light");break}eo()};var pc=localStorage.getItem("theme");handleThemeSwitch(pc);})(); ``` -------------------------------- ### Dark Reader Initialization and Mutation Observer Source: https://ru.annas-archive.gl/donate Initializes Dark Reader, sets up dynamic mode, and observes DOM mutations to re-apply dark mode if necessary. Handles fallback scenarios. ```javascript function ji(e,t,n){A=e,N=t,N?(se=Array.isArray(N.ignoreImageAnalysis)?N.ignoreImageAnalysis:[],rt=Array.isArray(N.ignoreInlineStyle)?N.ignoreInlineStyle:[]):(se=[],rt=[]),A.immediateModify&&uo(()=>!0),Os=n;let r=()=>{let s=()=>{Hi(),document.documentElement.setAttribute("data-darkreader-mode","dynamic"),document.documentElement.setAttribute("data-darkreader-scheme",A.mode?"dark":"dimmed"),Vi()},o=()=>{Xn()};Ui()?Y(document.querySelector(".darkreader--fallback")):Ni()?Bi({success:s,failure:o}):s()};if(document.head)r();else{if(!Ae){let o=J("darkreader--fallback");document.documentElement.appendChild(o),o.textContent=vn(A,{strict:!0})}let s=new MutationObserver(()=>{document.head&&(s.disconnect(),r())});s.observe(document,{childList:!0,subtree:!0})}} ``` -------------------------------- ### Get Theme Text Color Source: https://ru.annas-archive.gl/contact Retrieves the text color for a theme based on its mode (dark or light). ```javascript function gn(e){let n=e.mode===1?"darkSchemeTextColor":"lightSchemeTextColor";return e\[n\]} ``` -------------------------------- ### Fetch Resource with Cache and Credentials Source: https://ru.annas-archive.gl/faq Asynchronously fetches a resource from a given URL. It uses `force-cache` for caching, omits credentials, and sets a referrer. Includes specific handling for Firefox extensions and checks for MIME type and HTTP status. ```javascript async function Xt(e,t,n){let r=await fetch(e,{cache:"force-cache",credentials:"omit",referrer:n});if(Ae&&t==="text/css"&&e.startsWith("moz-extension://")&&e.endsWith(".css"))return r;if(t&&!r.headers.get("Content-Type").startsWith(t))throw new Error(\`Mime type mismatch when loading ${e}\");if(!r.ok)throw new Error(\`Unable to load ${e} ${r.status} ${r.statusText}\");return r} ``` -------------------------------- ### Get Theme Background Color Source: https://ru.annas-archive.gl/contact Retrieves the background color for a theme based on its mode (dark or light). ```javascript function hn(e){let n=e.mode===1?"darkSchemeBackgroundColor":"lightSchemeBackgroundColor";return e\[n\]} ``` -------------------------------- ### Initialize Dark Reader Theme Source: https://ru.annas-archive.gl/llm Initializes or updates the Dark Reader theme based on provided options and fixes. Throws an error if the engine is not 'dynamicTheme'. ```javascript function Ks(e={},t=null){let n={...Sr,...e};if(n.engine!==mt.dynamicTheme)throw new Error("Theme engine is not supported.");ji(n,t,tc),Jn=!0} ``` -------------------------------- ### Get Modifier for Dependent Variable Source: https://ru.annas-archive.gl/llm Retrieves a modifier for a variable that depends on another, using provided context. ```javascript function $a(e,t,n){return e.getModifierForVarDependant(t,n)} ``` -------------------------------- ### Get Modifier for Variable Source: https://ru.annas-archive.gl/donate Generates a modifier function for a given CSS variable. This function can be used to update styles when the variable's type or value changes. It handles different variable types like colors and gradients. ```javascript odifierForVariable(t){return n=>{let{varName:r,sourceValue:s,rule:o,ignoredImgSelectors:a,isCancelled:i}=t,l=()=>{let b=\[\];C=(E,p,y)=>{if(!this.isVarType(r,E))return;let f=p(r),k;if(Ce(s))if(fs(s)){let m=Dn(s,this.unstableVarValues);m||(m=E===re?"#ffffff":"#000000"),k=y(m,n)}else k=Se(s,m=>p(m),m=>y(m,n));else k=y(s,n);b.push({property:f,value:k})};if(C(re,Xe,Ee),C(Ie,An,Ze),C(Fe,Ln,It),this.isVarType(r,Ye)){let E=us(r),p=s;Ce(s)&&(p=Se(s,f=>Xe(f),f=>Ee(f,n)));let y=is(p,o,a,i);p=typeof y=="function"?y(n):y,b.push({property:E,value:p})}return b},c=new Set,u=b=>{let C=()=>{let E=l();b(E)};c.add(C),this.subscribeForVarTypeChange(r,C)},g=()=>{c.forEach(b=>{this.unsubscribeFromVariableTypeChanges(r,b)})};return{declarations:l(),onTypeChange:{addListener:u,removeListeners:g}}}} ``` -------------------------------- ### Get Dark Scheme Text Color Source: https://ru.annas-archive.gl/faq Retrieves the text color for the dark scheme based on the mode. ```javascript function gn(e){let n=e.mode===1?"darkSchemeTextColor":"lightSchemeTextColor";return e[n]} ``` -------------------------------- ### Dark Reader Initialization and Theme Switching Source: https://ru.annas-archive.gl/donate Initializes Dark Reader based on local storage settings and handles manual theme switching between light and dark modes. It updates UI elements to reflect the current theme state. ```javascript var ge=mc(Zs()),Js={brightness:100,contrast:90,sepia:0,grayscale:0,useFont:!1,textStroke:0,engine:"dynamicTheme",darkSchemeBackgroundColor:"#181a1b",darkSchemeTextColor:"#e8e6e3",scrollbarColor:"auto",selectionColor:"auto",styleSystemControls:!1,darkColorScheme:"Default",immediateModify:!1},eo=()=>{let O=document.getElementById("light-button");if(!O){setTimeout(()=>eo(),10);return}let B=document.getElementById("dark-button");ge.isEnabled()?(O.classList.remove("hidden"),B.classList.add("hidden")):(O.classList.add("hidden"),B.classList.remove("hidden"))};window.handleThemeSwitch=O=>{switch(O){case"light":localStorage.setItem("theme","light"),ge.disable();break;case"dark":localStorage.setItem("theme","dark"),ge.enable(Js);break;default:ge.auto(Js),localStorage.setItem("theme",ge.isEnabled()?"dark":"light");break}eo()};var pc=localStorage.getItem("theme");handleThemeSwitch(pc);})(); ``` -------------------------------- ### Get Dark Scheme Background Color Source: https://ru.annas-archive.gl/faq Retrieves the background color for the dark scheme based on the mode. ```javascript function hn(e){let n=e.mode===1?"darkSchemeBackgroundColor":"lightSchemeBackgroundColor";return e[n]} ``` -------------------------------- ### Initialize DarkReader dynamic mode Source: https://ru.annas-archive.gl/torrents Initializes DarkReader in dynamic mode, applying theme settings based on user preferences. Handles fallback scenarios if the document head is not immediately available. ```javascript function ji(e, t, n) { A = e, N = t, N ? (se = Array.isArray(N.ignoreImageAnalysis) ? N.ignoreImageAnalysis : [], rt = Array.isArray(N.ignoreInlineStyle) ? N.ignoreInlineStyle : []) : (se = [], rt = []); A.immediateModify && uo(() => !0), Os = n; let r = () => { let s = () => { Hi(), document.documentElement.setAttribute("data-darkreader-mode", "dynamic"), document.documentElement.setAttribute("data-darkreader-scheme", A.mode ? "dark" : "dimmed"), Vi() }; let o = () => { Xn() }; Ui() ? Y(document.querySelector(".darkreader--fallback")) : Ni() ? Bi({ success: s, failure: o }) : s() }; if (document.documentElement) r(); else { if (!Ae) { let o = J("darkreader--fallback"); document.documentElement.appendChild(o), o.textContent = vn(A, { strict: !0 }) } let s = new MutationObserver(() => { document.head && (s.disconnect(), r()) }); s.observe(document, { childList: !0, subtree: !0 }) } } ``` -------------------------------- ### Get Modifier for Dependent Variable Source: https://ru.annas-archive.gl/faq Retrieves a modifier function for a variable that depends on another variable's value. ```javascript function $a(e, t, n) { return e.getModifierForVarDependant(t, n) } ``` -------------------------------- ### Create Image Bitmap Source: https://ru.annas-archive.gl/faq Attempts to create an ImageBitmap from a given image data. Logs an error if it fails. ```javascript async function aa(e){try{return await createImageBitmap(e)}catch(t){return yr(\`Unable to create image bitmap for type ${e.type}: ${String(t)}\`),null}} ``` -------------------------------- ### Time Scheme Options Source: https://ru.annas-archive.gl/donate Enumerates options for time-based schemes, including none, time, system, and location. ```javascript var en;(function(e){e.NONE="",e.TIME="time",e.SYSTEM="system",e.LOCATION="location"})(en||(en={})) ``` -------------------------------- ### Get HSL from CSS Color String Source: https://ru.annas-archive.gl/contact Parses a CSS color string and converts it to HSL format. Caches results. ```javascript function Fr(e){if(vt.has(e))return vt.get(e);let t=Q(e);if(!t)return null;let n=Lt(t);return vt.set(e,n),n} ``` -------------------------------- ### Get Modifier for CSS Variable Source: https://ru.annas-archive.gl/llm Retrieves a modifier for a CSS variable, considering its source value, rule, and ignored selectors. ```javascript function Oa(e,t,n,r,s,o){return e.getModifierForVariable({varName:t,sourceValue:n,rule:r,ignoredImgSelectors:s,isCancelled:o})} ``` -------------------------------- ### Get Dark Reader Blob URL Status Source: https://ru.annas-archive.gl/faq Returns whether the Dark Reader blob URL check has been completed. ```javascript function ga(){return Qe!=null||!xn} ``` -------------------------------- ### Get Modifier for Variable Source: https://ru.annas-archive.gl/faq Retrieves a modifier function for a CSS variable, considering its name, source value, rule, and specific selectors. ```javascript function Oa(e, t, n, r, s, o) { return e.getModifierForVariable({varName: t, sourceValue: n, rule: r, ignoredImgSelectors: s, isCancelled: o}) } ``` -------------------------------- ### Create Style Element Source: https://ru.annas-archive.gl/contact Creates a new style element, adding 'darkreader' class and setting media to 'screen'. Optionally copies the title from the source element. ```javascript function di(e,t){if(!t)return null;let n=document.createElement("style");return n.classList.add("darkreader"),n.classList.add("da ``` -------------------------------- ### Get Modifier for CSS Variable Source: https://ru.annas-archive.gl/llm Generates a modifier function for CSS variables based on variable type and context. Useful for dynamic style adjustments. ```javascript getModifierForVariable(t){return n=>{let{varName:r,sourceValue:s,rule:o,ignoredImgSelectors:a,isCancelled:i}=t,l=()=>{let b=\[\] ,C=(E,p,y)=>{if(!this.isVarType(r,E))return;let f=p(r),k; if(Ce(s))if(fs(s)){let m=Dn(s,this.unstableVarValues);m||(m=E===re?"#ffffff":"#000000"),k=y(m,n)}else k=Se(s,m=>p(m),m=>y(m,n));else k=y(s,n); b.push({property:f,value:k})}; if(C(re,Xe,Ee),C(Ie,An,Ze),C(Fe,Ln,It),this.isVarType(r,Ye)){let E=us(r),p=s; Ce(s)&&(p=Se(s,f=>Xe(f),f=>Ee(f,n)));let y=is(p,o,a,i); p=typeof y==="function"?y(n):y,b.push({property:E,value:p})} return b },c=new Set,u=b=>{let C=()=>{let E=l();b(E)};c.add(C),this.subscribeForVarTypeChange(r,C)},g=()=>{c.forEach(b=>{this.unsubscribeFromVariableTypeChanges(r,b)})}; return{declarations:l(),onTypeChange:{addListener:u,removeListeners:g}}}} ``` -------------------------------- ### Handle Dark Reader Initialization Success/Failure Source: https://ru.annas-archive.gl/contact Manages the initialization process of Dark Reader, including checking for existing meta tags and handling potential failures. It uses a counter to ensure all checks are completed before proceeding. ```javascript let Wi=2; function Bi({success:e,failure:t}){ if(--Wi<=0){ t(); return } let n=document.head.querySelector('meta[name="darkreader"]'); if(!n||n.content===qn) return let r=document.createElement("meta"); r.name="darkreader-lock",document.head.append(r), queueMicrotask(()=>{ r.remove(), e() }) } ``` -------------------------------- ### Get Modifier for Variable Dependency Source: https://ru.annas-archive.gl/faq Determines the appropriate modifier function for a CSS variable dependency, handling various color formats and background properties. ```javascript getModifierForVarDependant(t,n){let r=n.match(/^\s\*(rgb|hsl)a?\(/),s=n.match(/^rgba?\(var\(--[\-\_A-Za-z0-9]+\)(\s\*,?\/?\s\*0?\.\d+)?\)$/);if(r&&!s){let o=t.startsWith("background"),a=Mn(t);return i=>{let l=Dn(n,this.unstableVarValues);return l||(l=o?"#ffffff":"#000000"),(o?Ee:a?Ze:It)(l,i)}}return t==="background-color"||s&&t==="background"?o=>{let a=Ee(r?"255, 255, 255":"#ffffff",o);return Se(n,i=>Xe(i),i=>Ee(i,o),a)}:Mn(t)?o=>{let a=Ze(r?"0, 0, 0":"#000000",o);return Se(n,i=>An(i),i=>Ze(i,o),a)}:t==="background"||t==="background-image"||t==="box-shadow"?o=>{let a=new Set,i=()=>{let c=Se(n,u=>this.isVarType(u,re)?Xe(u):this.isVarType(u,Ye)?us(u):(a.add(u),u),u=>Ee(u,o));if(t==="box-shadow"){let g=cs(c)(o);if(g.unparseableMatchesLength!==g.matchesLength)return g.result}return c},l=i();return a.size>0?l.match(/^var\(.\*?, (var\(--darkreader-bg--.\*\))|(#\[0-9A-Fa-f\]+)|(\[a-z\]+)|(rgba?\(.+\))|(hsla?\(.+\))\)$/)?l:new Promise(u=>{for(let g of a.values()){let b=()=>{this.unsubscribeFromVariableTypeChanges(g,b);let C=i();u(C)};this.subscribeForVarTypeChange(g,b)}}):l}:t.startsWith("border")||t.startsWith("outline")?o=>Se(n,a=>Ln(a),a=>It(a,o)):null} ``` -------------------------------- ### Checking for Complete Document Load Source: https://ru.annas-archive.gl/llm A simple utility function to check if the document's ready state is 'complete'. This is a stricter check than 'interactive' and ensures all resources have been loaded. ```javascript function yt(){return document.readyState==="complete"} ``` -------------------------------- ### Initialize Dark Reader Dynamic Mode Source: https://ru.annas-archive.gl/faq Initializes Dark Reader with dynamic mode, applying theme settings and fallback mechanisms. Use when Dark Reader needs to adapt to the page's content dynamically. ```javascript function ji(e,t,n){A=e,N=t,N?(se=Array.isArray(N.ignoreImageAnalysis)?N.ignoreImageAnalysis:[]):(se=[],rt=[]),A.immediateModify&&uo(()=>!0),Os=n;let r=()=>{let s=()=>{Hi(),document.documentElement.setAttribute("data-darkreader-mode","dynamic"),document.documentElement.setAttribute("data-darkreader-scheme",A.mode?"dark":"dimmed"),Vi()},o=()=>{Xn()};Ui()?Y(document.querySelector(".darkreader--fallback")):Ni()?Bi({success:s,failure:o}):s()};if(document.head)r();else{if(!Ae){let o=J("darkreader--fallback");document.documentElement.appendChild(o),o.textContent=vn(A,{strict:!0})}let s=new MutationObserver(()=>{document.head&&(s.disconnect(),r())});s.observe(document,{childList:!0,subtree:!0})}} ``` -------------------------------- ### Get Modifier for Variable Source: https://ru.annas-archive.gl/faq Generates a modifier function for a given variable. It handles different variable types and applies transformations based on provided functions. ```javascript getModifierForVariable(t){return n=>{let{varName:r,sourceValue:s,rule:o,ignoredImgSelectors:a,isCancelled:i}=t,l=()=>{let b=[],C=(E,p,y)=>{if(!this.isVarType(r,E))return;let f=p(r),k;if(Ce(s))if(fs(s)){let m=Dn(s,this.unstableVarValues);m||(m=E===re?"#ffffff":"#000000"),k=y(m,n)}else k=Se(s,m=>p(m),m=>y(m,n));else k=y(s,n);b.push({property:f,value:k})};if(C(re,Xe,Ee),C(Ie,An,Ze),C(Fe,Ln,It),this.isVarType(r,Ye)){let E=us(r),p=s;Ce(s)&&(p=Se(s,f=>Xe(f),f=>Ee(f,n)));let y=is(p,o,a,i);p=typeof y=="function"?y(n):y,b.push({property:E,value:p})}return b},c=new Set,u=b=>{let C=()=>{let E=l();b(E)};c.add(C),this.subscribeForVarTypeChange(r,C)},g=()=>{c.forEach(b=>{this.unsubscribeFromVariableTypeChanges(r,b)})};return{declarations:l(),onTypeChange:{addListener:u,removeListeners:g}}}} ``` -------------------------------- ### Initialize Language Settings from Cookie or Browser Source: https://ru.annas-archive.gl/llm Initializes language settings by checking for an existing language cookie. If found, it refreshes the cookie and redirects if necessary. If no cookie exists, it attempts to detect the browser's preferred language and set a cookie. ```javascript const cookieLangMatch = document.cookie.match(/selected\_lang=(\[^$ ;}\]+)/); if (cookieLangMatch) { let explicitlyRequestedLangCode = cookieLangMatch[1]; setLangCookie(explicitlyRequestedLangCode); if (explicitlyRequestedLangCode !== subDomainLangCode) { redirectLang(explicitlyRequestedLangCode); } } ``` -------------------------------- ### Initialize Color Map in JavaScript Source: https://ru.annas-archive.gl/contact Creates a JavaScript Map from an object containing color names and their corresponding hex values. Useful for quick color lookups. ```javascript jr=new Map(Object.entries({ActiveBorder:3906044,ActiveCaption:0,AppWorkspace:11184810,Background:6513614,ButtonFace:16777215,ButtonHighlight:15329769,ButtonShadow:10461343,ButtonText:0,CaptionText:0,GrayText:8355711,Highlight:11720703,HighlightText:0,InactiveBorder:16777215,InactiveCaption:16777215,InactiveCaptionText:0,InfoBackground:16514245,InfoText:0,Menu:16185078,MenuText:16777215,Scrollbar:11184810,ThreeDDarkShadow:0,ThreeDFace:12632256,ThreeDHighlight:16777215,ThreeDLightShadow:16777215,ThreeDShadow:0,Window:15527148,WindowFrame:11184810,WindowText:0,"-webkit-focus-ring-color":15046400}).map((\[e,t\])=> \[e.toLowerCase(),t\])) ``` -------------------------------- ### Find Delimited Substrings Source: https://ru.annas-archive.gl/contact Finds all occurrences of substrings delimited by a start and end character, respecting nested delimiters and quoted strings. Used for parsing CSS. ```javascript function at(e, t, n, r = []) { let s = [], o = 0, a; for (; a = _r(e, o, t, n, r); ) s.push(a), o = a.end; return s } ``` -------------------------------- ### Start/Stop Dark Reader Inline Script Source: https://ru.annas-archive.gl/faq Manages the lifecycle of an inline script for Dark Reader, allowing it to start and stop its operations. It listens for update events. ```javascript let Nt=!1;document.addEventListener("\_\_darkreader\_inlineScriptsAllowed",()=>Nt=!0,{once:!0});function ei(e,t,n,r){let s=null;function o(){l(),Nt&&e.sheet||(s=ti(e,t,n,r),s.start())}function i(){if(Nt=!0,s?.stop(),a)return;function g(){a=!1,!r()&&n()}a=!0,queueMicrotask(g)}function l(){e.addEventListener("\_\_darkreader\_updateSheet",i)}function c(){e.removeEventListener("\_\_darkreader\_updateSheet",i)}function u(){c(),s?.stop()}return{start:o,stop:u}} ``` -------------------------------- ### Initialize Style Processor Source: https://ru.annas-archive.gl/contact Sets up a style processor for a given element, managing its associated dark reader styles, CORS handling, and synchronization. It observes DOM mutations and handles style updates. ```javascript function ii(e,{update:t,loadingStart:n,loadingEnd:r}){let s=\[\]\,o=e;for(;(o=o.nextElementSibling)&&o.matches(".darkreader");)s.push(o);let a=s.find(x=>x.matches(".darkreader--cors")&&!Cs.has(x))||null,i=s.find(x=>x.matches(".darkreader--sync")&&!xs.has(x))||null,l=null,c=null,u=!1,g=!0,b=()=>u,C=Wn(),E=new MutationObserver(x=>{\nif(x.some(M=>M.type===\"characterData\")&&y()){let M=(e.textContent??"").trim();v(M,location.href).then(t)}\nelse t() }),p={attributes:!0,childList:!0,subtree:!0,characterData:!0};function y(){return e instanceof HTMLStyleElement?Nn(e.textContent??"").trim().match(Tr):!1}function f(x,M){let P=!1;if(x){let U;e:for(let X=0,K=x.length;X{d=!1,r(),P&&t()}).catch(P=>{d=!1,r()})),null)}let $=!1;function G(x,M){let P=k();if(!P)return;u=!1;function U(j){if(!!j)for(let Z=j.cssRules.length-1;Z>=0;Z--)j.deleteRule(Z)}function X(){i||w(),c&&c.stop(),m(),i.sheet==null&&(i.textContent="");let j=i.sheet;return U(j),c?c.run():c=sn(i,"prev-sibling",()=>{$=!0,K()}),i.sheet}function K(){let j=$;$=!1,C.modifySheet({prepareSheet:X,sourceCSSRules:P,theme:x,ignoreImageAnalysis:M,force:j,isAsyncCancelled:b}),g=i.sheet.cssRules.length===0,C.shouldRebuildStyle()&&an(()=>t())}K()}function we(){try{return e.sheet==null?(\[null,null\]):(\[e.sheet.cssRules,null\])}catch(x){return(\[null,x\])}}function lt(x){return x&&x.message&&x.message.includes("loading")}function I(){let\[x,M\]=we();return M?null:x}let W=ei(e,I,t,b);function H(){E.disconnect(),u=!0,l&&l.stop(),c&&c.stop(),W.stop()}function R(){if(H(),Y(a),Y(i),r(),Ne.has(S)){let x=Ne.get(S);Ne.delete(S),x&&x()}}function T(){E.observe(e,p),e instanceof HTMLStyleElement&&W.start()}let D=10,L=0;function q(){!i||(L++,!(L>D)&&(m(),l&&l.skip(),c&&c.skip(),g||($=!0,t())))}return{details:V,render:G,pause:H,destroy:R,watch:T,restore:q}} ``` -------------------------------- ### Get Modifier for Variable Dependency Source: https://ru.annas-archive.gl/llm Determines the appropriate modifier function for CSS properties that depend on variable values. Handles various color and background properties. ```javascript getModifierForVarDependant(t,n){let r=n.match(/^\s\*(rgb|hsl)a?\(/),s=n.match(/^rgba?\(var\(--\[\-\_A-Za-z0-9\]+\)(\s\*,?\/?\s\*0?\.\d+)?\)$/); if(r&&!s){let o=t.startsWith("background"),a=Mn(t); return i=>{let l=Dn(n,this.unstableVarValues);return l||(l=o?"#ffffff":"#000000"),(o?Ee:a?Ze:It)(l,i)}} return t==="background-color"||s&&t==="background"?o=>{let a=Ee(r?"255, 255, 255":"#ffffff",o); return Se(n,i=>Xe(i),i=>Ee(i,o),a)}:Mn(t)?o=>{let a=Ze(r?"0, 0, 0":"#000000",o); return Se(n,i=>An(i),i=>Ze(i,o),a)}:t==="background"||t==="background-image"||t==="box-shadow"?o=>{let a=new Set,i=()=>{let c=Se(n,u=>this.isVarType(u,re)?Xe(u):this.isVarType(u,Ye)?us(u):(a.add(u),u),u=>Ee(u,o)); if(t==="box-shadow"){let g=cs(c)(o);if(g.unparseableMatchesLength!==g.matchesLength)return g.result} return c },l=i(); return a.size>0?l.match(/^var\(.\*?, (var\(--darkreader-bg--.\*\))|(#\[0-9A-Fa-f\]+)|(\[a-z\]+)|(rgba?\(.+\))|(hsla?\(.+\))\)$/)?l:new Promise(u=>{for(let g of a.values()){let b=()=>{this.unsubscribeFromVariableTypeChanges(g,b);let C=i();u(C)};this.subscribeForVarTypeChange(g,b)}}):l}:t.startsWith("border")||t.startsWith("outline")?o=>Se(n,a=>Ln(a),a=>It(a,o)):null} ``` -------------------------------- ### Initialize and Manage Stylesheets Source: https://ru.annas-archive.gl/contact Initializes Dark Reader's style management, processes existing stylesheets, applies root variables, and sets up watchers for dynamic style changes. It also handles adopted stylesheets and CSS variable matching. ```javascript function Mi(){Us();let t=ye(document).filter(s=>!oe.has(s)).map(s=>Is(s));t.map(s=>s.details({secondRound:!1})).filter(s=>s&&s.rules.length>0).forEach(s=>{ F.addRulesForMatching(s.rules) }),F.matchVariablesAndDependents(),F.setOnRootVariableChange(()=>{ let s=J("darkreader--root-vars"); F.putRootVars(s,A) }); let n=J("darkreader--root-vars"); F.putRootVars(n,A), oe.forEach(s=>s.render(A,se)), ke.size===0&& Qn(), t.forEach(s=>s.watch()); let r=co(document.querySelectorAll(Je)); if(Le(document.documentElement,s=>{ Kn(s.shadowRoot); let o=s.shadowRoot.querySelectorAll(Je); o.length>0&& ne(o,t=>Un(t,A,rt,se)) })), r.forEach(s=>Un(s,A,rt,se)), Bs(document), Ae&& let s=Symbol(),o=a=>{ let{node:i,id:l,cssRules:c,entries:u}=a.detail; Array.isArray(u)?( u.forEach(b=>{ let C=b[2]; F.addRulesForMatching(C) }), F.matchVariablesAndDependents() ):c&& (F.addRulesForMatching(c), kr(s,()=>F.matchVariablesAndDependents()) ), (Array.isArray(u)?u:[i,l,c]?.[i,l,c]).forEach(( [b,C,E] )=>{ Vs.set(b,C), Hs(b).updateCSS(E) }) }; document.addEventListener("\_\_darkreader\_\_adoptedStyleSheetsChange",o), Yn.push(()=>document.removeEventListener("\_\_darkreader\_\_adoptedStyleSheetsChange",o)), document.dispatchEvent(new CustomEvent("\_\_darkreader\_\_startAdoptedStyleSheetsWatcher")), } } ``` -------------------------------- ### Deferred Execution Based on Complete Document Load Source: https://ru.annas-archive.gl/llm Manages a set of callback functions that are executed only when the document's ready state is 'complete'. Similar to 'on', but uses a stricter 'yt' check. ```javascript let kt=new Set;function an(e){yt()?e():kt.add(e)} ``` -------------------------------- ### Get the base directory of a URL Source: https://ru.annas-archive.gl/torrents Extracts the directory path of a given URL, excluding the filename and query parameters. This is useful for constructing relative paths within the same directory. ```javascript function \_t(e){let t=Ct(e);return`${t.origin}${t.pathname.replace(/\?.\*$/,"").replace(/(\/)(\[^\/\\\]+)$/i,"$1")}`} ``` -------------------------------- ### Initialize Dark Reader Source: https://ru.annas-archive.gl/llm Initializes Dark Reader by setting up mutation observers and applying styles. Handles cases where the document head is not immediately available. ```javascript function ji(e,t,n){A=e,N=t,N?(se=Array.isArray(N.ignoreImageAnalysis)?N.ignoreImageAnalysis:[]),(rt=Array.isArray(N.ignoreInlineStyle)?N.ignoreInlineStyle:[]) :(se=[],rt=[]),A.immediateModify&&uo(()=>!0),Os=n;let r=()=>{let s=()=>{Hi(),document.documentElement.setAttribute("data-darkreader-mode","dynamic"),document.documentElement.setAttribute("data-darkreader-scheme",A.mode?"dark":"dimmed"),Vi()},o=()=>{Xn()};Ui()?Y(document.querySelector(".darkreader--fallback")):Ni()?Bi({success:s,failure:o}):s()};if(document.head)r();else{if(!Ae){let o=J("darkreader--fallback");document.documentElement.appendChild(o),o.textContent=vn(A,{strict:!0})}}let s=new MutationObserver(()=>{document.head&&(s.disconnect(),r())});s.observe(document,{childList:!0,subtree:!0})} ``` -------------------------------- ### Color Name to Hex Map Initialization Source: https://ru.annas-archive.gl/donate Initializes a Map with common color names and their corresponding hex values. Used for color lookups. ```javascript 88564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgrey:11119017,darkgreen:25600,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,grey:8421504,green:32768,greenyellow:11403055,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgrey:13882323,lightgreen:9498256,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074}) ``` ```javascript jr=new Map(Object.entries({ActiveBorder:3906044,ActiveCaption:0,AppWorkspace:11184810,Background:6513614,ButtonFace:16777215,ButtonHighlight:15329769,ButtonShadow:10461343,ButtonText:0,CaptionText:0,GrayText:8355711,Highlight:11720703,HighlightText:0,InactiveBorder:16777215,InactiveCaption:16777215,InactiveCaptionText:0,InfoBackground:16514245,InfoText:0,Menu:16185078,MenuText:16777215,Scrollbar:11184810,ThreeDDarkShadow:0,ThreeDFace:12632256,ThreeDHighlight:16777215,ThreeDLightShadow:16777215,ThreeDShadow:0,Window:15527148,WindowFrame:11184810,WindowText:0,"-webkit-focus-ring-color":15046400}).map((\[e,t\])=>(\[e.toLowerCase(),t\]))) ``` -------------------------------- ### Get or Create a Symbol for Element Identification Source: https://ru.annas-archive.gl/faq Generates a unique Symbol for a given element if one doesn't exist. Symbols are used internally for managing element-specific states and watchers. ```javascript function Oi(e){if(Gn.has(e))return Gn.get(e); let t=Symbol(); return Gn.set(e,t),t} ``` -------------------------------- ### Initialize MutationObserver and handle mutations Source: https://ru.annas-archive.gl/torrents Sets up a MutationObserver to watch for changes in a DOM element. It handles both minor and potentially huge mutations, with specific callbacks for each. The observer is configured to watch for child list changes and subtree modifications. ```javascript function Cr(e,t){let n,r,s;if(wt.has(e))n=wt.get(e),r=cn.get(n);else{let o=!1,a=!1;n=new MutationObserver(i=>{if(ho(i))!o||pe()?r.forEach(({onHugeMutations:l})=>l(e)):a||(s=()=>r.forEach(({onHugeMutations:l})=>l(e)),on(s),a=!0),o=!0;else{let l=go(i);r.forEach(({onMinorMutations:c})=>c(e,l))}}),n.observe(e,{childList:!0,subtree:!0}),wt.set(e,n),r=new Set,cn.set(n,r)}return r.add(t),{disconnect(){r.delete(t),s&&wr(s),r.size===0&&(n.disconnect(),cn.delete(n),wt.delete(e))}}} ``` -------------------------------- ### Fetch Resource as Text Source: https://ru.annas-archive.gl/faq Fetches a resource from a URL and returns its content as text. It utilizes the `Xt` function for fetching, ensuring proper handling of cache, credentials, and potential errors. ```javascript async function hr(e,t){let n=await Xt(e,t);return await gr(n)} ``` -------------------------------- ### Initialize Canvas for Image Analysis Source: https://ru.annas-archive.gl/torrents Initializes an offscreen canvas and its 2D rendering context for image analysis. The context is configured for high-frequency reading to optimize performance. ```javascript function la(){let e=wn,t=wn;$e=document.createElement("canvas"),$e.width=e,$e.height=t,Pe=$e.getContext("2d",{willReadFrequently:!0}),Pe.imageSmoothingEnabled=!1} ```