Now it works, but does not update correctly the points afterwards
This commit is contained in:
parent
500f272c25
commit
8860bf29d9
2 changed files with 32 additions and 16 deletions
|
@ -1,15 +1,33 @@
|
|||
window.onload = function () {
|
||||
var calculateIssuePoints = function {
|
||||
document.getElementsByClassName.forEach(function(link) {
|
||||
let points_mark = link.text.match(/^\(\d+\)*/);
|
||||
if (points) {
|
||||
let points = points_mark[0].replace(/\(\)/g, '');
|
||||
link.text = link.text.replace(/^\(\d+\)/, '<span class="issue-points" style="background-color: #eef;">' + points + '</span>');
|
||||
}
|
||||
});
|
||||
var calculateIssuePoints = function () {
|
||||
let links = document.getElementsByClassName('js-project-card-issue-link');
|
||||
for (let count = 0; count < links.length; count++) {
|
||||
let link = links[count];
|
||||
let points_mark = link.text.match(/^\(\d+\)*/);
|
||||
if (points_mark) {
|
||||
let points = points_mark[0].replace(/\(|\)/g, '');
|
||||
link.innerHTML = link.text.replace(/^\(\d+\)/, '<span class="issue-points" style="background-color: #0366d6; color: #fff; padding: 0.1rem;">' + points + '</span>');
|
||||
}
|
||||
};
|
||||
var updatePoints = function () {
|
||||
calculateIssuePoints();
|
||||
};
|
||||
setTimeout(2000, updatePoints);
|
||||
};
|
||||
|
||||
var updatePoints = function () {
|
||||
calculateIssuePoints();
|
||||
let columns = document.getElementsByClassName('project-column');
|
||||
for (let count = 0; count < columns.length; count++) {
|
||||
let total = 0;
|
||||
let column = columns[count];
|
||||
let point_marks = column.getElementsByClassName('issue-points');
|
||||
for (let j = 0; j < point_marks.length; j++) {
|
||||
total += parseInt(point_marks[j].textContent);
|
||||
}
|
||||
let header = column.getElementsByTagName('h4')[0];
|
||||
let column_points = header.getElementsByClassName('column-points');
|
||||
if (column_points.length > 0) {
|
||||
column_points[0].text = total;
|
||||
} else {
|
||||
header.innerHTML = '<span class="column-points" style="background-color: #0366d6; color: #fff; padding: 0.1rem;">' + total + '</span>' + header.innerHTML;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
window.setInterval(updatePoints, 2000);
|
||||
|
|
|
@ -10,9 +10,7 @@
|
|||
"48": "icons/githubpoints-48.png"
|
||||
},
|
||||
|
||||
"permissions":["<all_urls>","tabs"],
|
||||
|
||||
"content_security_policy": "script-src 'self'; object-src 'self'; font-src 'self';",
|
||||
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'; font-src 'self';",
|
||||
|
||||
"content_scripts": [
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue