Spaces:
Sleeping
Sleeping
coyotte508
commited on
Commit
·
01903e8
1
Parent(s):
b6543fb
✨ Re-check storage access
Browse files
server.ts
CHANGED
@@ -27,30 +27,37 @@ app.use(async (ctx) => {
|
|
27 |
</form>
|
28 |
<p>Browser supports storage access API: <span id="storage-access-api"></span></p>
|
29 |
<p>Page can store cookies: <span id="page-can-store-cookies"></span></p>
|
|
|
30 |
<button id="request-storage-access" style="display: none;" type="button">Request storage access</button>
|
31 |
</body>
|
32 |
<script>
|
33 |
const storageAccess = document.getElementById("storage-access-api");
|
34 |
const pageCanStoreCookies = document.getElementById("page-can-store-cookies");
|
35 |
const requestStorageAccess = document.getElementById("request-storage-access");
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
|
|
47 |
}
|
|
|
48 |
requestStorageAccess.addEventListener("click", () => {
|
49 |
document.requestStorageAccess().then(() => {
|
50 |
pageCanStoreCookies.innerText = "Yes";
|
51 |
requestStorageAccess.style.display = "none";
|
52 |
});
|
53 |
});
|
|
|
54 |
</script>
|
55 |
</html>`;
|
56 |
}
|
|
|
27 |
</form>
|
28 |
<p>Browser supports storage access API: <span id="storage-access-api"></span></p>
|
29 |
<p>Page can store cookies: <span id="page-can-store-cookies"></span></p>
|
30 |
+
<button id="check-storage-access" type="button">Re-check storage access</button>
|
31 |
<button id="request-storage-access" style="display: none;" type="button">Request storage access</button>
|
32 |
</body>
|
33 |
<script>
|
34 |
const storageAccess = document.getElementById("storage-access-api");
|
35 |
const pageCanStoreCookies = document.getElementById("page-can-store-cookies");
|
36 |
const requestStorageAccess = document.getElementById("request-storage-access");
|
37 |
+
const checkStorageAccessBtn = document.getElementById("check-storage-access");
|
38 |
+
const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
39 |
+
function checkStorageAccess() {
|
40 |
+
if ("hasStorageAccess" in document) {
|
41 |
+
storageAccess.innerText = "Yes";
|
42 |
+
document.hasStorageAccess().then((hasAccess) => {
|
43 |
+
console.log("has access", hasAccess);
|
44 |
+
pageCanStoreCookies.innerText = hasAccess ? "Yes" : (isFirefox ? "No, on firefox" : "No");
|
45 |
+
if (!hasAccess) {
|
46 |
+
requestStorageAccess.style.display = "block";
|
47 |
+
}
|
48 |
+
});
|
49 |
+
} else {
|
50 |
+
storageAccess.innerText = "No";
|
51 |
+
}
|
52 |
}
|
53 |
+
checkStorageAccess();
|
54 |
requestStorageAccess.addEventListener("click", () => {
|
55 |
document.requestStorageAccess().then(() => {
|
56 |
pageCanStoreCookies.innerText = "Yes";
|
57 |
requestStorageAccess.style.display = "none";
|
58 |
});
|
59 |
});
|
60 |
+
checkStorageAccessBtn.addEventListener("click", checkStorageAccess);
|
61 |
</script>
|
62 |
</html>`;
|
63 |
}
|