您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Provide a button to switch to Simple Wikipedia and back to Normal Wikipedia
当前为
- // ==UserScript==
- // @name Wikipedia Simple Redirect with Button
- // @namespace http://tampermonkey.net/
- // @version 0.2
- // @description Provide a button to switch to Simple Wikipedia and back to Normal Wikipedia
- // @author Drewby123
- // @match https://en.wikipedia.org/*
- // @match https://simple.wikipedia.org/*
- // @grant GM_addStyle
- // @license MIT
- // ==/UserScript==
- (function() {
- 'use strict';
- // Create a button to toggle between Simple and Normal Wikipedia
- const button = document.createElement('button');
- button.textContent = 'Switch to Simple Wikipedia';
- button.style.position = 'fixed';
- button.style.bottom = '20px';
- button.style.right = '20px';
- button.style.backgroundColor = '#007bff';
- button.style.color = '#fff';
- button.style.border = 'none';
- button.style.padding = '10px 15px';
- button.style.borderRadius = '5px';
- button.style.cursor = 'pointer';
- button.style.zIndex = '1000';
- // Add button to the page
- document.body.appendChild(button);
- // Function to toggle between Simple and Normal Wikipedia
- button.addEventListener('click', () => {
- const currentUrl = window.location.href;
- if (currentUrl.includes('https://en.wikipedia.org/wiki/')) {
- // Redirect to Simple Wikipedia
- const newUrl = currentUrl.replace('en.wikipedia.org', 'simple.wikipedia.org');
- window.location.href = newUrl;
- button.textContent = 'Switch to Normal Wikipedia'; // Change button text
- } else if (currentUrl.includes('https://simple.wikipedia.org/wiki/')) {
- // Redirect to Normal Wikipedia
- const newUrl = currentUrl.replace('simple.wikipedia.org', 'en.wikipedia.org');
- window.location.href = newUrl;
- button.textContent = 'Switch to Simple Wikipedia'; // Change button text
- }
- });
- })();