Last active
January 18, 2018 16:52
-
-
Save 8ctopotamus/97927bcce2dcf46b6156b586e2333011 to your computer and use it in GitHub Desktop.
Quick-escape functionality
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
(function() { | |
// the ESC button on the page | |
var quickESCButton = document.getElementById('quick-esc') | |
function getAway() { | |
// open new tab with innocent site | |
window.open("http://weather.com", "_newtab") | |
// replace current site with another benign site | |
window.location.replace('http://google.com') | |
} | |
// automatically leave site if page left idle for a long time | |
function idleLeaveSiteTimer() { | |
var t | |
window.onload = resetTimer | |
window.onmousemove = resetTimer | |
window.onmousedown = resetTimer // catches touchscreen presses | |
window.onclick = resetTimer // catches touchpad clicks | |
window.onscroll = resetTimer // catches scrolling with arrow keys | |
window.onkeypress = resetTimer | |
function resetTimer() { | |
clearTimeout(t) | |
t = setTimeout(getAway, 300000) // time is in milliseconds (5 min) | |
} | |
} | |
// keyboard ESC | |
document.addEventListener('keyup', function(e) { | |
if (e.keyCode == 27) { // esc key | |
getAway() | |
} | |
}) | |
quickESCButton.addEventListener('click', function(e) { | |
getAway() | |
}) | |
idleLeaveSiteTimer() | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The back button was still working in chrome and edge. Check these out if you absolutely need to disable the back button:
The solution of adding
window.history.forward(1);
to my script worked for me! It just redirects you to a new blank tab.