Created
September 20, 2019 07:20
-
-
Save Henxed/b5542417c1fd451b4d90c44b8dd521b7 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 Авто возврат на главную | |
// @namespace https://henxed.ru/ | |
// @version 0.1 | |
// @description Возвращает страницу на главную, если киоском никто не пользуются | |
// @author Henxed | |
// Вводим свой сайт. Звездочку оставляем. | |
// @include http://site.ru/* | |
// @grant none | |
// @require http://code.jquery.com/jquery-3.4.1.min.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var $ = window.jQuery; | |
if(location.href !== 'http://site.ru/'){ //проверка главной страницы вашего сайта | |
var idleTimer = null; // переменная заглушка | |
var idleState = false; // состояние отсутствия | |
var idleWait = 120000; // время ожидания в мс. (1/1000 секунды) | |
$(document).on('mousemove keydown scroll', function(){ | |
clearTimeout(idleTimer); // отменяем прежний временной отрезок | |
idleState = false; | |
idleTimer = setTimeout(function(){ | |
idleState = true; | |
location.href = 'http://site.ru/'; //перекидывает на главную страницу вашего сайта | |
}, idleWait); | |
}); | |
$("body").trigger("mousemove"); // сгенерируем ложное событие, для запуска скрипта | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment