NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name metadev-branches-ext // @namespace https://openuserjs.org/users/mchdev // @description adds custom branches in branch navigation, useful when the branch is not created under current user // @homepageURL https://openuserjs.org/scripts/mchdev/metadev-branches-ext // @updateURL https://openuserjs.org/meta/mchdev/metadev-branches-ext.meta.js // @downloadURL https://openuserjs.org/install/mchdev/metadev-branches-ext.user.js // @copyright 2020, mchdev (https://openuserjs.org/users/mchdev) // @license MIT // @version 0.4 // @grant none // @author mchdev // @match https://meta.vub.sk/* // @match https://meta2.vub.sk/* // ==/UserScript== (function() { 'use strict'; $(document).ready(function() { var match = /(mch|vubbranch);v=.*/g.exec(contentpath); if (!match) { return; } var root = match[1]; var key = 'metadev-branches-ext_' + root; ['odobrať všetky', 'odobrať vetvu...', 'pridať vetvu...'].concat((localStorage.getItem(key) || '').split(';').filter(b => b !== '')).forEach((branch, idx) => { if (idx == 0) { $('#branchselect').prepend($('<a class="branchref" style="display:block; background:lightgreen;">' + branch + '</a>').click(function() { localStorage.removeItem(key); location.reload(); })); } else if (idx == 1) { $('#branchselect').prepend($('<a class="branchref" style="display:block; background:lightgreen;">' + branch + '</a>').click(function() { var branch = prompt('Názov vetvy'); if (branch) { localStorage.setItem(key, (localStorage.getItem(key) || '').split(';').filter(b => b !== branch).join(';')); location.reload(); } })); } else if (idx == 2) { $('#branchselect').prepend($('<a class="branchref" style="display:block; background:lightgreen;">' + branch + '</a>').click(function() { var branch = prompt('Názov vetvy'); if (branch) { localStorage.setItem(key, (localStorage.getItem(key) || '').split(';').filter(b => b !== '').concat(branch).join(';')); location.reload(); } })); } else { $('#branchselect').prepend('<strong><a class="branchref" style="display:block; background:lightgreen;" href="https://' + location.hostname + '/' + root + ';v=' + branch + '/?hdropt=vcontrol">' + branch + '</a></strong>'); } }); }); })();