Wikipedia Simplifier

Simplifies the layout of Wikipedia articles for easier reading with additional customization options

  1. // ==UserScript==
  2. // @name Wikipedia Simplifier
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Simplifies the layout of Wikipedia articles for easier reading with additional customization options
  6. // @author Kiwv
  7. // @match https://en.wikipedia.org/*
  8. // @license MIT
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Configuration options
  15. const config = {
  16. removeSidebar: true, // Whether to remove the sidebar
  17. removeTableOfContents: true, // Whether to remove the table of contents
  18. removeFooter: true, // Whether to remove the footer
  19. adjustFontSize: true, // Whether to adjust font size for readability
  20. fontSize: '16px', // Font size for paragraphs
  21. lineHeight: '1.5' // Line height for paragraphs
  22. };
  23.  
  24. // Remove clutter elements
  25. function removeElements() {
  26. if (config.removeSidebar) {
  27. const sidebar = document.getElementById('mw-navigation');
  28. if (sidebar) {
  29. sidebar.remove();
  30. }
  31. }
  32.  
  33. if (config.removeTableOfContents) {
  34. const toc = document.getElementById('toc');
  35. if (toc) {
  36. toc.remove();
  37. }
  38. }
  39.  
  40. if (config.removeFooter) {
  41. const footer = document.getElementById('footer');
  42. if (footer) {
  43. footer.remove();
  44. }
  45. }
  46. }
  47.  
  48. // Simplify layout and formatting
  49. function simplifyLayout() {
  50. const content = document.getElementById('content');
  51. if (content) {
  52. content.style.width = '100%';
  53. }
  54.  
  55. const bodyContent = document.getElementById('bodyContent');
  56. if (bodyContent) {
  57. bodyContent.style.margin = '0';
  58. bodyContent.style.padding = '0';
  59. }
  60.  
  61. if (config.adjustFontSize) {
  62. const paragraphs = document.querySelectorAll('#bodyContent p');
  63. for (let i = 0; i < paragraphs.length; i++) {
  64. paragraphs[i].style.fontSize = config.fontSize;
  65. paragraphs[i].style.lineHeight = config.lineHeight;
  66. }
  67. }
  68. }
  69.  
  70. // Main function to simplify the Wikipedia article
  71. function simplifyWikipedia() {
  72. removeElements();
  73. simplifyLayout();
  74. }
  75.  
  76. // Run the simplification process when the page has finished loading
  77. window.addEventListener('load', simplifyWikipedia);
  78. })();