Optimize work experience at Microsoft

Try to take over the world!

Από την 20/02/2021. Δείτε την τελευταία έκδοση.

// ==UserScript==
// @name         Optimize work experience at Microsoft
// @namespace    https://001.io/
// @version      1.0
// @description  Try to take over the world!
// @author       Guosen Wang
// @match        https://msdata.visualstudio.com/*
// @match        https://portal.microsofticm.com/imp/v3/incidents/details/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';
    const host = location.host;
    switch (host) {
        case 'msdata.visualstudio.com':
            devops();
            break;
        case 'portal.microsofticm.com':
            icm();
            break;
    }
})();

// Redirect VSTS to DevOps
function devops() {
    const url = location.href.replace("https://msdata.visualstudio.com", "https://dev.azure.com/msdata").replace("DefaultCollection/", "");
    window.location.replace(url);
}

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

        const body = document.querySelector('body');
        body.addEventListener('keydown', e => {
            if (e.key == 'f') {
                const enterFullScreenBtn = document.querySelector('body > div:nth-child(1) > main > div > ui-view > div > div > 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(4)');
                if (enterFullScreenBtn) {
                    enterFullScreenBtn.click();
                }
            } else if (e.key == "Escape") {
                const exitFullScreenBtn = document.querySelector('body > div:nth-child(1) > main > div > ui-view > div > div > 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(4)');
                if (exitFullScreenBtn) {
                    exitFullScreenBtn.click();
                }
            }
        });
    };
}