[Azure] Auto Resolve All

[Azure] Auto Resolve

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         [Azure] Auto Resolve All
// @namespace    Azure
// @version      1.10.12
// @description  [Azure] Auto Resolve
// @author       N.Duong
// @icon         https://www.google.com/s2/favicons?sz=64&domain=microsoft.com
// @run-at       document-start
// @grant        none
// @license      MIT
// @match        https://*/*/pullrequest/*
// @match        https://*/*/pullrequest/*
// ==/UserScript==

(function() {
    'use strict';

    function addResolveAllButton() {
        if (document.querySelector('#resolve')) {
            return; // Button already exists
        }

        let targetDiv = document.querySelector('.repos-activity-filter-dropdown');
        if (targetDiv) {
            let resolveButton = document.createElement('button');
            resolveButton.id = "resolve";
            resolveButton.textContent = 'Resolve All';
            resolveButton.className = 'bolt-button enabled bolt-focus-treatment';
            resolveButton.type = 'button';
            resolveButton.tabIndex = '0';
            resolveButton.style.marginLeft = '12px';

            resolveButton.addEventListener('click', function() {
                let xpath = "//div[contains(@class, 'repos-comment-editor-max-width')]//button[contains(@class, 'bolt-button')]";
                let button = document.evaluate(xpath, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
                for (let i = 0; i < button.snapshotLength; i++) {
                    let element = button.snapshotItem(i);
                    if (element.textContent.trim().toLowerCase() === 'resolve') {
                        console.log(element.textContent);
                        element.click();
                    }
                }
            });

            targetDiv.appendChild(resolveButton);
        }
    }
    
    // Option 1:
    window.addEventListener('DOMContentLoaded', addResolveAllButton, false);
    
    // Option 2:
    //addResolveAllButton();
    //const observer = new MutationObserver(addResolveAllButton);
    //observer.observe(document.body, { childList: true, subtree: true });
})();