Skip to content

Instantly share code, notes, and snippets.

@bastsoft
Last active August 13, 2018 12:24
Show Gist options
  • Save bastsoft/67737ef0c3a12f5fb577ecd189fb51ac to your computer and use it in GitHub Desktop.
Save bastsoft/67737ef0c3a12f5fb577ecd189fb51ac to your computer and use it in GitHub Desktop.
for automation youTrack
var issueId = document.querySelector('.issueId').innerText;
var issueSummary = document.querySelector('.issue-summary').innerText;
var typeRus = document.querySelectorAll('.fsi-property .attribute')[2].innerText.trim();
var scope = document.querySelectorAll('.fsi-property .attribute')[5].innerText.trim();
var mapType = {
"Функциональность": "feature",
"Ошибка": "bugfix",
"Документация": "docs",
"Косметика": "style",
"Проблема удобства использования":"refactor",
"Проблема производительности":"perf",
"Тестирование":"test",
"tools chore":"chore"
}
var type = mapType[typeRus];
var xhr = new XMLHttpRequest();
var keyApi = window.keyAPIT;
var data = "key=" + keyApi + "&text=" + issueSummary + "&lang=ru-en&format=html";
xhr.open("POST", 'https://translate.yandex.net/api/v1.5/tr.json/translate', true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send(data);
xhr.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
var res = JSON.parse(this.responseText);
var rusText = res.text[0];
var rusTextChange = rusText.
toLowerCase().
replace(/\.|\,|\'|\"|\(|\)|^\ /g, '').
replace(/\ a\ |\ the\ |^the\ |\ of\ |\ on\ |\ \ /g, ' ').
replace(/\ a\ |\ the\ |^the\ |\ of\ |\ on\ |\ \ /g, ' ').
trim().replace(/\ /g, '-');
var otherGitCmd = "git checkout develop && git pull && git remote update -p && git branch";
issueBranchName = otherGitCmd + ' && ' + 'git checkout -b ' + type + '/' + issueId + '_' + rusTextChange;
prompt("Copy to clipboard: Ctrl+C, Enter", issueBranchName);
}
};
var issueId = document.querySelector('.issueId').innerText;
var issueSummary = document.querySelector('.issue-summary').innerText;
var typeRus = document.querySelectorAll('.fsi-property .attribute')[2].innerText.trim();
var scope = document.querySelectorAll('.fsi-property .attribute')[5].innerText.trim();
var mapType = {
"Функциональность": "feat",
"Ошибка": "fix",
"Документация": "docs",
"Косметика": "style",
"Проблема удобства использования":"refactor",
"Проблема производительности":"perf",
"Тестирование":"test",
"tools chore":"chore"
}
var type = mapType[typeRus];
var xhr = new XMLHttpRequest();
var keyApi = window.keyAPIT;
var data = "key=" + keyApi + "&text=" + issueSummary + "&lang=ru-en&format=html";
xhr.open("POST", 'https://translate.yandex.net/api/v1.5/tr.json/translate', true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send(data);
xhr.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
var res = JSON.parse(this.responseText);
var rusText = res.text[0];
var rusTextChange = rusText.
toLowerCase().
replace(/\.|\,|\'|\"|\(|\)|^\ /g, '').
replace(/\ a\ |\ the\ |^the\ |\ of\ |\ on\ |\ \ /g, ' ').
replace(/\ a\ |\ the\ |^the\ |\ of\ |\ on\ |\ \ /g, ' ').
trim();
issueBranchName = "git commit -m \"" + type + '(' + scope + '):' + issueId + '-' + rusTextChange + "\"";
prompt("Copy to clipboard: Ctrl+C, Enter", issueBranchName);
}
};
var list = document.queryAll('.yt-swimlane-column')[2].
queryAll('yt-agile-card').map(function(item, i){
return (i + 1) + '. ' + item.query('.yt-agile-card__summary').innerText
});
console.log(list.join('\n'));
var list = document.queryAll('.yt-swimlane-column')[0].
queryAll('yt-agile-card').map(function(item, i){
return (i + 1) + '. ' + item.query('.yt-agile-card__summary').innerText
});
console.log(list.join('\n'));
btr.loadGist({ url: 'https://gist.github.com/', id: '67737ef0c3a12f5fb577ecd189fb51ac'}, function(){
btr.contextMenu('body', {
getCommitStringForGit : btr.functionGist('getCommitName.js'),
getChekcoutStringForGit : btr.functionGist('getBranchName.js'),
getTodayListInConsole : btr.functionGist('getTodayListInConsole.js'),
getWeekListInConsole : btr.functionGist('getWeekListInConsole.js')
});
alert('done');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment