forked from Vendicated/Vencord
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert mozilla store compliance changes
This reverts commit 97b6699. Vencord is dropping support for the firefox extension, so these changes are now obsolete. revert so users can still install the extension manually and enjoy the full experience
- Loading branch information
1 parent
390987e
commit d81302f
Showing
7 changed files
with
53 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* @template T | ||
* @param {T[]} arr | ||
* @param {(v: T) => boolean} predicate | ||
*/ | ||
function removeFirst(arr, predicate) { | ||
const idx = arr.findIndex(predicate); | ||
if (idx !== -1) arr.splice(idx, 1); | ||
} | ||
|
||
chrome.webRequest.onHeadersReceived.addListener( | ||
({ responseHeaders, type, url }) => { | ||
if (!responseHeaders) return; | ||
|
||
if (type === "main_frame") { | ||
// In main frame requests, the CSP needs to be removed to enable fetching of custom css | ||
// as desired by the user | ||
removeFirst(responseHeaders, h => h.name.toLowerCase() === "content-security-policy"); | ||
} else if (type === "stylesheet" && url.startsWith("https://raw.githubusercontent.com/")) { | ||
// Most users will load css from GitHub, but GitHub doesn't set the correct content type, | ||
// so we fix it here | ||
removeFirst(responseHeaders, h => h.name.toLowerCase() === "content-type"); | ||
responseHeaders.push({ | ||
name: "Content-Type", | ||
value: "text/css" | ||
}); | ||
} | ||
return { responseHeaders }; | ||
}, | ||
{ urls: ["https://raw.githubusercontent.com/*", "*://*.discord.com/*"], types: ["main_frame", "stylesheet"] }, | ||
["blocking", "responseHeaders"] | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters