anador / Sfera knoweledge helper

// ==UserScript==
// @name         Sfera knoweledge helper
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  
// @author       anador
// @match        https://sfera.inno.local/knowledge*
// @grant        none
// @license MIT
// ==/UserScript==

// замена favicon
(function () {
    let list = document.querySelectorAll('link[rel="icon"], link[rel="shortcut icon"]');
    list.forEach(el => {
        el.remove();
    });
    let link = document.createElement('link');
    link.rel = 'icon';
    link.href = 'https://sfera.inno.local/app/knowledge/api/page/v1/images/fab85606-efac-44da-b3e5-119549634945';
    document.head.appendChild(link);
})();

(function () {
    observer = new MutationObserver(() => {
        if ((docTitle = document.querySelector('span[data-testid="title-input-text"]')?.innerText)) {
            // observer.disconnect();
            document.title = `${docTitle} — Знания.Сфера`;

        }
        else if (docTitle = document.querySelector('span[data-testid="draft-status"]')?.previousSibling?.innerText) {
            document.title = `Изменить — ${docTitle} — Знания.Сфера`;
        }

        else {
            document.title = `Знания — Сфера`;
        }
    });
    observer.observe(document.body, {
        childList: true,
        subtree: true,
    })
})();


// включение проверки правописания
(function () {
    spellCheckObserver = new MutationObserver(() => {
        if (!document.body) return false;
        if (!document.querySelector('.mce-content-body')) return false;

        document.body.spellcheck = true;
        document.querySelector('.mce-content-body').spellcheck = true;
    });
    spellCheckObserver.observe(document.body, {
        childList: true,
        // subtree: true,
    })
})();