- install Tampermonkey
- Click here
Last active
February 15, 2024 15:01
-
-
Save KangOl/2d1b2f710346be87d760aaa2c245914c to your computer and use it in GitHub Desktop.
Change OPW tag to links to the ticket
This file contains 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 GitHub OPW Links | |
// @namespace odoo.com | |
// @description Change OPW tag to links to the ticket | |
// @include https://github.com/odoo/* | |
// @include https://github.com/odoo-dev/* | |
// @include https://github.com/odoo-ps/* | |
// @author @KangOl | |
// @version 22.03.03 | |
// @updateURL https://gist.githubusercontent.com/KangOl/2d1b2f710346be87d760aaa2c245914c/raw/github-opw-link.user.js | |
// @run-at document-end | |
// ==/UserScript== | |
(function() { | |
"use strict"; | |
function replace_opw() { | |
document.querySelectorAll('.js-commits-list-item pre, div.timeline-comment .comment-body p').forEach(function(desc) { | |
desc.innerHTML = desc.innerHTML.replace( | |
/\b(opw|task)\s*(?:-?id)?\s*(?:[:-](?:>)?)?\s*#?(\d+)\b/gi, | |
function(match, qualifier, id) { | |
id = parseInt(id); | |
const offset = 1000000; | |
if(qualifier==='opw' && id < offset) { | |
id += offset; | |
} | |
return '<a href="https://www.odoo.com/web#view_type=form&model=project.task&id='+id+'" class="issue-link odoo-link" style="background-color: #875A7B;color: white;padding: 0 0.2em;text-decoration: none;" target="_blank">'+match+'</a>'; | |
} | |
); | |
}); | |
} | |
window.addEventListener('load', function() { replace_opw(); }); | |
// Now that GitHub use websockets, this may not works anymore... | |
document.addEventListener('pjax:complete', function() { replace_opw(); }); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment