Skip to content

Instantly share code, notes, and snippets.

@himalay
Last active January 26, 2017 04:54
Show Gist options
  • Save himalay/b365d9c89b10eef509a56b5329d061df to your computer and use it in GitHub Desktop.
Save himalay/b365d9c89b10eef509a56b5329d061df to your computer and use it in GitHub Desktop.
Userscript: Add sidebar toggle on RegExr.com
// ==UserScript==
// @name RegExr: toggle sidebar
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Allows you to toggle sidebar on RegExr.com
// @author Himalay
// @match http://www.regexr.com/
// @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');
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment