EmbyCrackedClient/web/modules/skinmanager.js

1 line
13 KiB
JavaScript
Raw Permalink Normal View History

2025-06-25 11:46:04 +08:00
import connectionManager from"./emby-apiclient/connectionmanager.js";import{appHost}from"./common/servicelocator.js";import userSettings from"./common/usersettings/usersettings.js";import browser from"./browser.js";import events from"./emby-apiclient/events.js";import appSettings from"./common/appsettings.js";let SupportsCSSAccentColor=!1,SupportsNativeAccentColor=SupportsCSSAccentColor||appHost.supports("systemaccentcolor"),themeStyleElement,currentThemeId,currentThemeInfo,currentThemeController;function tryRemove(elem){try{elem.remove()}catch(err){console.log("Error removing child node: "+err)}}let supportsCssVariables=CSS.supports("color","var(--fake-var)");function unloadTheme(){var nextSibling,elem=themeStyleElement;elem&&(supportsCssVariables||(nextSibling=elem.nextSibling)&&nextSibling.getAttribute("data-cssvars-job")&&tryRemove(nextSibling),tryRemove(elem),themeStyleElement=null,currentThemeId=null,currentThemeInfo=null,currentThemeController?.destroy(),currentThemeController=null)}supportsCssVariables||document.documentElement.classList.add("nocssvars");let defaultSettingsThemeIsMainTheme=!supportsCssVariables||appHost.supports("multiserver");function getThemes(){let defaultTheme="dark";supportsCssVariables&&browser.electron?defaultTheme="blueradiance":appHost.getPreferredTheme&&"windows"===appHost.getPreferredTheme()&&(defaultTheme="windows");var themes=[],defaultController="./modules/themes/themecontroller.js";return supportsCssVariables&&themes.push({name:"Apple TV",id:"appletv",controller:defaultController}),themes.push({name:"Black",id:"black",isDefault:"black"===defaultTheme,controller:defaultController}),themes.push({name:"Blue Radiance",id:"blueradiance",isDefault:"blueradiance"===defaultTheme,baseThemeId:"darkgradient",controller:defaultController}),supportsCssVariables,themes.push({name:"Dark",id:"dark",isDefault:"dark"===defaultTheme,controller:defaultController}),supportsCssVariables&&(themes.push({name:"Light",id:"light",isSettingsDefault:!defaultSettingsThemeIsMainTheme,controller:defaultController}),appHost.supports("windowstheme")&&themes.push({name:"Windows",id:"windows",isDefault:"windows"===defaultTheme,skipForSettingsthemes:!0,controller:Emby.Page.baseUrl()+"/modules/themes/windows/windowsthemecontroller.js"}),themes.push({name:"Superman",id:"superman",baseThemeId:"darkgradient",controller:defaultController})),supportsCssVariables&&themes.push({name:"Windows Media Center",id:"wmc",baseThemeId:"darkgradient",controller:defaultController}),themes}let skinManager={loadSkin:loadSkin,getThemes:getThemes,getCurrentThemeId:function(){return currentThemeId},getCurrentThemeInfo:function(){return currentThemeInfo},getCurrentThemeController:function(){return currentThemeController}};function loadSkin(){return skinManager.setTheme(userSettings.theme())}function onRegistrationSuccess(){appSettings.set("appthemesregistered","true")}function onRegistrationFailure(){appSettings.set("appthemesregistered","false")}function isRegistered(){return Emby.importModule("./modules/registrationservices/registrationservices.js").then(function(registrationServices){registrationServices.validateFeature("themes",{showDialog:!1}).then(onRegistrationSuccess,onRegistrationFailure)}),"false"!==appSettings.get("appthemesregistered")}function getThemeStylesheetInfo(id,isSettings,requiresRegistration){id||isSettings||(apiClient=connectionManager.currentApiClient())&&apiClient.getCurrentUserId()||(id=appSettings.get("lastTheme"));var themes=skinManager.getThemes();let defaultMainTheme,defaultSettingsTheme,selectedTheme;for(let i=0,length=themes.length;i<length;i++){var theme=themes[i];theme.isDefault?defaultMainTheme=theme:theme.isSettingsDefault&&(defaultSettingsTheme=theme),id===theme.id&&(selectedTheme=theme)}defaultSettingsThemeIsMainTheme&&(defaultSettingsTheme=defaultMainTheme);var apiClient=isSettings&&"maintheme"!==id?defaultSettingsTheme:defaultMainTheme;return(selectedTheme=selectedTheme||apiClient).id!==apiClient.id&&requiresRegistration&&!isRegistered()&&(selectedTheme=apiClient),{themeInfoPath:"text!"+Emby.Page.baseU