hub_navigator

Website Navigator With Arrow Key Press

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

作者
krishnachaitanya9
日安装量
0
总安装量
41
评分
1 0 0
版本
1.0
创建于
2016-07-13
更新于
2024-09-29
大小
1.4 KB
许可证
暂无
适用于

// ==UserScript== // @name hub_navigator // @namespace http://your.homepage/ // @version 1.0 // @description Website Navigator With Arrow Key Press // @match https://./* // ==/UserScript== function updatePageNumber(increment) { const url = window.location.href;

// Use regex to find the last numeric sequence in the URL
const regex = /(\d+)(?!.*\d)/;
const match = url.match(regex);

if (match) {
    // Extract the matched number
    let number = parseInt(match[0]);

    // Adjust the number based on the increment (positive for next, negative for previous)
    number += increment;

    // Replace the old number in the URL with the updated number
    const updatedUrl = url.replace(regex, number.toString());

    // Log the updated URL to the console
    console.log('Updated URL:', updatedUrl);

    // Navigate to the updated URL
    window.open(updatedUrl, "_self");
} else {
    console.log("No number found in the URL to increment/decrement.");
}

}

function checkKeyPressed(e) { // Right arrow key for increment if (e.keyCode === 39) { updatePageNumber(1); // Increment page number } // Left arrow key for decrement if (e.keyCode === 37) { updatePageNumber(-1); // Decrement page number } }

// Listen for keydown events window.addEventListener("keydown", checkKeyPressed, false);