Skip to content

Commit

Permalink
temporary fix for chrome v130 CSP
Browse files Browse the repository at this point in the history
  • Loading branch information
Herobread committed Oct 16, 2024
1 parent 9c7a484 commit 33396cc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "better-studres",
"version": "2.9.2.2",
"version": "2.9.2.3",
"description": "Improves appearance of the St Andrews student resources platform, featuring a completely redesigned UI and UX.",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/Herobread/better-studres-v2"
},
"scripts": {
"build": "vite build",
"build": "vite build && bun vite/fixes/postBuildFixes.ts",
"build:firefox": "cross-env BROWSER=firefox vite build",
"dev": "nodemon",
"dev:firefox": "cross-env BROWSER=firefox nodemon",
Expand Down
19 changes: 19 additions & 0 deletions vite/fixes/postBuildFixes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import fs from "fs"
// Temp fix for CSP on Chrome 130
// Manually remove them because there is no option to disable use_dynamic_url on @crxjs/vite-plugin
// https://github.com/pnd280/complexity/commit/ce9242a0538e86b88ee455b2dea55598f6c779db
function forceDisableUseDynamicUrl() {
const manifestPath = "dist/manifest.json"
const manifestContents = JSON.parse(fs.readFileSync(manifestPath, "utf8"))
manifestContents.web_accessible_resources.forEach((resource: any) => {
delete resource.use_dynamic_url
})
if (!fs.existsSync(manifestPath)) {
return
}
fs.writeFileSync(manifestPath, JSON.stringify(manifestContents, null, 2))
}
forceDisableUseDynamicUrl()
console.log(
"Updated content.ts-loader and manifest for Content-Security-Policy fix."
)

0 comments on commit 33396cc

Please sign in to comment.