Wikipedia to Wikiwand Redirect

Redirects Wikipedia pages to Wikiwand

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @license you can edit this however you want I made it with AI
// @name         Wikipedia to Wikiwand Redirect
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Redirects Wikipedia pages to Wikiwand
// @author       Your Name
// @match        *://*.wikipedia.org/wiki/*
// @match        *://*.wikipedia.org/w/*
// @exclude      *://*.wikipedia.org/wiki/Special:*
// @exclude      *://*.wikipedia.org/wiki/Help:*
// @exclude      *://*.wikipedia.org/wiki/Wikipedia:*
// @exclude      *://*.wikipedia.org/wiki/File:*
// @exclude      *://*.wikipedia.org/wiki/Template:*
// @exclude      *://*.wikipedia.org/wiki/Category:*
// @exclude      *://*.wikipedia.org/wiki/Portal:*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Get current Wikipedia URL
    const currentUrl = window.location.href;
    
    // Check if this is a Wikipedia article (not a special page)
    const isArticle = !/\/wiki\/(Special|Help|Wikipedia|File|Template|Category|Portal):/i.test(currentUrl);
    
    // Check if we're already on Wikiwand (to prevent infinite redirects)
    const isAlreadyWikiwand = window.location.href.includes('wikiwand.com');
    
    if (isArticle && !isAlreadyWikiwand) {
        // Extract the article title from the URL
        const articleTitle = window.location.pathname.split('/wiki/')[1];
        
        // Construct the Wikiwand URL
        const wikiwandUrl = `https://www.wikiwand.com/en/${articleTitle}`;
        
        // Redirect to Wikiwand
        window.location.href = wikiwandUrl;
    }
})();