(function () {
'use strict';
var OLD_CSS = 'https://fs.getcourse.ru/fileservice/file/download/a/952035/sc/252/h/6d594cc4ae990e70848efbb30ecf6314.css';
var SETTINGS_URL = '/pl/tasks/resp/objects';
function ensureBaseCss() {
if (document.getElementById('shhelpdeskcss')) return;
var link = document.createElement('link');
link.id = 'shhelpdeskcss';
link.rel = 'stylesheet';
link.href = OLD_CSS;
document.head.appendChild(link);
}
function clickText(text) {
var nodes = Array.prototype.slice.call(document.querySelectorAll('.v-list-item-title,.v-list-item,[role="option"],button'));
var target = nodes.find(function (node) { return (node.textContent || '').trim() === text; });
if (target) target.click();
}
function openNativeFilters() {
var input = document.querySelector('input[placeholder="Поиск и фильтры"],input[placeholder="Поиск"]');
if (input) input.click();
}
function chooseSort(label) {
var buttons = document.querySelectorAll('.toolbar-action-btn');
if (buttons[1]) {
buttons[1].click();
window.setTimeout(function () { clickText(label); }, 120);
}
}
function chooseStatus(label) {
openNativeFilters();
window.setTimeout(function () {
var input = document.querySelector('input[placeholder="Все активные статусы"]');
if (!input) return;
input.click();
window.setTimeout(function () {
clickText(label);
window.setTimeout(function () { clickText('Применить'); }, 100);
}, 120);
}, 120);
}
function css() {
return '.shh-topbar{position:fixed;z-index:990;top:0;left:70px;right:0;height:38px;box-sizing:border-box;display:flex;align-items:center;gap:9px;padding:0 18px;background:#1d1d1f;color:#fff;font:12px/1 Arial,sans-serif}' +
'.shh-brand{font-size:16px;font-weight:500;margin-right:4px}.shh-count{color:#d5d5d5;font-size:11px;margin-right:auto}' +
'.shh-control{height:22px;min-width:112px;padding:0 25px 0 8px;border:1px solid #cfcfcf;border-radius:2px;background:#fff;color:#111;font-size:11px;line-height:20px;outline:0}' +
'.shh-control.status{min-width:122px}.shh-filter,.shh-gear{height:24px;border:0;background:transparent;color:#f4f4f4;font:11px Arial,sans-serif;cursor:pointer}' +
'.shh-filter:hover,.shh-gear:hover{color:#dda55e}.shh-gear{display:flex;align-items:center;justify-content:center;width:28px;font-size:17px;text-decoration:none}' +
'body.shh-helpdesk .gc-main-content{padding-top:38px!important;height:calc(100vh - 38px)!important;box-sizing:border-box!important}' +
'@media(max-width:760px){.shh-topbar{left:0;padding:0 8px;gap:5px}.shh-brand,.shh-count{display:none}.shh-control{min-width:96px}.shh-control.status{min-width:104px}.shh-filter{font-size:0}.shh-filter:after{content:"Фильтры";font-size:11px}}';
}
function build() {
if (!/^\/pl\/helpdesk\/helpdesk/.test(location.pathname)) return;
ensureBaseCss();
document.body.classList.add('shh-helpdesk');
if (!document.getElementById('shh-toolbar-style')) {
var style = document.createElement('style');
style.id = 'shh-toolbar-style';
style.textContent = css();
document.head.appendChild(style);
}
if (document.getElementById('shh-topbar')) return;
var bar = document.createElement('div');
bar.id = 'shh-topbar';
bar.className = 'shh-topbar';
bar.innerHTML = 'todo' +
'входящие сообщения' +
'' +
'' +
'' +
'⚙';
document.body.appendChild(bar);
bar.querySelector('.shh-sort').addEventListener('change', function () {
if (this.value) chooseSort(this.value);
});
bar.querySelector('.shh-status').addEventListener('change', function () {
if (this.value) chooseStatus(this.value);
else openNativeFilters();
});
bar.querySelector('.shh-filter').addEventListener('click', openNativeFilters);
}
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', build);
else build();
new MutationObserver(build).observe(document.documentElement, {childList:true,subtree:true});
}());