Custom GitLab Style

Custom GitLab Style!

目前為 2023-05-22 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Custom GitLab Style
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Custom GitLab Style!
// @author       Sean
// @match        http://192.168.0.200/fe3project*
// @icon         http://192.168.0.200/assets/favicon-7901bd695fb93edb07975966062049829afb56cf11511236e61bcf425070e36e.png
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    // 注入样式:改变容器宽度,项目描述多行展示
    let injectStyle = ".group-list-tree .group-row-contents .description p { white-space: normal; } .container-limited.limit-container-width { max-width: 1400px } .limit-container-width .info-well {max-width: none;}";

    injectStyle += ".container-fluid.container-limited.limit-container-width .file-holder.readme-holder.limited-width-container .file-content {max-width: none;}"
    // 添加注入样式
    let extraStyleElement = document.createElement("style");
    extraStyleElement.innerHTML = injectStyle;
    document.head.appendChild(extraStyleElement);

    // 改变列表打开链接方式,改为新窗口打开
    let change = false;
    let tryTimes = 3;

    function changeOpenType() {
        if(!change && tryTimes > 0){
            setTimeout(()=> {
                let links = document.querySelectorAll('.description a');
                tryTimes--;
                if(links.length) {
                    for(let i = 0, l = links.length; i < l; i++) {
                        links[i].target = "_blank";
                        if(i === l - 1) {
                            change = true;
                        }
                    }
                } else {
                    changeOpenType();
                }
            }, 1000);
        }
    }

    window.onload = ()=> {

        changeOpenType();

        setTimeout(()=> {
            const links = document.querySelectorAll('.description a');
            for(let i = 0, l = links.length; i < l; i++) {
                links[i].addEventListener('click', ()=> {
                    event.stopPropagation();
                });
            }
        }, 2000);
    };

})();