|
| 1 | +async function isBraveBrowser() { |
| 2 | + if (navigator.brave && (await navigator.brave.isBrave())) { |
| 3 | + return true; |
| 4 | + } |
| 5 | + return false; |
| 6 | +} |
| 7 | + |
| 8 | +document.addEventListener("DOMContentLoaded", async function () { |
| 9 | + if (await isBraveBrowser()) { |
| 10 | + const troubleshootElement = document.createElement("a"); |
| 11 | + troubleshootElement.href = "#"; |
| 12 | + troubleshootElement.className = "social-icon"; |
| 13 | + troubleshootElement.dataset.tooltip = "Troubleshoot"; |
| 14 | + |
| 15 | + const img = document.createElement("img"); |
| 16 | + img.src = "/images/troubleshoot.png"; |
| 17 | + img.style.width = "30px"; |
| 18 | + img.style.height = "30px"; |
| 19 | + img.style.marginTop = "10px"; |
| 20 | + img.alt = "Troubleshoot"; |
| 21 | + |
| 22 | + troubleshootElement.appendChild(img); |
| 23 | + |
| 24 | + troubleshootElement.addEventListener("click", function(event) { |
| 25 | + event.preventDefault(); |
| 26 | + const popup = document.createElement("div"); |
| 27 | + popup.className = "troubleshoot-popup"; |
| 28 | + popup.style.position = "fixed"; |
| 29 | + popup.style.top = "20%"; |
| 30 | + popup.style.left = "50%"; |
| 31 | + popup.style.transform = "translate(-50%, 0)"; |
| 32 | + popup.style.background = "black"; |
| 33 | + popup.style.padding = "20px"; |
| 34 | + popup.style.boxShadow = "0 0 10px rgba(0,0,0,0.5)"; |
| 35 | + popup.style.zIndex = "1000"; |
| 36 | + popup.style.borderRadius = "10px"; |
| 37 | + |
| 38 | + const text = document.createElement("p"); |
| 39 | + text.textContent = "Looks like you are using the brave browser. If you experience any issues please try turning off brave shields"; |
| 40 | + |
| 41 | + const gif = document.createElement("img"); |
| 42 | + gif.src = "/images/troubleshoot/brave.gif"; |
| 43 | + gif.style.width = "100%"; |
| 44 | + gif.style.marginTop = "10px"; |
| 45 | + |
| 46 | + const closeButton = document.createElement("button"); |
| 47 | + closeButton.className = "troubleshoot-close-button"; |
| 48 | + closeButton.textContent = "Close"; |
| 49 | + closeButton.style.marginTop = "10px"; |
| 50 | + closeButton.addEventListener("click", function() { |
| 51 | + document.body.removeChild(popup); |
| 52 | + }); |
| 53 | + |
| 54 | + popup.appendChild(text); |
| 55 | + popup.appendChild(gif); |
| 56 | + popup.appendChild(closeButton); |
| 57 | + document.body.appendChild(popup); |
| 58 | + }); |
| 59 | + |
| 60 | + document.querySelector("footer").appendChild(troubleshootElement); |
| 61 | + } |
| 62 | +}); |
0 commit comments