Skip to content

Instantly share code, notes, and snippets.

@tijnjh
Last active February 10, 2026 08:26
Show Gist options
  • Select an option

  • Save tijnjh/56d94a2d9dce858f1888cc147f344a59 to your computer and use it in GitHub Desktop.

Select an option

Save tijnjh/56d94a2d9dce858f1888cc147f344a59 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Quick MR link button
// @namespace http://tampermonkey.net/
// @version 2026-02-09
// @description Copy rich text link for MR
// @author You
// @match https://git.fletcher.build/**/merge_requests/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=fletcher.build
// @require https://cdn.jsdelivr.net/gh/tijnjh/cdnner@a6f1947/dist/main.js
// @grant none
// ==/UserScript==
(() => {
"use strict";
const titleEl = document.querySelector("h1");
const actionsEl = document.querySelector(".detail-page-header-actions");
if (!titleEl) return;
const copyButton = document.createElement("button");
copyButton.textContent = "Copy rich link";
copyButton.className = "gl-button btn btn-md btn-default gl-md-display-block gl-md-mr-3";
copyButton.onclick = async () => {
const textBefore = copyButton.textContent;
const title = titleEl.textContent.trim();
const url = location.href;
const html = `<a href="${url}">${title}</a>`;
const text = `${title} (${url})`; // fallback
await navigator.clipboard.write([
new ClipboardItem({
"text/html": new Blob([html], { type: "text/html" }),
"text/plain": new Blob([text], { type: "text/plain" }),
}),
]);
toast.success("Copied rich link to clipboard", { richColors: true });
};
actionsEl.insertAdjacentElement("afterbegin", copyButton);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment