您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Increment an integer value in the URL with keyboard shortcuts to go next page or previous page
当前为
- // ==UserScript==
- // @name URL Page Navigator
- // @version 1.5
- // @description Increment an integer value in the URL with keyboard shortcuts to go next page or previous page
- // @grant none
- // @match *://*/*
- // @license MIT
- // @namespace https://greasyfork.org/users/875241
- // ==/UserScript==
- (function() {
- 'use strict';
- function incrementIntegerValue(url) {
- let regex = /(\d+)(?=.*\d)/;
- let match = url.match(regex);
- if (match) {
- let number = parseInt(match[0], 10);
- let incrementedNumber = number + 1;
- if(number >= 1000 && number <= 9999){
- let secondLastMatch = url.match(/(\d+)(?=.*\d)/g)[1];
- let secondLastNumber = parseInt(secondLastMatch, 10);
- return url.replace(new RegExp(secondLastMatch, 'g'), secondLastNumber + 1);
- } else {
- return url.replace(regex, incrementedNumber);
- }
- }
- return url;
- }
- function handleShortcut(event) {
- if (event.altKey && event.key === 'k') {
- event.preventDefault();
- const currentUrl = window.location.href;
- const incrementedUrl = incrementIntegerValue(currentUrl);
- if (incrementedUrl !== currentUrl) {
- window.location.href = incrementedUrl;
- }
- }
- }
- document.addEventListener('keydown', handleShortcut);
- })();