Skip to content

Commit

Permalink
Add requestStorageAccess routine to support iframe cookies in Safari
Browse files Browse the repository at this point in the history
  • Loading branch information
zoldar committed Jul 23, 2024
1 parent 99c8a01 commit e7422f9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions extra/lib/plausible_web/views/help_scout_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,21 @@ defmodule PlausibleWeb.HelpScoutView do
const appContainer = document.getElementById("content")
window.addEventListener('load', async () => {
const hasStorageAccess = await document.hasStorageAccess()
if (!hasStorageAccess) {
const button = document.createElement('button')
button.innerHTML = 'Grant cookie access'
button.onclick = async (e) => {
await document.requestStorageAccess()
e.target.remove()
}
const paragraph = document.createElement('p')
paragraph.append(button)
appContainer.prepend(paragraph)
}
})
async function loadContent(uri) {
const response = await fetch(uri)
const html = await response.text()
Expand Down

0 comments on commit e7422f9

Please sign in to comment.