Toggle WhatsApp Sidebar Width

Changes Whatsapp Web, contact size so it can be toggled on or off.

  1. // ==UserScript==
  2. // @license Public
  3. // @name Toggle WhatsApp Sidebar Width
  4. // @namespace http://tampermonkey.net/
  5. // @version 1.3
  6. // @description Changes Whatsapp Web, contact size so it can be toggled on or off.
  7. // @author Atos
  8. // @match *://web.whatsapp.com/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Función para añadir el botón de toggle
  16. function addToggleButton() {
  17. // Crear el botón
  18. var toggleButton = document.createElement('button');
  19. toggleButton.style.position = 'fixed';
  20. toggleButton.style.top = '10px';
  21. toggleButton.style.left = '10px';
  22. toggleButton.style.zIndex = '9999';
  23. toggleButton.style.width = '40px';
  24. toggleButton.style.height = '40px';
  25. toggleButton.style.borderRadius = '50%';
  26. toggleButton.style.backgroundColor = '#25D366'; // Color de WhatsApp
  27. toggleButton.style.border = 'none';
  28. toggleButton.style.cursor = 'pointer';
  29. toggleButton.style.display = 'flex';
  30. toggleButton.style.alignItems = 'center';
  31. toggleButton.style.justifyContent = 'center';
  32.  
  33. // Crear el contenedor de las líneas
  34. var lineContainer = document.createElement('div');
  35. lineContainer.style.width = '20px';
  36. lineContainer.style.height = '20px';
  37. lineContainer.style.display = 'flex';
  38. lineContainer.style.flexDirection = 'column';
  39. lineContainer.style.justifyContent = 'space-around';
  40.  
  41. // Crear las líneas
  42. for (var i = 0; i < 3; i++) {
  43. var line = document.createElement('div');
  44. line.style.width = '100%';
  45. line.style.height = '2px';
  46. line.style.backgroundColor = 'white';
  47. lineContainer.appendChild(line);
  48. }
  49.  
  50. // Añadir el contenedor de líneas al botón
  51. toggleButton.appendChild(lineContainer);
  52.  
  53. // Añadir el botón al body
  54. document.body.appendChild(toggleButton);
  55.  
  56. // Establecer el estado inicial del botón
  57. toggleButton.setAttribute('data-state', 'open');
  58.  
  59. // Añadir evento de click para cambiar el CSS
  60. toggleButton.addEventListener('click', function() {
  61. var style = document.createElement('style');
  62. style.type = 'text/css';
  63.  
  64. if (toggleButton.getAttribute('data-state') === 'open') {
  65. style.innerHTML = `
  66. @media screen {
  67. .two ._aigw {
  68. flex: 0 0 10% !important;
  69. max-width: 10% !important;
  70. }
  71. }
  72. `;
  73. toggleButton.setAttribute('data-state', 'closed');
  74. } else {
  75. style.innerHTML = `
  76. @media screen {
  77. .two ._aigw {
  78. flex: 0 0 40% !important;
  79. max-width: 40% !important;
  80. }
  81. }
  82. `;
  83. toggleButton.setAttribute('data-state', 'open');
  84. }
  85.  
  86. // Añadir el estilo al head del documento
  87. document.head.appendChild(style);
  88. });
  89. }
  90.  
  91. // Esperar a que la página se cargue completamente
  92. window.addEventListener('load', function() {
  93. // Intenta añadir el botón cada segundo hasta que se encuentre el elemento
  94. var interval = setInterval(function() {
  95. addToggleButton();
  96. clearInterval(interval);
  97. }, 1000);
  98.  
  99. // Detiene el intervalo después de 10 segundos
  100. setTimeout(function() {
  101. clearInterval(interval);
  102. }, 10000);
  103. });
  104. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址