// ==UserScript== // @name ECU Bitbucket Improvements // @namespace https://greasyfork.org/en/scripts/458896 // @homepageURL https://gist.github.com/raveren/3bd55656272143f667e9cfd7e7171c52 // @license MIT // @version 1.4.0 // @author raveren // @description Changes page titles to be informative, makes branch name click to copy, and links PHPStorm from diff line // @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 // @downloadURL none // ==/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.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 = $('div[data-qa="pr-branches-and-state-styles"] > div:first-child > div:first-child > span:first-child > span:first-child') .text() .replace(/^Branch: /, ''); if (branchName) { $('