Wikipedia Simple Redirect with Button

Provide a button to switch to Simple Wikipedia and back to Normal Wikipedia

目前为 2025-02-18 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Wikipedia Simple Redirect with Button
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Provide a button to switch to Simple Wikipedia and back to Normal Wikipedia
  6. // @author Drewby123
  7. // @match https://en.wikipedia.org/*
  8. // @match https://simple.wikipedia.org/*
  9. // @grant GM_addStyle
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Create a button to toggle between Simple and Normal Wikipedia
  17. const button = document.createElement('button');
  18. button.textContent = 'Switch to Simple Wikipedia';
  19. button.style.position = 'fixed';
  20. button.style.bottom = '20px';
  21. button.style.right = '20px';
  22. button.style.backgroundColor = '#007bff';
  23. button.style.color = '#fff';
  24. button.style.border = 'none';
  25. button.style.padding = '10px 15px';
  26. button.style.borderRadius = '5px';
  27. button.style.cursor = 'pointer';
  28. button.style.zIndex = '1000';
  29.  
  30. // Add button to the page
  31. document.body.appendChild(button);
  32.  
  33. // Function to toggle between Simple and Normal Wikipedia
  34. button.addEventListener('click', () => {
  35. const currentUrl = window.location.href;
  36. if (currentUrl.includes('https://en.wikipedia.org/wiki/')) {
  37. // Redirect to Simple Wikipedia
  38. const newUrl = currentUrl.replace('en.wikipedia.org', 'simple.wikipedia.org');
  39. window.location.href = newUrl;
  40. button.textContent = 'Switch to Normal Wikipedia'; // Change button text
  41. } else if (currentUrl.includes('https://simple.wikipedia.org/wiki/')) {
  42. // Redirect to Normal Wikipedia
  43. const newUrl = currentUrl.replace('simple.wikipedia.org', 'en.wikipedia.org');
  44. window.location.href = newUrl;
  45. button.textContent = 'Switch to Simple Wikipedia'; // Change button text
  46. }
  47. });
  48. })();