您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Changes page titles to be informative, makes branch name click to copy, and links PHPStorm from diff line
当前为
// ==UserScript== // @name ECU Bitbucket Improvements // @namespace https://greasyfork.org/en/scripts/458896 // @homepageURL https://gist.github.com/raveren/3bd55656272143f667e9cfd7e7171c52 // @license MIT // @version 1.3.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 const branchName = $('#pull-request-details > header > div > div > div > div > div > div > div > div > div > div > span').eq(0).text(); $('<div style="position: fixed;top: 0;z-index: 9999;margin: 0 auto;width: 100%;text-align: center;cursor: pointer;font-weight: bold;color: darkred;">'+branchName+'</div>') .appendTo(document.body) .prop('title', 'click to copy') .on('click',function(){ navigator.clipboard.writeText($(this).text()) $(this).append('<span><svg width="16" height="16" viewBox="0 0 24 24" role="presentation"><g fill-rule="evenodd"><circle fill="green" cx="12" cy="12" r="10"></circle><path d="M9.707 11.293a1 1 0 10-1.414 1.414l2 2a1 1 0 001.414 0l4-4a1 1 0 10-1.414-1.414L11 12.586l-1.293-1.293z" fill="inherit"></path></g></svg> Copied</span>'); $(this).find('span').fadeOut(1000, function(){$(this).remove()}) }) }); })();