您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
一个简单的鼠标手势脚本
当前为
- // ==UserScript==
- // @name My Mouse Gestures
- // @name:zh-CN 我的鼠标手势
- // @name:zh-TW 我的滑鼠手勢
- // @description A simple mouse gesture script
- // @description:zh-CN 一个简单的鼠标手势脚本
- // @description:zh-TW 一個簡單的滑鼠手勢腳本
- // @version 0.2.0
- // @match *://*/*
- // @run-at document-start
- // @grant GM_openInTab
- // @grant window.close
- // @grant GM_setValue
- // @grant GM_getValue
- // @namespace https://gf.qytechs.cn/users/4968
- // ==/UserScript==
- // --- Settings ---
- const SENSITIVITY = 3; // 1 ~ 5
- const TOLERANCE = 3; // 1 ~ 5
- const funcs = {
- 'DR': function() {
- window.top.close();
- },
- 'RL': function() {
- let closedTabs = GM_getValue("closedTabs", []);
- if(closedTabs.length > 0) {
- let lastclosedTab = closedTabs.pop();
- GM_setValue("closedTabs", closedTabs)
- GM_openInTab(lastclosedTab, false);
- }
- },
- 'U': function() {
- window.scrollTo(0, 0);
- },
- 'D': function() {
- window.scrollTo(0, 1073741824);
- },
- 'L': function() {
- window.history.back();
- },
- 'R': function() {
- window.history.forward();
- },
- 'RU': function() {
- GM_openInTab('about:newtab', false);
- if (navigator.userAgent.indexOf('Firefox') !== -1) {
- GM_openInTab('about:blank', false);
- }
- },
- 'UD': function() {
- window.location.reload();
- }
- };
- // ----------------
- const s = 1 << ((7 - SENSITIVITY) << 1);
- const t1 = Math.tan(0.15708 * TOLERANCE),
- t2 = 1 / t1;
- let x, y, path;
- const tracer = function(e) {
- let cx = e.clientX,
- cy = e.clientY,
- deltaX = cx - x,
- deltaY = cy - y,
- distance = deltaX * deltaX + deltaY * deltaY;
- if (distance > s) {
- let slope = Math.abs(deltaY / deltaX),
- direction = '';
- if (slope > t1) {
- direction = deltaY > 0 ? 'D' : 'U';
- } else if (slope <= t2) {
- direction = deltaX > 0 ? 'R' : 'L';
- }
- if (path.charAt(path.length - 1) !== direction) {
- path += direction;
- }
- x = cx;
- y = cy;
- }
- };
- window.addEventListener('mousedown', function(e) {
- if (e.which === 3) {
- x = e.clientX;
- y = e.clientY;
- path = "";
- window.addEventListener('mousemove', tracer, false);
- }
- }, false);
- window.addEventListener('contextmenu', function(e) {
- window.removeEventListener('mousemove', tracer, false);
- if (path !== "") {
- e.preventDefault();
- if (funcs.hasOwnProperty(path)) {
- funcs[path]();
- }
- }
- }, false);
- window.addEventListener("beforeunload", (e) => {
- let closedTabs = GM_getValue("closedTabs", []);
- closedTabs.push(window.location.href);
- GM_setValue("closedTabs", closedTabs)
- });
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址