javascript:(function(){ /* Global variables. */ const gmailResizeSideBarStyle = ` div.wT { min-width: unset; max-width: unset; }`; /********************************************************************************************* MAIN FUNCTION *********************************************************************************************/ function gmailResizeSideBar() { if (location.href.toLowerCase().indexOf("mail.google.com") > -1) { const target = document.querySelector('.aeN.WR.baA.nH.oy8Mbf'); /* side bar */ if (!target) return console.log("Error: Target element not found."); /* error */ if (document.getElementById('gmail-resizer-handle')) /* no duplicates */ return console.log("Resizer already exists."); /* 1. reset outer sidebar constraints */ target.style.minWidth = '100px'; target.style.maxWidth = '80vw'; target.style.position = 'relative'; target.style.flexBasis = 'auto'; target.style.width = /* close enough but enough to indicate bm ready for use */ target.offsetWidth + 75 + 'px'; /* 2. create the invisible drag handle */ const handle = document.createElement('div'); handle.id = 'gmail-resizer-handle'; Object.assign(handle.style, { position: 'absolute', right: '-4px', top: '0', width: '8px', height: '100%', cursor: 'col-resize', zIndex: '9999', backgroundColor: 'transparent' }); /* add event for resize */ handle.onmouseenter = () => handle.style.backgroundColor = 'rgba(0,0,0,0.1)'; handle.onmouseleave = () => handle.style.backgroundColor = 'transparent'; /* add element to target */ target.appendChild(handle); /* drag Logic */ let isResizing = false; /* switch */ let startX, startWidth; /* ready resize */ handle.addEventListener('mousedown', (e) => { isResizing = true; startX = e.clientX; startWidth = target.offsetWidth; document.body.style.cursor = 'col-resize'; document.body.style.userSelect = 'none'; }); /* resizing */ window.addEventListener('mousemove', (e) => { if (!isResizing) return; const newWidth = startWidth + (e.clientX - startX); target.style.width = newWidth + 'px'; window.dispatchEvent(new Event('resize')); }); /* done resizing */ window.addEventListener('mouseup', () => { isResizing = false; document.body.style.cursor = 'default'; document.body.style.userSelect = 'auto'; }); /* ready for use logged */ console.log("Custom Gmail Sidebar Resizer Active!"); /* apply min-width and max-width to nested elements */ let style = document.createElement("style"); /* new style tag */ style.innerText = gmailResizeSideBarStyle; /* global var */ document.body.insertAdjacentElement("afterbegin", style); /* add */ } else { /* address is not gmail */ console.log("Error: gmail not detected"); } } gmailResizeSideBar(); })();