ScriptsForMsDocToc

MSDN TOC Enhance

Verze ze dne 18. 10. 2022. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         ScriptsForMsDocToc
// @namespace    mailto:[email protected]
// @version      0.7.2
// @license      MIT
// @description  MSDN TOC Enhance
// @description:zh 微软文档目录功能新增
// @author       fish-404
// @run-at       document-idle
// @match        *://learn.microsoft.com/*
// @exclude      *://learn.microsoft.com/*/training/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';
    setTocContainerSticky();
    clickShowMoreBtn();
    mvSave2CollectionBtn();
})();

function logError(exception, customMsg) {
    console.error(`${customMsg} \n ${exception.name}: ${exception.message}`);
}

function setTocContainerSticky() {
    try {
        document.getElementById("affixed-right-container").setAttribute("style", "position: sticky; top: 3vh");
    }
    catch (e) {
        logError(e, "Error: set to ccontainer sticky failed!");
    }
}

function clickShowMoreBtn() {
    try {
        document.querySelector("#affixed-right-container .show-more-text").parentElement.click();
    }
    catch (e) {
        logError(e, "Error: click show more button failed!");
    }

    try {
        document.querySelector('#right-rail-in-this-article-list .is-expanded a').setAttribute("style", "outline: 0");
    }
    catch (e) {
        logError(e, "Error: hide dash outline failed!");
    }
}

function mvSave2CollectionBtn() {
    try {
        document.querySelector('div[data-bi-name="right-column"] article div').insertAdjacentElement('beforeend', document.querySelector('button[data-bi-name="collection"]'));
    }
    catch (e) {
        logError(e, "Error: move save to collection button failed!");
    }
}