-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgitlab-tweak.user.js
More file actions
73 lines (66 loc) · 2.33 KB
/
gitlab-tweak.user.js
File metadata and controls
73 lines (66 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// ==UserScript==
// @name GitLab tweaks
// @namespace https://github.com/lilydjwg/userscripts
// @description My GitLab tweaks
// @match https://gitlab.com/*/issues/*
// @match https://gitlab.com/*/work_items/*
// @match https://gitlab.com/*/merge_requests/*
// @match https://gitlab.archlinux.org/*/issues/*
// @match https://gitlab.archlinux.org/*/work_items/*
// @match https://gitlab.archlinux.org/*/merge_requests/*
// @match https://gitlab.gnome.org/*/issues/*
// @match https://gitlab.gnome.org/*/work_items/*
// @match https://gitlab.gnome.org/*/merge_requests/*
// @match https://gitlab.freedesktop.org/*/issues/*
// @match https://gitlab.freedesktop.org/*/work_items/*
// @match https://gitlab.freedesktop.org/*/merge_requests/*
// @match https://gitlab.xfce.org/*/issues/*
// @match https://gitlab.xfce.org/*/work_items/*
// @match https://gitlab.xfce.org/*/merge_requests/*
// @version 0.2.9
// @grant none
// ==/UserScript==
(function() {
'use strict'
const add_item = function(el, sidebar) {
el.style.listStyleType = 'none'
el.style.paddingLeft = '0'
el.style.width = '250px'
el.querySelector('button').style.paddingLeft = '0'
sidebar.insertBefore(el, sidebar.firstChild)
}
const main = function() {
let notif, issueref
const is_issue = location.pathname.includes('/-/issues/') || location.pathname.includes('/-/work_items/')
if(is_issue) {
notif = document.querySelector('li[data-testid="notifications-toggle-form"]')
issueref = document.querySelector('li[data-testid="copy-reference-action"]')
} else {
notif = document.querySelector('li[data-testid="notification-toggle"]')
if(notif) {
notif = notif.parentNode
}
}
let sidebar = document.querySelector('section.work-item-overview-right-sidebar > .work-item-sidebar-container')
if(!sidebar)
sidebar = document.querySelector('aside > div')
if(notif) {
if(is_issue) {
add_item(notif, sidebar)
add_item(issueref, sidebar)
}else{
sidebar.insertBefore(notif, sidebar.firstChild)
}
return true
} else {
return false
}
}
const doit = function(count) {
if(count <= 0) return
if(!main()) {
setTimeout(() => { doit(count-1) }, 1000)
}
}
doit(10)
})()