Last active
July 25, 2019 13:47
-
-
Save EmilienD/82abd2a70cb41d40537c47edf7e1c8b6 to your computer and use it in GitHub Desktop.
User script to easily toggle document.designMode on a webpage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name DesignMode toggler | |
| // @version 1 | |
| // @grant none | |
| // @include * | |
| // ==/UserScript== | |
| const shortcut = { | |
| key: '1', | |
| ctrlKey: true, | |
| shiftKey: true, | |
| } | |
| const isShortcut = (sc, event) => | |
| Object.keys(sc).reduce( | |
| (acc, propName) => sc[propName] === event[propName] && acc, | |
| true, | |
| ) | |
| document.addEventListener('keyup', e => { | |
| if (isShortcut(shortcut, e)) { | |
| document.designMode = document.designMode === 'off' ? 'on' : 'off' | |
| } | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment