Last active
October 13, 2024 14:55
-
-
Save indirivacua/1b9c878c5b7e3487be7ca5fb384ff286 to your computer and use it in GitHub Desktop.
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 Overleaf Editor Enhancer | |
// @namespace https://gist.github.com/indirivacua/1b9c878c5b7e3487be7ca5fb384ff286 | |
// @version 0.1 | |
// @description This script aims to improve productivity and user experience on Overleaf LaTeX editor. | |
// @author indirivacua | |
// @match https://*.overleaf.com/project/* | |
// @icon https://images.ctfassets.net/nrgyaltdicpt/h9dpHuVys19B1sOAWvbP6/5f8d4c6d051f63e4ba450befd56f9189/ologo_square_colour_light_bg.svg | |
// @grant none | |
// @license MIT | |
// @updateURL https://gist.github.com/indirivacua/1b9c878c5b7e3487be7ca5fb384ff286/raw/overleaf_editor_enhancer.user.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
setTimeout(function () { | |
var toolbar = document.querySelector('div.toolbar-editor'); | |
var buttonGroup = document.createElement('div'); | |
buttonGroup.className = "ol-cm-toolbar-button-group"; | |
var element = document.createElement('img'); | |
element.src = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1em' height='1em' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M14.7 20.7L11 17l3.7-3.7l1.4 1.45L14.85 16h2.4q.725 0 1.238-.513T19 14.25t-.513-1.237t-1.237-.513H4v-2h13.25q1.575 0 2.663 1.088T21 14.25t-1.088 2.663T17.25 18h-2.4l1.25 1.25zM4 18v-2h5v2zM4 7V5h16v2z'/%3E%3C/svg%3E"; | |
element.className = "ol-cm-toolbar-button btn"; | |
element.onclick = function() { | |
var editor = document.querySelector('.cm-content'); | |
editor.classList.toggle("cm-lineWrapping"); | |
}; | |
element.title = "Toggle Line Wrap"; | |
buttonGroup.appendChild(element); | |
toolbar.insertBefore(buttonGroup, toolbar.children[1]); | |
var button = document.querySelector('button.ol-cm-toolbar-button-math'); | |
button.addEventListener('click', function() { | |
setTimeout(function() { | |
var overlay = document.querySelector('div.symbol-palette-overlay.small'); | |
overlay.parentNode.removeChild(overlay); | |
}, 1000); | |
}); | |
}, 3000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 26, add:
element.title="Toggle Line Wrap";