Last active
June 2, 2025 09:53
-
-
Save william-andre/740d8b146f5f99eec6c3062c3fd27b50 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Floating Mergebot | |
// @namespace https://odoo.com | |
// @version 2025-01-14 | |
// @description Floating button to link mergebot/runbot | |
// @author [email protected] | |
// @match https://github.com/odoo/enterprise/pull/* | |
// @match https://github.com/odoo/odoo/pull/* | |
// @match https://github.com/odoo/upgrade/pull/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
makeMergebotButton(); | |
makeRunbotButton(); | |
})(); | |
function makeMergebotButton() { | |
const url = new URL(document.URL); | |
const stem = new RegExp("(.*/pull/\\d+).*"); | |
url.hostname = 'mergebot.odoo.com'; | |
url.pathname = url.pathname.replace(stem, '$1') | |
makeButton("Mergebot", url, '10px'); | |
} | |
function makeRunbotButton() { | |
const branch = document.querySelectorAll('.commit-ref .css-truncate-target')[3].textContent; | |
const url = 'https://runbot.odoo.com/runbot/bundle/' + branch; | |
makeButton("Runbot", url, '40px'); | |
} | |
function makeButton(title, url, height) { | |
const button = document.createElement('button'); | |
button.innerText = title; | |
button.style.position = 'fixed'; | |
button.style.bottom = height; | |
button.style.right = '10px'; | |
button.style.height = '30px'; | |
button.style['font-size'] = '10px'; | |
button.style.zIndex = 1000; | |
async function openUrl(e) { | |
e.preventDefault(); | |
const target = e.currentTarget; | |
target.disabled = true; | |
const tab = window.open(url, '_blank'); | |
tab.focus(); | |
target.disabled = false; | |
} | |
button.onclick = openUrl; | |
button.onauxclick = openUrl; | |
document.documentElement.appendChild(button); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment