Greasy Fork

Greasy Fork is available in English.

Niconico URL 重定向

自动将类似 acg.tv/sm* 的 URL 转换为 nicovideo.jp/watch/sm* (包括 URL 参数)

当前为 2024-03-07 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name              Niconico URL 重定向
// @name:en           Niconico URL redirector
// @name:zh-TW        Niconico 網址重新導向
// @namespace         http://tampermonkey.net/
// @version           0.1
// @description       自动将类似 acg.tv/sm* 的 URL 转换为 nicovideo.jp/watch/sm* (包括 URL 参数)
// @description:en    Redirect URLs like acg.tv/sm* to nicovideo.jp/watch/sm* (including url arguments)
// @description:zh-TW 自動將類似 acg.tv/sm* 的網址轉換為 nicovideo.jp/watch/sm* (包含網址參數)
// @author            はなちゃん with help by Bing Copilot
// @match             *://*/*
// @grant             none
// @license           MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to redirect URLs
    function redirectUrls() {
        // Redirect current window URL
        if (window.location.href.includes("acg.tv/sm")) {
            window.location.href = window.location.href.replace("acg.tv/sm", "nicovideo.jp/watch/sm");
        }

        // Redirect URLs in href of a tags
        document.querySelectorAll('a').forEach(a => {
            if (a.href.includes("acg.tv/sm")) {
                a.href = a.href.replace("acg.tv/sm", "nicovideo.jp/watch/sm");
            }
        });
    }

    // Call the function initially
    redirectUrls();

    // Call the function 1s later, for later-render page.
    setInterval(() => { redirectUrls(); }, 1000);
})();