Overleaf customisation.

overleaf line-wrap toggle for overleaf.com

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Overleaf customisation.
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  overleaf line-wrap toggle for overleaf.com
// @author       You
// @match        https://www.overleaf.com/project/*
// @grant        none
// @license MIT
// ==/UserScript==


(function() {
    'use strict';

    setTimeout(function () {
        var toolbar = document.querySelector('div.toolbar-editor > div.toolbar-right');
        var element = document.createElement('A');
        element.textContent = 'Toggle wrap';
        element.onclick = function() {
            var editor = document.querySelector('.ace-editor-body');
            let session = ace.edit(editor).getSession();
            session.setUseWrapMode(!session.$useWrapMode)
        };
        toolbar.insertBefore(element, toolbar.children[0]);
    }, 3000);
})();