Skip to content

Instantly share code, notes, and snippets.

@bespokoid
Created September 20, 2019 02:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bespokoid/bdb010ea27feb3d9c4844a08f07b8da5 to your computer and use it in GitHub Desktop.
Save bespokoid/bdb010ea27feb3d9c4844a08f07b8da5 to your computer and use it in GitHub Desktop.
TamperMonkey script to change editor settings like fontSize for TradingView script editor
// ==UserScript==
// @name TradingView editor options
// @namespace https://www.tradingview.com/
// @version 1.0
// @author bespokoid
// @match https://www.tradingview.com/*
// ==/UserScript==
(function() {
document.addEventListener("load", event =>
{
// Wait for Ace to load his styles
if (event.target.id == 'ace_editor.css' && (editor = ace.edit('editor'))) {
// Editor options. For full list look here: https://github.com/ajaxorg/ace/wiki/Configuring-Ace
editor = ace.edit('editor');
editor.setOptions({
fontSize: '16px',
// selectionStyle: "line"|"text",
// highlightActiveLine: true|false, //defauls to true
highlightSelectedWord: true, // true|false,
// readOnly: true|false,
cursorStyle: "slim", // "ace"|"slim"|"smooth"|"wide",
// mergeUndoDeltas: false|true|"always",
// behavioursEnabled: true|false,
// wrapBehavioursEnabled: true|false,
// this is needed if editor is inside scrollable page
autoScrollEditorIntoView: true, // defaults to false
// copy/cut the full line if selection is empty, defaults to false
// copyWithEmptySelection: true|false,
// useSoftTabs: true|false, // defaults to false
// navigateWithinSoftTabs: true|false, // false
// enableMultiselect: true|false,
// hScrollBarAlwaysVisible: boolean,
// vScrollBarAlwaysVisible: boolean,
// highlightGutterLine: boolean,
// animatedScroll: boolean,
// showInvisibles: boolean,
// showPrintMargin: boolean,
// printMarginColumn: number (defaults to 80)
// shortcut for showPrintMargin and printMarginColumn
// printMargin: false|number,
// fadeFoldWidgets: boolean,
// showFoldWidgets: boolean, // defaults to true
// showLineNumbers: boolean, // defaults to true
showGutter: false, // defaults to true
// displayIndentGuides: boolean, // defaults to true
// fontFamily: css font-family value,
// resize editor based on the contents of the editor until the number of lines reaches maxLines
// maxLines: number,
// minLines: number,
// number of page sizes to scroll after document end (typical values are 0, 0.5, and 1)
// scrollPastEnd: number|boolean,
// fixedWidthGutter: boolean (defaults to false),
// theme: path to a theme e.g "ace/theme/textmate", //Wouldn't work in case of TV :(
});
// Session options
editor.session.setUseWrapMode(true);
// editor.session.setFirstLineNumber(1);
// editor.session.setOverwrite(boolean);
// editor.session.setNewLineMode("auto" | "unix" | "windows");
// editor.session.setUseWorker(boolean);
// editor.session.setUseSoftTabs(boolean);
// editor.session.setTabSize(number);
// editor.session.setWrap(boolean|number);
// editor.session.setFoldStyle("markbegin"|"markbeginend"|"manual");
// editor.session.setMode(path to a mode e.g "ace/mode/text");
// Theming. Still in work :(
// ace.config.set('basePath','https://ace.c9.io/build/src/');
// editor.setTheme("ace/theme/monokai");
}
}, true);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment