Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// ==UserScript==// @name ResizingDragBar// @namespace https://en.wikipedia.org/wiki/User:Arthurfragoso/ResizingDragBar.js// @version 1.0// @description Add a draggable resizing bar to Wikipedia text areas.// @author Arthurfragoso// @match https://*.wikipedia.org/w/index.php?*action=*// @icon https://en.wikipedia.org/static/favicon/wikipedia.ico// @grant none// @run-at document-end// ==/UserScript==/* * Inspired by WikiEditor. * written with the help of ChatGPT * * */(asyncfunction(){'use strict';// Adds the WpExtnSideBySideEnabled CSS class to the HTML tag,// This allows for external scripts to check if it is enabled.// It also prevents two versions of the script to be run at the same time,// In case it is activated in Wikipedia and as a browser user scriptif(document.documentElement.classList.contains("WpExtnResizingDragBar")){return;}document.documentElement.classList.add("WpExtnResizingDragBar");// Function to add a draggable resizing barfunctionaddResizingBar(textArea){constdragBar=document.createElement('div');dragBar.id='ext-ResizingDragBar';dragBar.style.width='100%';dragBar.style.height='10px';dragBar.style.cursor='row-resize';dragBar.style.backgroundColor='#ccc';// Insert the drag bar below the text areatextArea.parentNode.insertBefore(dragBar,textArea.nextSibling);letisDragging=false;// Mouse eventsdragBar.addEventListener('mousedown',(e)=>{e.preventDefault();isDragging=true;document.body.style.userSelect='none';// Prevent text selection during drag});document.addEventListener('mousemove',(e)=>{if(!isDragging)return;constnewHeight=e.clientY-textArea.getBoundingClientRect().top;textArea.style.height=`${Math.max(newHeight,100)}px`;// Set a minimum height});document.addEventListener('mouseup',()=>{isDragging=false;document.body.style.userSelect='';// Restore text selection});}// Wait to check if WikiEditor is availablesetTimeout(()=>{// Only load if WikiEditor is not available, as it already has a RisizingBar.if(document.querySelector('.ext-WikiEditor-ResizingDragBar')){returnfalse;}consttextArea=document.querySelector('#wpTextbox1');// Wikipedia's editing textareaif(textArea){textArea.style.resize='none';// Disable default resizingtextArea.style.overflow='auto';addResizingBar(textArea);}},1000);})();