Skip to content

Instantly share code, notes, and snippets.

@MadameMinty
Forked from realies/compact-messenger.user.js
Last active May 20, 2020 20:22
Show Gist options
  • Save MadameMinty/1fb516fcdc54d512a2c89b1b98751322 to your computer and use it in GitHub Desktop.
Save MadameMinty/1fb516fcdc54d512a2c89b1b98751322 to your computer and use it in GitHub Desktop.
Making the Messenger sidebar narrow. Adapted the original script to handle dynamic CSS names, and better work with vertical screens. This will compact the sidebar when you keep Messenger window on a vertical HD screen (1080px) or snap its window to a side of a HD (960px) or ultrawide (1280px width available) screen, but will expand it on e.g. HD…
// ==UserScript==
// @name Compact Messenger Sidebar
// @version 2
// @match https://www.messenger.com/*
// @grant GM_xmlhttpRequest
// @grant GM_addStyle
// ==/UserScript==
const targetCSS = document.getElementsByTagName("head")[0].querySelectorAll("link[href*='.css']")[2];
GM_xmlhttpRequest({
method: "GET",
url: targetCSS.href,
onload: response => {
targetCSS.parentNode.removeChild(targetCSS);
GM_addStyle(response.responseText.replace(/max-width: 900px/g, "max-width: 1280px"));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment