ScriptsForMsDocToc

MSDN TOC Enhance

2022/09/27のページです。最新版はこちら

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         ScriptsForMsDocToc
// @namespace    mailto:[email protected]
// @version      0.7.0
// @license      MIT
// @description  MSDN TOC Enhance
// @description:zh 微软文档目录功能新增
// @author       fish-404
// @match        *://docs.microsoft.com/*
// @match        *://learn.microsoft.com/*
// @grant        none
// ==/UserScript==

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

function logError(exception, customMsg) {
    console.error(customMsg);
    console.error(exception.name);
    console.error(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("button[data-bi-name='show-more-btn']").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!");
    }
}