Created
September 27, 2023 14:36
-
-
Save manikantag/273a57e1ab011515a07c4a5dbd3677fc to your computer and use it in GitHub Desktop.
duplicate-tab-check.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const tabCheckBroadcast = new BroadcastChannel("TAB_CHECK"); | |
tabCheckBroadcast.postMessage("FIRST_TAB"); | |
tabCheckBroadcast.onmessage = (event) => { | |
if (event.data === "FIRST_TAB") { | |
tabCheckBroadcast.postMessage("FIRST_TAB_OPENED"); | |
} | |
if (event.data === `FIRST_TAB_OPENED`) { | |
alert("You are not supposed to duplicate the tab"); | |
//disableApp(); | |
} | |
}; | |
function disableApp() { | |
document.body.classList.add("disable"); | |
document.getElementById('maskApp').style.display = 'block'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment