WebExtension.psm1
Function Export-WebExtension { Param ( $Path = '.' ) Compress-Archive -Path "$Path\*" -DestinationPath ~\Downloads\extension.zip -Force $PathV2 = "$Path\manifest-v2.json" If (Test-Path -PathType Leaf -Path $PathV2) { $Data = Get-Content -Raw -Path "$Path\manifest.json" | ConvertFrom-Json -AsHashtable $DataV2 = Get-Content -Raw $PathV2 | ConvertFrom-Json -AsHashtable ForEach ($Key In $DataV2.Keys) { $Data[$Key] = $DataV2[$Key] } $Data.manifest_version = 2 Rename-Item -Path "$Path\manifest.json" -NewName manifest-v3.json $Data | ConvertTo-Json -Depth 10 | Set-Content -Path "$Path\manifest.json" Compress-Archive -Path "$Path\*" -DestinationPath ~\Downloads\extension-v2.zip -Force Remove-Item -Path "$Path\manifest.json" Rename-Item -Path "$Path\manifest-v3.json" -NewName manifest.json } } |