Skip to content

Instantly share code, notes, and snippets.

@a2intl
Created February 23, 2019 16:46
Show Gist options
  • Save a2intl/293a76ae3323ec21d7cdceb6f7cd63af to your computer and use it in GitHub Desktop.
Save a2intl/293a76ae3323ec21d7cdceb6f7cd63af 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});
})();
@a2intl
Copy link
Author

a2intl commented Jul 15, 2019

@unrue If you're using a private jenkins instance (i.e. not the one at http://jenkins-ci.org), you'll need to customize the @match line, for instance @match https://my-company-jenkins.corp/*. You can make sure the @match is working by checking out the TamperMonkey extension menu and making sure "Enabled" and "Resizable Jenkins Script Editor" are the first two items when you're on a Jenkins tab. Also, this was tested on Jenkins 2.121.2, different versions might have different versions of the ace_editor component or name their UI elements differently in a way this script can't find them.

@unrue
Copy link

unrue commented Jul 16, 2019

@a2int, thanks for the help. Using Jenkins 2.176.1 unfortunately does not works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment