Created
June 26, 2017 17:08
-
-
Save AlbinoDrought/ddc1f29ef6509971b316e4851c15aebf to your computer and use it in GitHub Desktop.
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
// ==UserScript== | |
// @name Automatic Tab Closer | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description No more tab hogging ;) | |
// @author AlbinoDrought | |
// @match *://www.w3schools.com/* | |
// @match *://php.net/* | |
// @match *://www.google.ca/* | |
// @grant window.close | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var timeoutReference = false; | |
var delay = 10000; | |
function onTimeout() { | |
window.close(); | |
} | |
function resetTimer() { | |
if (timeoutReference !== false) { | |
clearTimeout(timeoutReference); | |
} | |
timeoutReference = setTimeout(onTimeout, delay); | |
} | |
document.addEventListener("load", resetTimer); | |
document.addEventListener("mousemove", resetTimer); | |
document.addEventListener("keypress", resetTimer); | |
document.addEventListener("click", resetTimer); | |
document.addEventListener("scroll", resetTimer); | |
resetTimer(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment