Skip to content

Instantly share code, notes, and snippets.

@dravek
Last active October 27, 2023 14:50
Show Gist options
  • Save dravek/2f22e0b66d7f234dc1a639ec51296500 to your computer and use it in GitHub Desktop.
Save dravek/2f22e0b66d7f234dc1a639ec51296500 to your computer and use it in GitHub Desktop.
Tampermonkey script to show gitlab links in Moodle tracker
// ==UserScript==
// @name Gitlab WP link
// @namespace https://tracker.moodle.org/
// @version 0.1
// @description Show gitlab MRs for the current issue (based on previous script from tracker)
// @author David Carrillo <davidmc@moodle.com>
// @match https://tracker.moodle.org/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=moodle.org
// @grant none
// ==/UserScript==
(function() {
'use strict';
run();
})();
async function run() {
// Get the issue.
const issue = document.querySelector('meta[name=ajs-issue-key]')?.getAttribute('content') ?? '';
// End if it's not a WP issue.
if (! issue.match(/^WP(OS|)-/)) {
return;
}
// Build the link
const link = '<a target="_blank" href="https://git.in.moodle.com/groups/workplace/-/merge_requests?' +
'scope=all&utf8=%E2%9C%93&state=all&search=' + issue + '">View related merge requests</a>';
const issuedetails = document.getElementById("issuedetails");
issuedetails.innerHTML += '<li class="item full-width" id="gitlab-matching-mr"><div class="wrap" id=wrap-gitlab">' +
'<strong class="name">Gitlab link:</strong>' +
'<div class="gitlab-wrap value"><span class="gitlab">' +
link +
'</span></div></div></li>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment