From e61edc387c1edeca1745c96d163a397b5bf1abdf Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 1 Jun 2022 17:29:41 -0400 Subject: More Safari support (#2171) * Add support for not building a zip * Update gitignore * Add safari variant --- .gitignore | 1 + dev/build.js | 29 ++++++++++++++++------------- dev/data/manifest-variants.json | 20 ++++++++++++++++++++ 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 2bb2540a..cb899753 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules builds +.DS_Store diff --git a/dev/build.js b/dev/build.js index e9c204c5..496e5865 100644 --- a/dev/build.js +++ b/dev/build.js @@ -141,22 +141,25 @@ async function build(buildDir, extDir, manifestUtil, variantNames, manifestPath, const modifiedManifest = manifestUtil.getManifest(variant.name); - const fileNameSafe = path.basename(fileName); - const fullFileName = path.join(buildDir, fileNameSafe); ensureFilesExist(extDir, excludeFiles); - if (!dryRun) { - fs.writeFileSync(manifestPath, ManifestUtil.createManifestString(modifiedManifest)); - } - if (!dryRun || dryRunBuildZip) { - await createZip(extDir, excludeFiles, fullFileName, sevenZipExes, onUpdate, dryRun); - } + if (typeof fileName === 'string') { + const fileNameSafe = path.basename(fileName); + const fullFileName = path.join(buildDir, fileNameSafe); + if (!dryRun) { + fs.writeFileSync(manifestPath, ManifestUtil.createManifestString(modifiedManifest)); + } - if (!dryRun) { - if (Array.isArray(fileCopies)) { - for (const fileName2 of fileCopies) { - const fileName2Safe = path.basename(fileName2); - fs.copyFileSync(fullFileName, path.join(buildDir, fileName2Safe)); + if (!dryRun || dryRunBuildZip) { + await createZip(extDir, excludeFiles, fullFileName, sevenZipExes, onUpdate, dryRun); + } + + if (!dryRun) { + if (Array.isArray(fileCopies)) { + for (const fileName2 of fileCopies) { + const fileName2Safe = path.basename(fileName2); + fs.copyFileSync(fullFileName, path.join(buildDir, fileName2Safe)); + } } } } diff --git a/dev/data/manifest-variants.json b/dev/data/manifest-variants.json index 96b6d877..e9672cc0 100644 --- a/dev/data/manifest-variants.json +++ b/dev/data/manifest-variants.json @@ -306,6 +306,26 @@ "js/dom/simple-dom-parser.js", "lib/parse5.js" ] + }, + { + "name": "safari", + "fileName": null, + "modifications": [ + {"action": "remove", "path": ["optional_permissions"], "item": "clipboardRead"}, + {"action": "remove", "path": ["permissions"], "item": "webRequestBlocking"}, + {"action": "delete", "path": ["content_scripts", 0, "match_about_blank"]}, + {"action": "delete", "path": ["sandbox"]}, + { + "action": "set", + "path": ["content_security_policy"], + "value": "default-src 'self'; script-src 'self' 'unsafe-eval'; img-src blob: 'self'; style-src 'self' 'unsafe-inline'; media-src *; connect-src *" + } + ], + "excludeFiles": [ + "sw.js", + "js/dom/simple-dom-parser.js", + "lib/parse5.js" + ] } ] } -- cgit v1.2.3