Hide Mouse Idle

Auto hide mouse pointer when idle

Verze ze dne 07. 01. 2020. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        Hide Mouse Idle
// @namespace   iFantz7E.HideMouseIdle
// @version     0.1
// @description Auto hide mouse pointer when idle
// @include     *
// @grant       none
// @license     GPLv3
// @copyright   2020, 7-elephant
// ==/UserScript==

// License: GPLv3 - https://www.gnu.org/licenses/gpl-3.0.txt

// Since 8 Jan 2020

(function ()
{
	"use strict";
	// jshint multistr:true
	
function attachOnLoad(callback)
{
	window.addEventListener("load", function (e)
	{
		callback();
	});
}

function attachOnReady(callback)
{
	document.addEventListener("DOMContentLoaded", function (e)
	{
		callback();
	});
}

var isVisible = (function()
{
	var stateKey;
	var eventKey;
	var keys =
	{
		hidden: "visibilitychange",
		webkitHidden: "webkitvisibilitychange",
		mozHidden: "mozvisibilitychange",
		msHidden: "msvisibilitychange"
	};
	for (stateKey in keys)
	{
		if (stateKey in document)
		{
			eventKey = keys[stateKey];
			break;
		}
	}
	return function(c)
	{
		if (c)
		{
			document.addEventListener(eventKey, c);
		}
		return !document[stateKey];
	}
})();

function main()
{
	var timingHideCursor = 5000;    // 5 seconds
	var tmMouseMove = 0;
	
	document.body.addEventListener("mousemove", function(ev)
	{
		document.body.style.removeProperty("cursor");
		
		clearTimeout(tmMouseMove);
		
		tmMouseMove = setTimeout(function()
		{
			if (isVisible)
			{
				document.body.style.setProperty("cursor", "none");
			}
		}, timingHideCursor);
	});
}

attachOnReady(main);

})();

// End