-
Notifications
You must be signed in to change notification settings - Fork 0
/
KAST.txt
143 lines (124 loc) · 4.93 KB
/
KAST.txt
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// ==UserScript==
// @name KAST - KPI Assessment Support Tool
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Mini tool for supporting KPI assessment (* ̄3 ̄)╭
// @author Mzn
// @include https://pms.bssgroup.vn/default/viewtaskdetail/*
// @icon https://bssgroup.vn/wp-content/uploads/2022/10/favicon.png
// @grant none
// ==/UserScript==
(function () {
const memberList = [
"Nguyễn Văn Ninh",
"Trần Đức Nam",
"Nguyễn Kim Tùng",
"Cao Nam Trường",
"Bùi Đình Dự",
"Hoàng Ngọc Nhật",
"Vũ Minh Hiếu",
"Nguyễn An Thuyên",
"Nguyễn Thế Huy"
]
var commitList = []
function appendDropdown(optionName, selector, data) {
const option = document.createElement('option');
option.value = optionName;
if (data == optionName) {
option.selected = 'selected'
}
option.textContent = optionName;
selector.appendChild(option);
}
function changeBgColor(eleList) {
const noLogCmtColor = 'rgb(255 212 157)'
const logCmtColor = 'rgb(253 241 225)'
let allComment = document.querySelectorAll(".comment_item")
allComment.forEach(cmt => {
cmt.style.backgroundColor = ''
});
eleList.forEach(ele => {
const logTimeEle = ele.querySelector(".comment_item > span:nth-child(2)")
if (logTimeEle && logTimeEle.textContent.includes("Time Log")) {
ele.style.backgroundColor = noLogCmtColor
} else ele.style.backgroundColor = logCmtColor
});
}
function getData() {
const name = localStorage.getItem('mznTargetMember')
const month = localStorage.getItem('mznTargetMonth')
return { name, month }
}
function getCommentLineByNameAndMonth(isUpdate) {
const { name, month } = getData()
let allComment = document.querySelectorAll(".comment_item")
var targetComment = Array.from(allComment).filter(el => el.querySelector(".bc-usercm").textContent.trim() == name);
targetComment = Array.from(targetComment).filter(el => parseInt(el.querySelector(".comment_item > span:nth-child(2) > span").textContent.trim().split('-')[1], 10) == month);
targetComment.forEach(ele => {
var commentUrl = ele.querySelectorAll('[class*="comment_item"] > p > a')
if (commentUrl) {
commentUrl.forEach(e => {
if (e.href.includes('/commits/') && !commitList.includes(e.href)) {
commitList.push(e.href)
window.open(e.href);
}
});
}
});
targetComment[0].scrollIntoView()
changeBgColor(targetComment)
}
function loadScript() {
const targetDiv = document.querySelector(".wrap_comment")
const observer = new MutationObserver((mutationsList, observer) => {
let isUpdate = false
for (let mutation of mutationsList) {
if (mutation.type === 'childList') {
isUpdate = true
}
}
if (isUpdate) {
getCommentLineByNameAndMonth(true)
}
});
const config = {
childList: true
};
observer.observe(targetDiv, config);
getCommentLineByNameAndMonth()
}
//append function block with fixed position
var divBlock = document.createElement("div");
divBlock.classList.add('mzn');
divBlock.style = "top:0;left:calc(50% - 150px);position:fixed;z-index:99999;width:300px;height:5rem;background-color:#31353d;border:none;";
document.body.appendChild(divBlock);
// Create a new select element
const selectName = document.createElement('select');
const selectMonth = document.createElement('select');
// Set style for select ele
selectName.style = "height:100%;width:70%";
selectMonth.style = "height:100%;width:30%";
// Set any desired attributes or properties
selectName.id = 'memberList';
selectMonth.id = 'targetMonth';
var { name, month } = getData()
memberList.forEach(member => {
appendDropdown(member, selectName, name)
});
for (let i = 0; i < 12; i++) {
appendDropdown(`${i}`, selectMonth, month)
}
selectName.addEventListener('change', function (event) {
localStorage.setItem('mznTargetMember', event.target.value)
getCommentLineByNameAndMonth()
});
selectMonth.addEventListener('change', function (event) {
localStorage.setItem('mznTargetMonth', event.target.value)
getCommentLineByNameAndMonth()
});
// Append the select element to a target HTML element
const targetElement = document.getElementsByClassName('mzn');
targetElement[0].appendChild(selectName);
targetElement[0].appendChild(selectMonth);
loadScript()
})();