ScriptsForMsDocToc

MSDN TOC Enhance

  1. // ==UserScript==
  2. // @name ScriptsForMsDocToc
  3. // @namespace mailto:fish404hsif@gmail.com
  4. // @version 0.7.2
  5. // @license MIT
  6. // @description MSDN TOC Enhance
  7. // @description:zh 微软文档目录功能新增
  8. // @author fish-404
  9. // @run-at document-idle
  10. // @match *://learn.microsoft.com/*
  11. // @exclude *://learn.microsoft.com/*/training/*
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. (function () {
  16. 'use strict';
  17. setTocContainerSticky();
  18. clickShowMoreBtn();
  19. mvSave2CollectionBtn();
  20. })();
  21.  
  22. function logError(exception, customMsg) {
  23. console.error(`${customMsg} \n ${exception.name}: ${exception.message}`);
  24. }
  25.  
  26. function setTocContainerSticky() {
  27. try {
  28. document.getElementById("affixed-right-container").setAttribute("style", "position: sticky; top: 3vh");
  29. }
  30. catch (e) {
  31. logError(e, "Error: set to ccontainer sticky failed!");
  32. }
  33. }
  34.  
  35. function clickShowMoreBtn() {
  36. try {
  37. document.querySelector("#affixed-right-container .show-more-text").parentElement.click();
  38. }
  39. catch (e) {
  40. logError(e, "Error: click show more button failed!");
  41. }
  42.  
  43. try {
  44. document.querySelector('#right-rail-in-this-article-list .is-expanded a').setAttribute("style", "outline: 0");
  45. }
  46. catch (e) {
  47. logError(e, "Error: hide dash outline failed!");
  48. }
  49. }
  50.  
  51. function mvSave2CollectionBtn() {
  52. try {
  53. document.querySelector('div[data-bi-name="right-column"] article div').insertAdjacentElement('beforeend', document.querySelector('button[data-bi-name="collection"]'));
  54. }
  55. catch (e) {
  56. logError(e, "Error: move save to collection button failed!");
  57. }
  58. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址