Skip to content

Commit

Permalink
fix(wrapper): sanitize text content to remove all strings
Browse files Browse the repository at this point in the history
  • Loading branch information
rxri committed Aug 27, 2024
1 parent 975d66d commit d5dfb11
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion jsHelper/spicetifyWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,17 @@ window.Spicetify = {
// Filter out non-webpack scripts
.filter((script) => ["extensions", "spicetify", "helper", "theme"].every((str) => !script.src?.includes(str)));

//console.time("sanitize");
await Promise.all(
scripts.map(async (script) => {
try {
const res = await fetch(script.src);
const text = await res.text();
// remove every string from the content
const sanitizedText = text.replace(/(["'`])(?:\\.|[^\\\1])*?\1/g, "");
const src = script.src.split("/").pop();
console.log(`[spicetifyWrapper] Waiting for ${src}`);
for (const pack of text.match(/(?<!["'`])(?:,|{)(\d+): ?\(.,.,./g).map((str) => str.slice(0, -7).slice(1))) {
for (const pack of sanitizedText.match(/(?<!["'`])(?:,|{)(\d+): ?\(.,.,./g).map((str) => str.slice(0, -7).slice(1))) {
//console.debug(`[spicetifyWrapper] Waiting for ${pack} of ${src}`);
while (!require.m || !Object.keys(require.m).includes(pack)) {
await new Promise((r) => setTimeout(r, 100));
Expand All @@ -485,6 +488,7 @@ window.Spicetify = {
})
).then(() => {
console.log("[spicetifyWrapper] All required webpack modules loaded");
//console.timeEnd("sanitize");
chunks = Object.entries(require.m);
cache = Object.keys(require.m).map((id) => require(id));

Expand Down

0 comments on commit d5dfb11

Please sign in to comment.