PR 默认显示 Active Comments

默认显示 active comments,不用每次都点一下

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         PR 默认显示 Active Comments
// @version      0.1.3
// @description  默认显示 active comments,不用每次都点一下
// @namespace    https://dev.azure.com/
// @match        https://dev.azure.com/*/pullrequest/*
// @icon         https://cdn.vsassets.io/content/icons/favicon.ico
// @author       bowencool
// @license      MIT
// @supportURL   https://github.com/bowencool/Tampermonkey-Scripts/issues
// @require      https://cdn.jsdelivr.net/gh/bowencool/Tampermonkey-Scripts@f59cc91442dd34eb28e0d270486da5c7ac8d2d50/shared/waitForElementToExist.js
// @grant        none
// ==/UserScript==

(async function () {
  "use strict";

  function sleep(time) {
    return new Promise((resolve) => setTimeout(resolve, time));
  }

  const button = await waitForElementToExist(
    ".repos-activity-filter-dropdown button"
  );
  for (let i = 0; i < 10; i++) {
    button.click();
    const isActive = button.classList.contains("active");
    if (isActive) {
      break;
    }
    await sleep(500);
  }
  const dropDownId = button.getAttribute("aria-controls");
  const dropDownOption = await waitForElementToExist(`#${dropDownId} #__bolt-active_comments`);
  dropDownOption.click();
})();