Greasy Fork is available in English.
Custom hotkeys for overleaf.com
当前为
// ==UserScript==
// @name Overleaf morekeys
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Custom hotkeys for overleaf.com
// @author markusmo3
// @match https://www.overleaf.com/project/*
// @grant none
// @require http://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js
// @require http://cdnjs.cloudflare.com/ajax/libs/mousetrap/1.6.1/mousetrap.min.js
// @require http://cdnjs.cloudflare.com/ajax/libs/mousetrap/1.6.1/plugins/global-bind/mousetrap-global-bind.min.js
// ==/UserScript==
// original source: http://greasyfork.icu/en/scripts/387109-overleaf-fileswitcher/code
(function($, undefined) {
function encloser(cmd) {
var fn = function(editor) {
var selection = editor.getSelection();
if (selection.isEmpty()) {
editor.insert("\\" + cmd + "{}");
return editor.navigateLeft(1);
}
var text = editor.getCopyText();
return editor.insert("\\" + cmd + "{" + text + "}");
}
return fn;
}
function init() {
console.log("activating custom overleaf hotkeys...");
var editor = ace.edit($('.ace-editor-body')[0]);
//console.log(editor);
// ctrl-m to insert '\text'
editor.commands.addCommand({
name: "mathmode",
bindKey: {
win: "Ctrl-M",
mac: "Command-M"
},
exec: encloser('text'),
readOnly: !1
});
// custom hotkey by markusmo3
editor.commands.byName['add-new-comment'].exec = editor.commands.byName.togglecomment.exec
editor.commands.byName.copylinesdown.bindKey = {
win: "Alt-Shift-Down|Ctrl-Shift-D",
mac: "Command-Option-Down|Command-Shift-D"
}
}
function wait_to_load(callback) {
if ($('.loading-screen-brand').length > 0) {
console.log("still loading");
window.setTimeout(wait_to_load, 500, callback);
} else {
console.log("detected loading completion");
window.setTimeout(callback, 200);
}
}
$(document).ready(function() {
wait_to_load(init);
});
})(window.jQuery.noConflict(true));