// ==UserScript== // @name Add Patch Link Button to Gitlab // @namespace http://tampermonkey.net/ // @version 2026-09-18 // @description Adds a button to Gitlab pages to create a markdown link with the patch name // @match https://gitlab.wikimedia.org/*/-/merge_requests/* // @grant none // ==/UserScript== // Based on "Add Patch Link Button to Gerrit" (function() { 'use strict'; // Function to create the button element function createSinglePatchButton() { const singlePatchButton = document.createElement('button'); singlePatchButton.textContent = 'Patch'; singlePatchButton.style.cssText = ` position: fixed; bottom: 3em; right: 1em; z-index: 1000; background-color: #4CAF50; color: white; padding: 10px 15px; border: none; border-radius: 4px; cursor: pointer; `; singlePatchButton.onclick = () => { const mergeRequest = document.querySelector('.merge-request'); const patchName = mergeRequest.querySelector("h1.title").textContent.trim(); const repoName = window.location.href.split("https://gitlab.wikimedia.org/repos/")[1].split("/-/")[0] const markdownLink = `[[${repoName}] ${patchName}](${window.location.href})`; navigator.clipboard.writeText(markdownLink).then(() => { console.log('copied!'); }); }; return singlePatchButton; } // Function to inject the button into the page function injectButtons() { document.body.appendChild(createSinglePatchButton()); } injectButtons(); // Your code here... })();