ECU Bitbucket Improvements

Changes page titles to be informative, makes branch name click to copy, and links PHPStorm from diff line

目前为 2024-02-12 提交的版本。查看 最新版本

// ==UserScript==
// @name        ECU Bitbucket Improvements
// @namespace   https://gf.qytechs.cn/en/scripts/458896
// @homepageURL https://cat7373.github.io/remove-web-limits/
// @license     MIT
// @version     1.2.0
// @author      raveren
// @description Changes page titles to be informative, makes branch name click to copy, and links PHPStorm from diff line
// @require     https://code.jquery.com/jquery-3.7.1.min.js
// @match       https://bitbucket.org/ecu1/internal-www/pull-requests*
// @match       https://bitbucket.org/ecu1/backend-api/pull-requests*
// @run-at      document-start
// @connect     localhost
// @grant       GM_xmlhttpRequest
// ==/UserScript==

(function () {
    'use strict';

    window.addEventListener('load', function () {
        if (location.href === 'https://bitbucket.org/ecu1/internal-www/pull-requests/') {
            document.title = 'All Pull Requests';
        } else {
            document.title = document.title.replace('ecu1 / internal-www / Pull Request ', '');
            document.title = document.title.replace(/Feature\/\w+ \d* /, '');
        }


        // small monitor icon when hovering on line number to go to IDE
        $(document).on('mouseover', 'a.line-number-permalink', function (e) {
            if ($(this).data('ecu-loaded')) {
                return
            }
            $(this).data('ecu-loaded', 1)

            // https://bitbucket.org/ecu1/internal-www/pull-requests/1373#chg_app/Modules/blablabla.php_newline81
            let link = $(this).prop('href').replace(/.*#chg_/, '')
            let path = link.replace(/_newline/, ':')


            let a = document.createElement('span');
            a.innerHTML = '<a class="asd" href="http://localhost:63342/api/file/' + path + '"><svg width="8px" height="8px" version="1.1" viewBox="0 0 2.1024 2.1186" xmlns="http://www.w3.org/2000/svg"><g transform="translate(-1.1725 -.99595)"><path d="m1.1743 1.2677 1.8282-7.437e-4 0.00146 1.8455m-1.6398-0.18919 1.6423-1.6446" stroke="#000" stroke-width=".54173"/></g></svg></a>';
            a.onclick="return false"
            a.title="Open in PHPStorm"
            $(this).before(a);
        });

        $(document).on('click', 'a.asd', function (e) {
            e.preventDefault()

            GM_xmlhttpRequest({
                method: "GET",
                url: this.href,
            })

            return false
        })

        // make branch name stand out a little and click to copy
        $('[data-qa="pr-branches-and-state-styles"] > div > div > div > span').eq(0)
            .css({'max-width':'inherit','color':'red'})
            .prop('title', 'click to copy')
            .on('click',function(){
               navigator.clipboard.writeText($(this).text())
               $(this).parent().append(' (copied to clipboard)');
            })
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址