Optimize work experience at Microsoft

Optimize work experience at Microsoft!

Από την 23/12/2024. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Optimize work experience at Microsoft
// @namespace
// @version      1.0.0
// @description  Optimize work experience at Microsoft!
// @author       Guosen Wang
// @match        https://ms.portal.azure.com/*
// @match        https://*.visualstudio.com/*
// @match        https://portal.microsofticm.com/imp/v3/incidents/details/*
// @match        https://eng.ms/docs/*
// @run-at       document-start
// @grant        none
// @namespace https://001.io/
// ==/UserScript==
(function () {
    'use strict';
    const host = location.host;

    switch (true) {
        case 'ms.portal.azure.com' === host:
            azure();
            break;
        case 'portal.microsofticm.com' === host:
            icm();
            break;
        case 'eng.ms' === host:
            eng_ms();
            break;
        case ["developercommunity", "spsprodeus27.vssps"].indexOf(host.match(/^(.+).visualstudio.com$/)[1].toLowerCase()) == -1:
            vsts();
            break;
    }
})();

function azure() {
    let checkExist = setInterval(function () {
        const selector = '#_weave_e_6';
        if (document.querySelector(selector)) {
            document.querySelector(selector).remove();
            const bannerLabel = document.querySelector("#_weave_e_5 > div.fxs-topbar-internal.fxs-internal-full");
            bannerLabel.innerText = bannerLabel.innerText.replace(" (Preview)", "");
            clearInterval(checkExist);
        }
    }, 100);
    setTimeout(() => {
        clearInterval(checkExist);
    }, 5000);
}

// Redirect VSTS to DevOps
function vsts() {
    let url = location.href.replace(/(\w+)\.visualstudio.com(\/DefaultCollection)?/, 'dev.azure.com/$1');
    location.replace(url);
}

// Optimize ICM fullscreen experience
function icm() {
    window.onload = () => {
        const style = document.createElement('style');
        style.innerText = '.widget.full-frame{padding:25px 25% 0;}.in.collapse::-webkit-scrollbar{display:none;}.widget.full-frame>header{padding-left:0;}';
        document.querySelector('head').appendChild(style);

        const body = document.querySelector('body');
        body.addEventListener('keydown', e => {
            if (e.ctrlKey || e.altKey) {
                return;
            }
            if (e.key === "f" || e.key === "F") {
                if (e.target.tagName === "INPUT") {
                    return;
                }
                const enterFullScreenBtn = document.querySelector('#skip-to-main > ui-view > div > div:nth-child(3) > div.maintabs-tabset > div > div.tab-pane.active > div > detail-view > div > div.col-12.col-sm-8 > widget-panel > div > section:nth-child(1) > header > button:nth-child(5)');
                if (enterFullScreenBtn) {
                    enterFullScreenBtn.click();
                }
            } else if (e.key === "Escape") {
                const exitFullScreenBtn = document.querySelector('#skip-to-main > ui-view > div > div:nth-child(3) > div.maintabs-tabset > div > div.tab-pane.active > div > detail-view > div > div.col-12.col-sm-8 > widget-panel > div > section.widget.full.full-frame.non-draggable > header > button:nth-child(5)');
                if (exitFullScreenBtn) {
                    exitFullScreenBtn.click();
                }
            }
        });
    };
}

function eng_ms() {
    const style = document.createElement("style");
    style.textContent = ".docfx-container pre{line-height:0;}";
    document.head.appendChild(style);
}