// ==UserScript== // @name gitlab duplicate button // @description a simply tool to rapidly duplicate pipeline schedule // @match https://gitlab.com/*/pipeline_schedules* // @match https://*.gitlab.com/*/pipeline_schedules* // @grant GM_log // @author FrogChopi // @version 1 // @run-at document-end // @license GNU // @namespace https://greasyfork.org/users/1445314 // @downloadURL https://update.greasyfork.icu/scripts/529726/gitlab%20duplicate%20button.user.js // @updateURL https://update.greasyfork.icu/scripts/529726/gitlab%20duplicate%20button.meta.js // ==/UserScript== !async function(){"use strict";let e=document.createElement("style");e.innerText="\n .modal {\n position: fixed;\n top: 0;\n left: 0;\n z-index: 1050;\n width: 100%;\n height: 100%;\n overflow: hidden;\n outline: 0;\n background-color: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .modal-dialog {\n position: relative;\n width: auto;\n margin: 0.5rem;\n pointer-events: none;\n max-width: 500px;\n }\n\n .modal-content {\n position: relative;\n display: flex;\n flex-direction: column;\n width: 100%;\n pointer-events: auto;\n background-color: #fff;\n background-clip: padding-box;\n border: 1px solid rgba(0, 0, 0, 0.2);\n border-radius: 0.3rem;\n outline: 0;\n }\n\n .modal-header {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n padding: 1rem;\n border-bottom: 1px solid #dee2e6;\n border-top-left-radius: 0.3rem;\n border-top-right-radius: 0.3rem;\n }\n\n .modal-title {\n margin-bottom: 0;\n line-height: 1.5;\n font-size: 1.25rem;\n }\n\n .close {\n float: right;\n font-size: 1.5rem;\n font-weight: 700;\n line-height: 1;\n color: #000;\n text-shadow: 0 1px 0 #fff;\n opacity: .5;\n padding: 1rem;\n margin: -1rem -1rem -1rem auto;\n background-color: transparent;\n border: 0;\n }\n\n .modal-body {\n position: relative;\n flex: 1 1 auto;\n padding: 1rem;\n }\n\n .modal-footer {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: flex-end;\n padding: 0.75rem;\n border-top: 1px solid #dee2e6;\n border-bottom-right-radius: 0.3rem;\n border-bottom-left-radius: 0.3rem;\n }\n ",document.head.appendChild(e);let n=async function(e,n,t,o,a){return new Promise(((i,l)=>{let d={method:e,headers:o,credentials:"same-origin"};a&&(d.body=JSON.stringify(a)),fetch(`https://${n}${t}`,d).then((e=>e.json())).then((e=>{i(e)})).catch((e=>l(e)))}))};var t;await(t='a[data-testid="edit-pipeline-schedule-btn"]',new Promise((e=>{const o=new MutationObserver((a=>{document.querySelector(t)&&(document.querySelectorAll('a[data-testid="edit-pipeline-schedule-btn"]').forEach((e=>{let t=e.href.match(/(\d+)$/)[1];var o=document.createElement("BUTTON"),a=document.createElement("IMG");o.className="btn btn-default btn-md gl-button btn-icon",a.className="gl-button-icon gl-icon s16 gl-fill-current",a.src="https://cdn-icons-png.flaticon.com/512/1621/1621635.png",o.appendChild(a),o.id=t,o.title="Duplicate scheduled pipeline",o.ariaLabel="Duplicate scheduled pipeline",o.onclick=async()=>{let e=await n("GET",document.location.host,`/api/v4/projects/${+document.body.getAttribute("data-project-id")}/pipeline_schedules/${t}`,{"Content-Type":"application/json"},void 0),o=document.createElement("DIV");o.innerHTML=`\n