Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Integration GitLab WOB-2728 #52

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 98 additions & 70 deletions public/scripts/content-scripts/gitlab.js
Original file line number Diff line number Diff line change
@@ -1,86 +1,114 @@
function insertAfter(el, referenceNode) {
referenceNode.parentNode.insertBefore(el, referenceNode.nextSibling);
referenceNode.parentNode.insertBefore(el, referenceNode.nextSibling);
}

wobblyButton.renderButton('.issue-details .detail-page-description', function(elem){
const rootElement = searchElem(elem);
if (!rootElement) return;
wobblyButton.renderButton('.issue-details .detail-page-description', function (elem) {
const rootElement = searchElem(elem);
if (!rootElement) return;

const getNumTaskText = () => {
const numTask = searchElem('.breadcrumbs-links li:last-child a');
return numTask ? numTask.textContent.split(' ').pop() : '';
}
const getNumTaskText = () => {
const numTask = searchElem('.breadcrumbs-links li:last-child a');
return numTask ? numTask.textContent.split(' ').pop() : '';
};

const getDetailTask = () => {
const detailTask = searchElem('.title', rootElement);
return detailTask ? detailTask.textContent : '';
}
const getDetailTask = () => {
const detailTask = searchElem('.title', rootElement);
return detailTask ? detailTask.textContent : '';
};

wobblyButton.detail = getDetailTask();
wobblyButton.task = getNumTaskText();
wobblyButton.issue = `${wobblyButton.task} ${wobblyButton.detail}`;
wobblyButton.detail = getDetailTask();
wobblyButton.task = getNumTaskText();
wobblyButton.issue = `${wobblyButton.task} ${wobblyButton.detail}`;

let container = searchElem('.detail-page-header-body');
let link = createTag('a', 'wobbly', 'Start timer')
link.style.cursor = 'pointer'
link.style = `
let container = searchElem('.detail-page-header-body');
let link = createTag('a', 'wobbly', 'Start timer');
link.style.cursor = 'pointer';
link.style = `
cursor: pointer;
padding-left: 20px;
background: url(${chrome.extension.getURL("images/favicon.svg")}) no-repeat;
background-position: -13px 50%;
margin-left: auto;
margin-right: 5px;
font-weight: 600;
background: url(${chrome.extension.getURL('images/favicon.svg')}) no-repeat;
background-position: -14px 45%;
background-size: 50% 50%;
`
insertAfter(link,container);
container.appendChild(link);

link.onclick = () => {
wobblyButton.currentTimer ? wobblyButton.timerStop() : wobblyButton.timerStart(`${getNumTaskText()} ${getDetailTask()}`);
}

link.title = `${getNumTaskText()} ${getDetailTask()}`;

wobblyButton.link = link;
if(link) {
const firstLink = container.getElementsByClassName('wobbly');
firstLink[0].style = `display: none;`;
}
})

wobblyButton.renderButton('.merge-request-details .detail-page-description', function(elem){
let rootElement = searchElem(elem)
if(!rootElement) return

const getNumTaskText = () => {
const numTask = searchElem('.breadcrumbs-links li:last-child a');
return numTask ? numTask.textContent.split(' ').pop() : '';
}

const getDetailTask = () => {
const detailTask = searchElem('h1.title');
return detailTask ? detailTask.textContent : '';
}

wobblyButton.detail = getDetailTask();
wobblyButton.task = getNumTaskText();
wobblyButton.issue = `${wobblyButton.task} ${wobblyButton.detail}`;

let container = searchElem('.detail-page-header-body');
let link = createTag('a', 'wobbly', 'Start timer')
link.style.cursor = 'pointer'
link.style = `
`;

// Цвета для ссылки при наведении и при отведении курсора
link.addEventListener('mouseover', function () {
this.style.color = '#1f75cb';
});

link.addEventListener('mouseout', function () {
this.style.color = '#333238';
});

insertAfter(link, container);
container.appendChild(link);

link.onclick = () => {
wobblyButton.currentTimer
? wobblyButton.timerStop()
: wobblyButton.timerStart(`${getNumTaskText()} ${getDetailTask()}`);
};

link.title = `${getNumTaskText()} ${getDetailTask()}`;

wobblyButton.link = link;
if (link) {
const firstLink = container.getElementsByClassName('wobbly');
firstLink[0].style = `display: none;`;
}
});

wobblyButton.renderButton('.merge-request-details .detail-page-description', function (elem) {
let rootElement = searchElem(elem);
if (!rootElement) return;

const getNumTaskText = () => {
const numTask = searchElem('.breadcrumbs-links li:last-child a');
return numTask ? numTask.textContent.split(' ').pop() : '';
};

const getDetailTask = () => {
const detailTask = searchElem('h1.title');
return detailTask ? detailTask.textContent : '';
};

wobblyButton.detail = getDetailTask();
wobblyButton.task = getNumTaskText();
wobblyButton.issue = `${wobblyButton.task} ${wobblyButton.detail}`;

let container = searchElem('.detail-page-header-body');
let link = createTag('a', 'wobbly', 'Start timer');
link.style.cursor = 'pointer';
link.style = `
cursor: pointer;
min-width: 100px;
margin-bottom: auto;
font-weight: 600;
padding-left: 20px;
background: url(${chrome.extension.getURL("images/favicon.svg")}) no-repeat;
background-position: -13px 50%;
background: url(${chrome.extension.getURL('images/favicon.svg')}) no-repeat;
background-position: -16px 45%;
background-size: 50% 50%;
`
container.appendChild(link);
`;

link.onclick = () => {
wobblyButton.currentTimer ? wobblyButton.timerStop() : wobblyButton.timerStart(`${getNumTaskText()} ${getDetailTask()}`);
}
link.addEventListener('mouseover', function () {
this.style.color = '#1f75cb'; // Замените на нужный цвет
});

link.title = `${getNumTaskText()} ${getDetailTask()}`;
link.addEventListener('mouseout', function () {
this.style.color = '#333238'; // Замените на исходный цвет текста
});
container.appendChild(link);

wobblyButton.link = link;
})
link.onclick = () => {
wobblyButton.currentTimer
? wobblyButton.timerStop()
: wobblyButton.timerStart(`${getNumTaskText()} ${getDetailTask()}`);
};

link.title = `${getNumTaskText()} ${getDetailTask()}`;

wobblyButton.link = link;
});