Skip to content

Instantly share code, notes, and snippets.

@stevenhao
Created November 27, 2018 11:54
Show Gist options
  • Save stevenhao/0c5356ce0fbfcd57f81cb601256a34fd to your computer and use it in GitHub Desktop.
Save stevenhao/0c5356ce0fbfcd57f81cb601256a34fd to your computer and use it in GitHub Desktop.
Expose ace editor when its module is globally loaded
// ==UserScript==
// @name Ace Editor Exposer
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://modeanalytics.com/*
// @grant none
// ==/UserScript==
const ace = window.ace;
window.aceEditors = [];
console.debug('found ace module', ace);
const oldEdit = ace.edit.bind(ace);
ace.edit = function(...args) {
const editor = oldEdit(...args);
const element = args[0];
window.aceEditors.push({
editor,
element,
});
return editor;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment