Skip to content

Instantly share code, notes, and snippets.

@srz-zumix
Forked from a2intl/resize_jenkins_editor.js
Created March 13, 2020 02:50
Show Gist options
  • Save srz-zumix/ef9c63abce41e20c52c94ebb53dbcb7e to your computer and use it in GitHub Desktop.
Save srz-zumix/ef9c63abce41e20c52c94ebb53dbcb7e to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Resizeable Jenkins Script Editor
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Display pipeline options in wide screen, make script editor resizeable.
// @author Andrew Allen (credit to Victor Toulouse for previous version)
// @match http://jenkins-ci.org
// @grant none
// ==/UserScript==
/**
* Wait for the script editor to appear.
*/
function check(changes, observer) {
var ace_editors = document.querySelectorAll('.ace_editor');
ace_editors.forEach(function(editor) {
if(!editor.made_wide) {
var container = editor.closest('tr.dropdownList-container');
if(container) {
container.querySelector(':scope > td:nth-child(1)').style.display = 'none';
container.querySelector(':scope > td:nth-child(2)').colSpan = '3';
editor.made_wide = true;
}
}
if(!editor.made_resizeable) {
var jquery_ui = editor.closest('.jquery-ui-1');
if(jquery_ui) {
jquery_ui.style.resize = 'both';
jquery_ui.style.overflow = 'scroll';
jquery_ui.style.height='750px';
editor.style.height='100%';
const resizeObserver = new ResizeObserver(entries => {
for (let entry of entries) {
if(entry.target.aceEditor) entry.target.aceEditor.resize();
}
});
resizeObserver.observe(editor);
editor.made_resizeable = true;
}
}
});
}
(function() {
'use strict';
document.querySelector('.container').style.width = '100%';
document.querySelector('.container').style.padding = '0';
document.querySelector('.col-md-offset-2').style.width = '100%';
document.querySelector('.col-md-offset-2').style.margin = '0';
(new MutationObserver(check)).observe(document, {childList: true, subtree: true});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment