From 1d8e086cc30c57a056edf13f116e389af654bce4 Mon Sep 17 00:00:00 2001 From: James Shiffer Date: Mon, 24 Jul 2023 21:05:18 -0700 Subject: [PATCH] Only refresh if still possible to circumvent pop-up blocker --- public/js/perms.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/js/perms.js b/public/js/perms.js index b071e66..393e0c3 100644 --- a/public/js/perms.js +++ b/public/js/perms.js @@ -1,13 +1,18 @@ +var askedOnce = false; function ask() { navigator.mediaDevices.getUserMedia({audio:true, video:true}) .catch(function (e) { if (e.message === 'Permission denied') { + if (!askedOnce) + return; if (location.host.indexOf("www") !== 0) location.host = "www2." + location.host; else if (location.host.indexOf("www.") !== 0) location.host = "www" + (Number(location.host[3]) + 1) + "." + location.host.slice(5); else location.host = "www." + location.host; + } else if (e.message === 'Permission dismissed') { + askedOnce = true; } }); }