Greasy Fork is available in English.

Add Trailing Slash to Narou URL

なろうの小説トップページのURLが「/n0001a」「/n0001a/?p=1」のとき「/n0001a/」へリダイレクトする。

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Add Trailing Slash to Narou URL
// @namespace    haaarug
// @version      1.2
// @description  なろうの小説トップページのURLが「/n0001a」「/n0001a/?p=1」のとき「/n0001a/」へリダイレクトする。
// @license      CC0
// @match        https://ncode.syosetu.com/*
// @run-at       document-start
// ==/UserScript==

(function () {
    'use strict';

    const url = new URL(window.location.href);

    // クエリが ?p=1 のとき → クエリ削除してそのままリダイレクト(スラッシュは追加しない)
    if (url.search === '?p=1') {
        url.search = '';
        window.location.replace(url.toString());
        return;
    }

    // クエリがない & pathname がスラッシュで終わっていないとき → スラッシュ追加
    if (!url.search && !url.pathname.endsWith('/')) {
        url.pathname += '/';
        window.location.replace(url.toString());
    }

    // それ以外(クエリがある or スラッシュ付き)は何もしない
})();