NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name metadev-newbranch-ext // @namespace https://openuserjs.org/users/mchdev // @description allows creating private branches, useful if current user contains underscore // @homepageURL https://openuserjs.org/scripts/mchdev/metadev-newbranch-ext // @updateURL https://openuserjs.org/meta/mchdev/metadev-newbranch-ext.meta.js // @downloadURL https://openuserjs.org/install/mchdev/metadev-newbranch-ext.user.js // @copyright 2020-2024, mchdev (https://openuserjs.org/users/mchdev) // @license MIT // @version 0.7 // @grant none // @author mchdev // @match https://meta.vub.sk/*;v=*/?hdropt=vcontrol // @match https://meta2.vub.sk/*;v=*/?hdropt=vcontrol // @run-at document-end // ==/UserScript== (function() { 'use strict'; $(document).ready(function() { setTimeout(function() { var currentuser = $('#currentuser').first().text().replace(/.*_/, ''); var match = /(mch|vubbranch|mia|common);v=([R,D,M][\d\.]+|MIA|MCH)\//g.exec(contentpath); if (!match) { return; } var mainBranch = match[2]; function updateButton2() { var form = $('#new_branch_form'); var val = form.find('input[name=name]').val(); if (val.length > 0 && val.match(/^[a-z0-9\.]+$/i)) { form.find('input[type=submit]').removeAttr("disabled"); } else { form.find('input[type=submit]').attr("disabled", "disabled"); } } $('#tabs-branches').prepend('<form id="new_branch_form"><div class="vcblock"><label>Nová privátna vetva</label>' + mainBranch + '.private.' + currentuser + '.<input size="30" name="name" type="text"><input type="submit" value="Vytvoriť" disabled="disabled"></div></form>'); $('#new_branch_form input[name=name]').keyup(function() {updateButton2()}); $('#new_branch_form').submit(function() { $('body').css('cursor', 'wait'); var form = $(this); form.find('input[type="submit"]').attr('disabled', 'disabled'); var name = form.find('input[name="name"]').val(); if (name == null || name.length == 0) { return; } name = mainBranch + '.private.' + currentuser + '.' + name; var path = 'https://' + location.hostname + '/' + contentpath; var urls = new Array(); urls.push(path); branch(urls, name, null, reloadPage, function() { var form = $('#new_branch_form'); form.find('input[type="submit"]').removeAttr('disabled'); $('body').css('cursor', 'auto'); }); return false; }); }, 1000); }); })();