Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ==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