Skip to content

Instantly share code, notes, and snippets.

@DaniilBabanin
Last active January 31, 2018 13:45
Show Gist options
  • Save DaniilBabanin/55ef57222649feebf26191292f9a40e5 to your computer and use it in GitHub Desktop.
Save DaniilBabanin/55ef57222649feebf26191292f9a40e5 to your computer and use it in GitHub Desktop.
GitLab - userscripts
// ==UserScript==
// @name Hide issues by tags
// @namespace http://babanin.de/
// @version 0.2
// @description try to take over the world! and hide gitlab issues by tags
// @author Daniil Babanin & Robin Würfel
// @match http*://hpm.agency/*
// @grant none
// ==/UserScript==
window.setInterval(function() {
'use strict';
var opacityLables = ['Ready For Test', 'Ready for Test', 'Blocked', 'Concept', 'Draft', "won't fix", 'Suggestion', 'Input Needed' ];
var ignoreLables = ['Ready For Test', 'Ready for Test', 'Blocked', "won't fix"];
var issues = document.getElementsByClassName('issue');
if (issues.length) {
for ( var i = 0; i < issues.length; i ++ ) {
var issue = issues[i];
var tagElems = issue.getElementsByTagName('a');
var tags = [];
if(tagElems.length > 2){
var j = 2;
while(j < tagElems.length){
j = j + 1;
var elem = tagElems[j];
if(elem && elem.getElementsByTagName('span').length){
tags.push(elem.getElementsByTagName('span')[0].innerHTML);
}
}
}
var remove = tags.map(function(elem) {
if(ignoreLables.indexOf(String(elem)) !== -1){
return 'remove';
}
else if(opacityLables.indexOf(String(elem)) !== -1){
return 'opacity';
}
else{
return false;
}
}).filter(function (arg) {return arg;})
;
if(remove.indexOf('remove') !== -1){
issue.style.display = 'none';
}
if(remove.indexOf('opacity') !== -1){
issue.style.opacity = 0.5;
}
}
}
}, 500);
// ==UserScript==
// @name add lables to gitlab issue links
// @namespace babanin.de
// @description remove comment padding
// @include http*://hpm.agency/*/*/issues/*
// ==/UserScript==
var privatToken = '';
var base = 'https://hpm.agency/api/v4/projects/{{project}}/issues/{{issue}}';
setTimeout(function () {
$(function () {
var query = document.getElementsByClassName("gfm-issue");
if (query) {
for (var i in query) {
console.log('i: ', i);
(function (elem) {
try {
if (!elem) {
return;
}
var issueId;
try {
issueId = elem.dataset.original.split('/')
.pop();
issueId = issueId.split('#')
.pop();
} catch (e) {
issueId = elem.dataset.original.split('#')
.pop();
}
var requestURL = base.replace('{{project}}', elem.dataset.project)
.replace('{{issue}}', issueId);
console.log('requestURL: ', requestURL);
$.ajax({
url: requestURL,
headers: {
"PRIVATE-TOKEN": privatToken
},
})
.done(function (res) {
if (res.labels && res.labels.length) {
elem.text = elem.text + ' #' + res.labels.join(', #'); // text
//elem.title = elem.title + '-------------------------------------#' + res.labels.join(', #'); //popup
}
})
.fail(function (err) {
console.log('Error: ' + err.status);
});
} catch (e) {
console.log('e: ', e);
}
})(query[i]);
}
}
}, 5000);
});
// ==UserScript==
// @name remove issue list padding
// @namespace hpm.agency
// @description remove comment padding
// @include http*://hpm.agency/*/*/issues
// ==/UserScript==
setTimeout(function () {
$(function () {
var query = document.getElementsByClassName("issue");
if (query) {
for (i = 0; i < query.length; i++) {
query[i].style.padding = "1px 1px 1px";
query[i].style['border-color'] = "#666";
query[i].style['border-bottom'] = "2px solid #666";
}
}
});
}, 0);
// ==UserScript==
// @name sytsem comment size and opacity
// @namespace babanin.de
// @description sytsem comment size and opacity
// @include http*://hpm.agency/*/*/issues/*
// ==/UserScript==
(function() {
'use strict';
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
addGlobalStyle('ul.notes .system-note { font-size: 14px; opacity: 0.5; clear: both; display: block;}');
})();
// ==UserScript==
// @name remove comment padding
// @namespace hpm.agency
// @description remove comment padding
// @include http*://hpm.agency/*/*/issues/*
// ==/UserScript==
setTimeout(function () {
$(document)
.ajaxComplete(function () {
var query = document.getElementsByClassName("timeline-entry-inner");
if (query) {
for (i = 0; i < query.length; i++) {
query[i].style.padding = "1px 1px";
}
}
});
}, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment