您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Use the arrow keys to navigate the next or previous pages of tutorials ;)
当前为
- // ==UserScript==
- // @name Next/Previous navigation with arrow keys!
- // @namespace Violentmonkey Scripts
- // @match https://www.w3schools.com/.*/*
- // @grant none
- // @version 1.0
- // @author AvinashReddy3108 (assisted by ChatGPT)
- // @license WTFPL
- // @description Use the arrow keys to navigate the next or previous pages of tutorials ;)
- // ==/UserScript==
- (function() {
- 'use strict';
- document.addEventListener('keydown', function(event) {
- if (event.target.tagName.toLowerCase() === 'input' || event.target.tagName.toLowerCase() === 'textarea') {
- return; // Ignore inputs and textareas
- }
- // Container which has the next/previous buttons
- let container = document.querySelector("div.w3-clear.nextprev");
- if (!container) return;
- // The Next/Previous buttons
- let prevButton = container.querySelector("a.w3-left.w3-btn");
- let nextButton = container.querySelector("a.w3-right.w3-btn");
- if (event.key === 'ArrowLeft' && prevButton) {
- window.location.href = prevButton.href;
- } else if (event.key === 'ArrowRight' && nextButton) {
- window.location.href = nextButton.href;
- }
- });
- })();