Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Яндекс.Практикум
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Подсветка задач в трекере
  6. // @author Alex Zhukov (zhukovalexey@yandex-team.ru)
  7. // @match https://st.yandex-team.ru/agile/board/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Профессия: [номера задач]
  15. const CONFIG = {
  16. 'web-developer': [10, 11, 12, 13, 14, 15]
  17. };
  18.  
  19. const COLOR = 'red';
  20.  
  21. const MS_IN_SECOND = 1000;
  22.  
  23. function findTasks(count) {
  24. let tasks = Array.from(document.querySelectorAll('article.b-agile-task'));
  25.  
  26. if (tasks.length) {
  27. tasks.forEach(articleEl => {
  28. const {innerText: type} = articleEl.querySelector('.b-agile-task__components-value');
  29. const {innerText: name} = articleEl.querySelector('.b-agile-task__title');
  30.  
  31. if (type && name && CONFIG[type]) {
  32. const [_, number] = name.match(/\[([0-9]+)\]/);
  33.  
  34. if (number && CONFIG[type].indexOf(Number(number)) !== -1) {
  35. articleEl.style.backgroundColor = COLOR;
  36. articleEl.style.padding = '3px';
  37. }
  38. }
  39. });
  40. } else if (!count || count < 5) {
  41. setTimeout(() => findTasks(count + 1 || 0), MS_IN_SECOND);
  42. }
  43. }
  44.  
  45. setTimeout(findTasks, MS_IN_SECOND);
  46.  
  47. document.body.addEventListener('click', () => setTimeout(findTasks, MS_IN_SECOND));
  48. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement