Skip to content

Instantly share code, notes, and snippets.

@alber70g
Last active August 31, 2021 18:51
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 alber70g/efe0839dd748df153dc8186c780f4751 to your computer and use it in GitHub Desktop.
Save alber70g/efe0839dd748df153dc8186c780f4751 to your computer and use it in GitHub Desktop.
Hide and Show WIP items in gitlab. **Install Grease or Tampermonkey**. Click the RAW version of the script and it'll redirect to Tamper-/Greasemonkey
// ==UserScript==
// @name Hide WIP on GitLab
// @namespace
// @version 0.2
// @description Dont show WIP in merge requests on GitLab
// @author Alber70g
// @include /.*gitlab.*\/merge_requests/
// @grant none
// @updateURL https://gist.github.com/Alber70g/efe0839dd748df153dc8186c780f4751/raw/toggleWipGitlab.user.js
// ==/UserScript==
(function() {
'use strict';
var shown = true;
function toggleWip() {
var allLi = Array.from(document.querySelectorAll(".mr-list > li"));
var listWips = allLi.filter(x => { return (x.textContent.toLocaleLowerCase().split("wip").length > 1); });
var listNonWips = allLi.filter(x => { return (x.textContent.toLocaleLowerCase().split("wip").length <= 1); });
listNonWips.forEach(x => { x.style.backgroundColor = 'lightyellow'; });
var hiddenMessage = document.getElementById('hiddenMessage');
if (!shown) {
shown = true;
listWips.forEach(x => { x.style.display = 'block'; });
} else {
shown = false;
listWips.forEach(x => { x.style.display = 'none'; });
}
}
var message = document.createElement('h5');
message.setAttribute('id', 'hiddenMessage');
message.style.color = 'orange';
message.style.userSelect = 'none';
message.innerText = 'Click to show/hide WIP';
message.addEventListener('click', toggleWip);
document.querySelector(".mr-list").prepend(message);
function onHref(substring) {
if (location.href.split(substring).length <= 1) {
alert('not on ' + substring + ': ' + location.href);
return false;
} else {
return true;
}
}
toggleWip();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment