Refactor html file to call divee.ai APIs, as well as to load external images
This skill patches a saved HTML file (SingleFile format) to embed the divee widget. It patches the HTML file's CSP to allow divee domains 5. Appends the divee SDK script with the generated project ID
An html file.
$file = "C:\Users\moshe\Documents\Development\divee.ai\web\public\SITENAME.html"
$html = [System.IO.File]::ReadAllText($file)
$old = "default-src 'none'; font-src 'self' data:; img-src 'self' data:; style-src 'unsafe-inline'; media-src 'self' data:; script-src 'unsafe-inline' data:; object-src 'self' data:; frame-src 'self' data:;"
$new = "default-src 'none'; font-src 'self' data:; img-src * data: blob:; style-src 'unsafe-inline'; media-src 'self' data:; script-src 'unsafe-inline' data: https://srv.divee.ai https://cdn.divee.ai; object-src 'self' data:; frame-src 'self' data:; connect-src https://srv.divee.ai https://cdn.divee.ai;"
$html2 = $html.Replace($old, $new)
if ($html2 -eq $html) { Write-Host "ERROR: no replacement - CSP pattern not found" } else { [System.IO.File]::WriteAllText($file, $html2, [System.Text.Encoding]::UTF8); Write-Host "OK: CSP updated" }
$script = "`n<script src=`"https://srv.divee.ai/storage/v1/object/public/sdk/divee.sdk.latest.js`" data-project-id=`"PROJECT_ID`"></script>"
[System.IO.File]::AppendAllText($file, $script, [System.Text.Encoding]::UTF8)
Write-Host "OK: script appended"
Write-Host "`nPreview URL: https://divee.ai/SITENAME.html"
After running, present the final preview URL to the user so they can copy it: