MCPcopy
hub / github.com/spicetify/cli / htmlMod

Function htmlMod

src/apply/apply.go:132–224  ·  view source on GitHub ↗
(htmlPath string, flags Flag)

Source from the content-addressed store, hash-verified

130}
131
132func htmlMod(htmlPath string, flags Flag) {
133 if len(flags.Extension) == 0 &&
134 !flags.HomeConfig &&
135 !flags.SidebarConfig &&
136 !flags.ExpFeatures {
137 return
138 }
139
140 extensionsHTML := "\n"
141 helperHTML := "\n"
142
143 if flags.InjectThemeJS {
144 extensionsHTML += "<script defer src='extensions/theme.js'></script>\n"
145 }
146
147 if flags.SidebarConfig {
148 helperHTML += "<script defer src='helper/sidebarConfig.js'></script>\n"
149 }
150
151 if flags.HomeConfig {
152 helperHTML += "<script defer src='helper/homeConfig.js'></script>\n"
153 }
154
155 if flags.ExpFeatures {
156 helperHTML += "<script defer src='helper/expFeatures.js'></script>\n"
157 }
158
159 if flags.SpicetifyVer != "" {
160 var extList string
161 for _, ext := range flags.Extension {
162 extList += fmt.Sprintf(`"%s",`, ext)
163 }
164
165 var customAppList string
166 for _, app := range flags.CustomApp {
167 customAppList += fmt.Sprintf(`"%s",`, app)
168 }
169
170 helperHTML += fmt.Sprintf(`<script>
171 Spicetify.Config={};
172 Spicetify.Config["version"]="%s";
173 Spicetify.Config["current_theme"]="%s";
174 Spicetify.Config["color_scheme"]="%s";
175 Spicetify.Config["extensions"] = [%s];
176 Spicetify.Config["custom_apps"] = [%s];
177 Spicetify.Config["check_spicetify_update"]=%v;
178 </script>
179 `, flags.SpicetifyVer, flags.CurrentTheme, flags.ColorScheme, extList, customAppList, flags.CheckSpicetifyUpdate)
180 }
181
182 for _, v := range flags.Extension {
183 if strings.HasSuffix(v, ".mjs") {
184 extensionsHTML += fmt.Sprintf("<script defer type='module' src='extensions/%s'></script>\n", v)
185 } else {
186 extensionsHTML += fmt.Sprintf("<script defer src='extensions/%s'></script>\n", v)
187 }
188 }
189

Callers

nothing calls this directly

Calls 3

GetAppManifestFunction · 0.92
ModifyFileFunction · 0.92
ReplaceFunction · 0.92

Tested by

no test coverage detected