Greasy Fork is available in English.
四击页面任意位置即可关闭页面
当前为
// ==UserScript==
// @name 四击关闭页面
// @namespace http://tampermonkey.net/
// @version 1.0.2
// @description 四击页面任意位置即可关闭页面
// @author 捈荼
// @license MIT
// @match *://*/*
// @require http://greasyfork.icu/scripts/453846-string-format/code/string%20format.js
// @run-at document-start
// @grant unsafeWindow
// @grant window.close
// ==/UserScript==
"use strict";
function nclickEvent(n, interval, dom, fn) {
dom.removeEventListener('dblclick', null);
n = parseInt(n) < 1 ? 1 : parseInt(n);
var count = 0, lastTime = 0;
var handler = (event) => {
var currentTime = new Date().getTime();
count = (currentTime - lastTime) < interval ? count + 1 : 0;
console.log('click event: last since {} ms;\nconsecutive {} times.\n'.format(currentTime - lastTime, count + 1));
lastTime = new Date().getTime();
if (count >= n - 1) {
fn(event, n);
count = 0;
}
};
dom.addEventListener('click', handler);
}
(function () {
nclickEvent(4, 250, document, (_event, n) => {
console.log(n + 'click');
window.opener = null;
window.open('', '_self');
setTimeout(() => window.close(), 1);
});
})();