RegExr: toggle sidebar

Allows you to toggle sidebar on RegExr.com

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         RegExr: toggle sidebar
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Allows you to toggle sidebar on RegExr.com
// @author       Himalay
// @match        http://regexr.com/
// @grant        none
// ==/UserScript==

(function () {
  'use strict';

  document.head.appendChild(Object.assign(document.createElement('style'), {
    innerText: `#menuToggle {
                    font-weight: 900;
                    color: #101113;
                    margin-right: 10px;
                  }

                  .sidemenu {
                    position:absolute;
                    float: none;
                    left: -352px;
                  }

                  .mainarea {
                    float: none;
                    width: 100%;
                  }`
  }));

  toggleSidemenu();

  document.querySelector('#docview  .title').prepend(Object.assign(document.createElement('a'), {
    id: 'menuToggle',
    innerText: '☰'
  }));

  document.querySelector('#menuToggle').addEventListener('click', toggleSidemenu);

  function toggleSidemenu() {
    document.querySelector('#libview').classList.toggle('sidemenu');
    document.querySelector('#docview').classList.toggle('mainarea');
  }
})();