// ==UserScript== // @name 快速查包 // @namespace fsh // @version 6.5 // @description 快速跳转至指定包或指定分支 // @author xxtest // @match *://ci.meitu.city/* // @match *://omnibus.meitu-int.com/* // @match *://ios.meitu-int.com/ipa/* // @match *://jira.meitu.com/* // @match *://cf.meitu.com/* // @grant GM_xmlhttpRequest // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js // @homepage https://greasyfork.org/zh-CN/scripts/454567-%E5%BF%AB%E9%80%9F%E6%9F%A5%E5%8C%85 // @license MIT // @note 6.5 修复bug,解决鸿蒙和web平台影响版本判断问题 // @note 6.4 创建bug判断平台和影响版本是否一致 // @note 6.3 解决Jira获取分支,偶尔会填写错误的问题 // @note 6.2 解决iOS魔法屋跑图异常问题 // @note 6.1 解决跨年日期获取不到版本号问题 // @note 6.0 一键复制需求列表,增加容错 // @note 5.9 支持iOS跳转omnibus,调整omnibus展示 // @note 5.8 修复最近日期判断逻辑,minNum计算错误问题 // @note 5.7 修复版本日期格式变更,无法获取到最近版本的问题 // @note 5.6 一键复制进版需求bug修复 // @note 5.5 支持魔法屋跑图、支持jira创建/解决build跳转到omnibus平台、支持不同项目跳转 // @note 5.4 修改bug:支持请求头是appuid而不是mtxx平台的情况 // @note 5.3 临时修改,支持获取分支 // @note 5.2 cf中一键复制Android、iOS进版需求,Bug修复 // @note 5.1 新增步骤重置 // @note 5.0 针对格式不同的build ID进行适配 // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 设置刷新时间 const refreshTime = 1000; // 添加CSS $('head').append($(` `)); // 当是ci域名时,才触发后续的操作,如果不是则不触发 // CI // CI // CI if (location.href.indexOf('ci.meitu.city') > 0) { clearInterval(refreshTime); setInterval(function () { let input_find_build = document.getElementById('input_find_build'); let to_new_build = document.getElementById('to_new_build'); // 不存在输入框和跳转按钮则添加 if (!input_find_build) { addFindButtonCicity(); // 当用户按下键盘上的某个键时触发 document.addEventListener("keyup", function(event) { // 如果按下的是回车键 if (event.keyCode === 13) { // 触发按钮的点击事件 $('#btn_find_build').click(); } }); // 跳转按钮点击 $('#btn_find_build').unbind("click").click(function () { // 获取当前url, 用正则表达式获取项目名 let localUrl = window.location.href let project = '' let reg = /(?<=build\/)\w*/ project = localUrl.match(reg)[0] if(project != null){ let baseUrl = 'https://ci.meitu.city/build/' + project + '/' // 获取用户输入 let input_build_content = document.getElementById("input_find_build").value.trim() if(input_build_content===""){ return false; } let targetUrl = "" // 如果输入的是纯数字,视为build id if(/^\d+$/.test(input_build_content)){ targetUrl = baseUrl + 'number/' + input_build_content }else{// 否则按输入的是分支处理 input_build_content = input_build_content.replaceAll("/","%2F") targetUrl = baseUrl + 'branch/' + input_build_content } // 跳转到指定页面 window.location.href=targetUrl } else{ input_find_build.value = "未能正确获取项目名称" } }); } // 不存在跳转至最新按钮则添加 if(!to_new_build){ addToNewCicity(); $('.to_new_build').unbind("click").click(function(){ // 判断当前所处的页面, 用正则表达式获取项目名 let localUrl = window.location.href let project = '' let reg = /(?<=build\/)\w*/ project = localUrl.match(reg)[0] // 获取所要跳转的分支名 let full_build_name = this.parentNode.children[0].innerText.trim() let targetUrl = "" let baseUrl = 'https://ci.meitu.city/build/' + project + '/branch/' full_build_name = full_build_name.replaceAll("/","%2F") targetUrl = baseUrl + full_build_name // 跳转到指定页面 window.location.href=targetUrl }); } }, refreshTime); } if (location.href.indexOf('omnibus.meitu-int.com') > 0) { clearInterval(refreshTime); setInterval(function () { let input_find_build = document.getElementById('input_find_build'); let to_new_build = document.getElementById('to_new_build'); let input_last_build = document.getElementById('input_last_build'); let build_magichouse = document.getElementById('build_magichouse'); // 不存在输入框和跳转按钮则添加 if (!input_find_build) { addFindButtonOmnibus(); // 当用户按下键盘上的某个键时触发 document.addEventListener("keyup", function(event) { // 如果按下的是回车键 if (event.keyCode === 13) { // 触发按钮的点击事件 $('#btn_find_build').click(); } }); // 跳转按钮点击 $('#btn_find_build').unbind("click").click(function () { // 获取当前url, 用正则表达式获取项目名 let localUrl = window.location.href let project = '' let platform = '' let reg_platform = /:\/\/[^\/]+\/apps\/[^:]+:(\w+)/; let reg = /\/apps\/([^/:]+)/ project = localUrl.match(reg)[1] if(project != null){ console.log(project.length) let baseUrl = "" if (project.length<10){ // 适配iOS的情况 platform = localUrl.match(reg_platform)[1] console.log(platform) baseUrl = ' https://omnibus.meitu-int.com/apps/'+ project +':'+ platform +'/build' } else{ baseUrl = ' https://omnibus.meitu-int.com/apps/'+ project +'/build' } console.log(baseUrl) // 获取用户输入 let input_build_content = document.getElementById("input_find_build").value.trim() if(input_build_content===""){ return false; } let targetUrl = "" // 如果输入的是纯数字,视为build id if(/^\d+$/.test(input_build_content)){ targetUrl = baseUrl + '/number/' + input_build_content }else{// 否则按输入的是分支处理 input_build_content = input_build_content.replaceAll("/","%2F") targetUrl = baseUrl + '?branch=' + input_build_content } console.log(targetUrl) // 跳转到指定页面 window.location.href=targetUrl } else{ input_find_build.value = "未能正确获取项目名称" } }); } // 不存在跳转至最新按钮则添加 if(!to_new_build){ addToNewOmnibus(); $('.to_new_build').unbind("click").click(function(){ let localUrl = window.location.href // 项目名 let project = '' // 平台 let platform = '' let reg_platform = /:\/\/[^\/]+\/apps\/[^:]+:(\w+)/; let reg = /\/apps\/([^/:]+)/ project = localUrl.match(reg)[1] // 获取对应节点,因重复节点较多只能这么处理 let parent_node = this.parentNode.parentNode.parentNode let bracnh_span = parent_node.children[2].children[0].children[1].querySelector('span.el-link__inner') // 获取所要跳转的分支名 let full_build_name = bracnh_span.innerText.trim() if(project != null){ let baseUrl = "" // 区分通过appuid还是通过项目:平台 if (project.length<10){ // 适配iOS的情况,获取对应平台 platform = localUrl.match(reg_platform)[1] baseUrl = ' https://omnibus.meitu-int.com/apps/'+ project +':'+ platform +'/build?branch=' + full_build_name } else{ baseUrl = ' https://omnibus.meitu-int.com/apps/'+ project +'/build?branch=' + full_build_name } // 跳转到指定页面 window.location.href=baseUrl } }); } // 不存在魔法屋跑图按钮则添加 if(!build_magichouse){ addOmnibusMagichouse(); $('.build_magichouse').unbind("click").click(function(){ let buildIdB = document.getElementById("input_last_build").value.trim() if(buildIdB===""){ alert("请输入上个版本提交的build id"); return false; } let buildIdA = this.parentNode.parentNode.parentNode.children[0].children[0].children[0].innerText.trim() // 获取请求的URL let url = window.location.href //分割,获取平台(可能是mtxx:ios,也可能是aze3897z9xi8g3dzvw8ce6thc5) let path_url = url.split('/'); let platform = path_url.includes('apps') ? path_url[path_url.indexOf('apps') + 1] : null; if (confirm("确定构建魔法屋任务吗?点击确定构建")) { if (platform == "hydsriakywi7a4wtukhxh6zt6q" || platform.split(":")[1] =='android'){ buildMagichouseTask(2, buildIdA, buildIdB); } else if(platform == "aze3897z9xi8g3dzvw8ce6thc5" || platform.split(":")[1] =='ios'){ buildMagichouseTask(0, buildIdA, buildIdB); } else{ console.log(platform); alert("出现错误,请联系阿德"); } } }); } }, refreshTime); } var project_android_omnibus = {"美图秀秀":"mtxx","美颜相机":"beautycam", "美拍":"meipai","美妆相机":"makeup", "潮自拍":"selfiecity","设计室":"mtsjs", "wink":"wink","BeautyPlus":"beautyplus", "AirBrush":"airbrush","eve":"eve", "chic":"chic","美图宜肤V":"eveking", "EveNetAssist":"evenetassist","VChat":"vchatbeauty", "vcut":"vcut","Vmake":"beautyplusvideo", "PixEngine":"pixengine","智肤APP":"skinar", "美图秀秀Starii":"starii" } var appuid_android = {"美图秀秀":"hydsriakywi7a4wtukhxh6zt6q","美颜相机":"afpqgy5mqyiyejvj7tu5pvkb3s", "美拍":"a3cat9d2fnieu5ghyjr6uvysd7","美妆相机":"e69r7unz2bi2rm4d5hhmejunjt", "潮自拍":"au89qds8ipjnfmq6y36yxrwwqr","设计室":"e57ixjbvhjj3pkjtqbircekw4g", "wink":"a7wb9ngehrjhs5s6kbc8jhpmut","BeautyPlus":"b4ecchhcsgibw5kfamgxdr4z2f", "AirBrush":"ap6s3sujqjjze3nzd8e46sgwg8","eve":"bqn9z5twij9d3jqjgpg6dvws3", "chic":"ajbmhzdremjtk5nkx9eezbc2ps","美图宜肤V":"cprbcrdb58jwxjne7z5daitprd", "EveNetAssist":"epynw2drmbjyz5amwe4eirqm3f","VChat":"envi6ei33biw7kn9zi42t2yqm2", "PixEngine":"pixengine","智肤APP":"ecsgbwkuj5iffmjg3jzjq82ti4", "美图秀秀Starii":"enri33faz6ibwj5t7f9jpq4cvi" } var appuid_ios = {"美图秀秀":"aze3897z9xi8g3dzvw8ce6thc5","美颜相机":"cd2z8rxy5uic9iaz6dbjv8xhw6", "美拍":"e79mtyimnwixp46e6hvspus6v2","美妆相机":"ffp224ksztiqhi58ud7n33fvs2", "潮自拍":"etiv8nbxjpihni6cr9qhba4u3r","设计室":"gki88wa2nfiqxi7vhyf2xux6cw", "wink":"bhks37k3uaizn4yvcspt4j3nma","BeautyPlus":"eprvgz2kwujgvmyt7bvw92fae7", "AirBrush":"e8new3bg3eiximneygeizjyrn6","eve":"b3huanjy32ipcmhkq6cfnvvspp", "chic":"hfkv4chfbgj56kuphtpe656t6g","美图宜肤V":"dcjubb2t6ajvyjxaymkvtpp5az", "PixEngine":"pixengine","智肤APP":"ecsgbwkuj5iffmjg3jzjq82ti4", "美图秀秀Starii":"hmeb767rjnjh8i3vmy3rwmkxn7" } var project_ios_omnibus = {"美图秀秀":"mtxx","美颜相机":"beautycam", "美拍":"meipai","美妆相机":"makeup", "潮自拍":"selfiecity","设计室":"mtsjs", "wink":"wink","BeautyPlus":"beautyplus", "AirBrush":"airbrush","eve":"eve", "chic":"chic","美图宜肤V":"eveking", "EveNetAssist":"evenetassist","VChat":"vchatbeauty", "vcut":"vcut","Vmake":"beautyplusvideo", "PixEngine":"pixengine","智肤APP":"skinar", "美图秀秀Starii":"starii" } // omnibus页面,添加输入框和跳转按钮 function addFindButtonOmnibus() { let span = $('
') let input_find_build = $(''); let btn_find_build = $(''); span.append(input_find_build); span.append(btn_find_build); // jQuery不能直接插入,需要转一下格式,转成HTML才行 let spanHtml = span.prop('outerHTML'); // 获取第一个再插入; let firstDivWithTitleClass = document.querySelector('.is-plain'); firstDivWithTitleClass.insertAdjacentHTML('beforebegin', spanHtml); } // omnibus页面,添加跳转至最新按钮 function addToNewOmnibus(){ let to_new_build = $(''); $(".el-text--primary").after(to_new_build); } // omnibus页面,在其后方添加魔法屋跑图任务按钮 function addOmnibusMagichouse(){ let input_last_build = $(''); let build_magichouse = $(''); $(".to_new_build").after(build_magichouse); $(".to_new_build").after(input_last_build); } function buildMagichouseTask(osType, buildIdA, buildIdB){ let url = "http://mh-mng.meitu-int.com/xianyao/schedule/run/report"; let module_list = [2,3,4,5] for (var i = 0; i < module_list.length; i++) { var module = module_list[i] GM_xmlhttpRequest({ url: url, method: 'POST', headers: { "Content-Type": "application/json" }, data: JSON.stringify({ osType: osType, module: module, buildIdA: buildIdA, buildIdB: buildIdB, creator: "ydr@meitu.com" }), onload: function(res) { console.log(res) }, onerror: function(err) { result = '接口请求失败,建议重新关闭开启脚本再试试'; } }); } if (confirm("点击确定跳转魔法屋查看任务,如无任务联系阿德")) { window.open('https://magichouse.meitu-int.com/check/media/run/tasks', '_blank'); } } // CI页面,添加输入框和跳转按钮 function addFindButtonCicity() { let span = $('') let input_find_build = $(''); let btn_find_build = $(''); span.append(input_find_build); span.append(btn_find_build); $(".project-label__name").after(span); } // CI页面,在分支名后方添加跳转至最新按钮 function addToNewCicity(){ let to_new_build = $(''); $(".message-card__subtitle").after(to_new_build); } // 当是granary域名时,才触发后续的操作,如果不是则不触发 // Granary // Granary // Granary if (location.href.indexOf('ios.meitu-int.com') > 0) { clearInterval(refreshTime); setInterval(function () { let input_find_build = document.getElementById('input_find_build'); let to_new_build = document.getElementById('to_new_build'); let input_last_build = document.getElementById('input_last_build'); let build_magichouse = document.getElementById('build_magichouse'); // 项目名 var project = '' var reg = /(?<=ipa\/)\w*/ // 当前页面Url, 用正则表达式获取项目名 var localUrl = window.location.href project = localUrl.match(reg)[0] // 不存在输入框和跳转按钮则添加 if (!input_find_build) { addFindButtonGranary(); // 当用户按下键盘上的某个键时触发 document.addEventListener("keyup", function(event) { // 如果按下的是回车键 if (event.keyCode === 13) { // 触发按钮的点击事件 $('#btn_find_build').click(); } }); // 按钮绑定点击事件 $('#btn_find_build').unbind("click").click(function () { if(project != null){ // 获取用户输入 let input_build_content = document.getElementById("input_find_build").value.trim() if(input_build_content===""){ return false; } let targetUrl = "" // 如果输入的是纯数字,视为build id if(/^\d+$/.test(input_build_content)){ let baseUrl = 'http://ios.meitu-int.com/ipa/'+ project + '/build/' targetUrl = baseUrl + input_build_content }else{// 否则按分支处理 let baseUrl = 'http://ios.meitu-int.com/ipa/'+ project + '/' input_build_content = input_build_content.replaceAll("/","%2F") targetUrl = baseUrl + input_build_content } // 跳转到指定页面 window.location.href=targetUrl } else{ input_build_content.value = "未能正确获取项目名称" } }); } //不存在跳转至最新按钮则添加 if(!to_new_build){ addToNewGranary(); // 跳转按钮点击 $('.to_new_build').unbind("click").click(function(event){ // 分支名,去掉首尾的字符串,“/”转为“%2F” let parentNode = event.target.parentNode; let branchName = parentNode.querySelector("span.branch-name").innerText.trim() branchName = branchName.substring(1, branchName.length - 1).replaceAll("/","%2F"); // 跳转链接 let baseUrl = 'http://ios.meitu-int.com/ipa/'+ project + '/' let targetUrl = baseUrl + branchName // 跳转 window.location.href=targetUrl }); } if(!build_magichouse){ addGranaryMagichouse(); $('.build_magichouse').unbind("click").click(function(){ let buildIdB = document.getElementById("input_last_build").value.trim() if(buildIdB===""){ alert("请输入上个版本提交的build id"); return false; } let parentNode = event.target.parentNode.children[0].innerText.trim(); let buildIdA = parentNode.match(/#Build\s+(\d+)/)[1].trim(); if (confirm("确定构建魔法屋任务吗?点击确定构建")) { buildMagichouseTask(0, buildIdA, buildIdB) } }); } }, refreshTime); } // granary页面,添加输入框和跳转按钮 function addFindButtonGranary() { let span = $('') let input_find_build = $(''); let btn_find_build = $(''); span.append(input_find_build); span.append(btn_find_build); $("#myTab").append(span); } // granary页面,在分支名后方添加跳转至最新按钮 function addToNewGranary(){ let to_new_build = $(''); $("div#list-home span.branch-name").after(to_new_build); } // granary页面,在其他后方添加魔法屋跑图任务按钮 function addGranaryMagichouse(){ let input_last_build = $(''); let build_magichouse = $(''); $(".to_new_build").after(build_magichouse); $(".to_new_build").after(input_last_build); } // 当是jira域名时,才触发后续的操作,如果不是则不触发 // Jira // Jira // Jira if (location.href.indexOf('jira.meitu.com') > 0) { clearInterval(refreshTime); var counter = 0; // 定时器循环操作:页面元素添加等 setInterval(function () { var search_span = document.getElementById('search_span_create'); // 因为切至iOS按钮和切至Android按钮一般都会成对出现,所以这里只获取iOS按钮,用于判断按钮是否已存在 var change_side_button = document.getElementById('change_side_ios'); var create_input = document.getElementById('customfield_10303'); var step_text = document.getElementById('customfield_10203'); var create_issue_dialog = document.getElementById('create-issue-dialog'); var close_bug_dialog = document.getElementById('workflow-transition-21-dialog'); var reopen_bug_dialog = document.getElementById('workflow-transition-31-dialog'); var comment_bug_toolbar = document.getElementById('wiki-edit-wikiEdit0'); // 如果不存在bug跳转按钮则添加一个,需要判断url是bug页面而不是bug列表页,否则会报错 if (!search_span) { addButtonJira(); // 存储bug平台 GM_setValue('platform', $('#customfield_10301-val').text().trim()) } // 在创建问题dialog添加获取分支按钮组 if (create_issue_dialog){ // 加个计时避免按钮显示不出来 // Bug模版按钮 if(change_side_button == undefined || change_side_button.length == 0){ addChangeSideButton(); } // 获取分支按钮 if(create_input !== undefined || create_input.length !== 0){ var branch_span = $(''); $("#customfield_10303").after(branch_span) add_get_branch_btn($(branch_span)); } // 重置步骤按钮 if(step_text !== undefined || step_text.length !== 0){ var step_span = $(''); $("#customfield_10203").after(step_span); var step_btn = $(''); step_span.append(step_btn) } // 隐藏starii项目不必要的UI hideUI(); // 自动填充build号 fillBuildIdAuto(); } // 自动往指定的input组件中填build号 function fillBuildIdAuto(){ // 获取输入框内容 var inputContent = $("#customfield_10303").val(); // 使用正则表达式检查当前文本内容是否是纯数字 var isCurrentNumber = /^\d+$/.test(inputContent); if (isCurrentNumber) { counter++; console.log(counter) // 如果当前文本内容是纯数字 if (counter % 6 === 0) { // 往输入框内填写 set_branch('get_branch_btn','create-issue-dialog') counter = 0; } } } // 在关闭问题dialog 或 重新打开dialog 添加获取分支按钮组 if (close_bug_dialog || reopen_bug_dialog) { var pre_text_button = $(''); var pre_text_btn = document.getElementById('close-text'); var branch_span_close = $('输入id:'); var input_text_close = $(''); setTimeout(function () { if (!pre_text_btn) { $(".jira-dialog-content .form-footer").append(branch_span_close).append(input_text_close);// buildid输入框 add_get_branch_btn($(".jira-dialog-content").find(".form-footer"));//获取分支按钮 $(".jira-dialog-content .form-footer").append(pre_text_button);//上次填写按钮 } }, 500); } // 在备注窗口添加获取分支按钮组 if (comment_bug_toolbar) { var pre_text_span = $('输入id:'); var pre_text_span_element = document.getElementById('pre_text'); var input_text = $(''); setTimeout(function () { if (!pre_text_span_element && !close_bug_dialog) { var branch_span = $(''); branch_span.append(pre_text_span).append(input_text); add_get_branch_btn($(branch_span)); $(".security-level .current-level").after(branch_span); } }, 500); } // 获取分支按钮点击事件 $('#get_branch_btn, #last_branch_btn').unbind("click").click(function(event) { setTimeout(function () { // 当前节点的父节点 var parentNode = event.target.parentNode; // 如果父节点没有Id属性,则往上遍历 while (parentNode != null) { if (parentNode.hasAttribute("id")) { // 找到第一个有id属性的父节点 var parentWithId = parentNode; break; } parentNode = parentNode.parentNode; } // 第一个拥有Id的父节点的id let parentId = parentWithId.getAttribute("id"); // 获取当前节点id var selfId = event.target.id // 往网页中填入分支名 set_branch(selfId, parentId); },500); }); // 重置步骤按钮点击事件 $('#reset_step').unbind('click').click(function(event){ let default_text = '[预置条件]\n\n[步骤]\n\n[结果]\n\n[期望]\n\n[备注机型]\n\n[BUG出现频次]\n\n\n' document.getElementById('customfield_10203').value = default_text; }) function hideUI(){ // 获取具有id为project-options的div元素 var projectOptionsDiv = document.getElementById('project-options'); if(projectOptionsDiv){ // 获取data-suggestions属性的值 var dataSuggestionsValue = projectOptionsDiv.getAttribute('data-suggestions'); var jsonObject = JSON.parse(dataSuggestionsValue); // 项目名 var project = jsonObject[0]['items'][0].label.trim(); var project_name = project.replace(/\s*\([^)]*\)\s*/, '').trim(); }else{ var project_name = $('#project-name-val').text().trim(); // 项目名 } if(project_name === "美图秀秀Starii"){ hideParentNodeById("customfield_10422"); hideParentNodeById("customfield_10202"); hideParentNodeById("customfield_10305"); hideParentNodeById("customfield_11100"); hideParentNodeById("customfield_11101"); hideParentNodeById("customfield_11102"); hideParentNodeById("customfield_10304"); hideParentNodeById("fixVersions"); hideParentNodeById("reporter"); hideParentNodeById("customfield_13601"); } } // 隐藏指定ID节点的父节点 function hideParentNodeById(childNodeId){ // 隐藏bug优先级 var element = document.getElementById(childNodeId); // 检查是否找到了元素 if (element) { // 获取父节点并将其样式的display属性设置为"none" element.parentNode.style.display = "none"; } } // 往网页中填入分支名称 async function set_branch(selfId, parentId) { if (selfId === "get_branch_btn") { switch (parentId) { // 创建Bug窗口填写分支 case "create-issue-dialog": // bug平台节点和buildId节点 var $platform = $('input:radio[name="customfield_10301"]:checked'); var $buildId = $('#customfield_10303'); // 通过buildId节点(input)定位到bug平台节点(label) var id = $platform.attr("id") var label = document.querySelector("label[for='" + id + "']"); // bug平台和buildId try { var platform = label.textContent; } catch (error) { GM_setValue('branch_value', "#请先选择Bug平台"); fillInBranch('#customfield_10303'); return; } var buildId = $buildId.val(); if (buildId === undefined || buildId === ''||buildId === null) { GM_setValue('branch_value', "#请先填写Build号"); fillInBranch('#customfield_10303'); return; } console.log(platform) // 获取分支名 await get_branch(platform, buildId); // 填入分支 await fillInBranch('#customfield_10303'); counter = 0; break; // 关闭||重新打开窗口填写分支 case "issue-workflow-transition": var $platform = $('#customfield_10301-val'); var $buildId = $('#build_id_close'); // bug平台和buildId var platform = $platform.text().trim(); var buildId = $buildId.val(); // 获取分支名 await get_branch(platform, buildId); // 填入分支 await fillInBranchTextarea('div#comment-wiki-edit textarea#comment'); // 聚焦到输入框 sleep(500).then(() => { $('#comment-wiki-edit textarea').focus(); }) break; // 备注 case "issue-comment-add": var $platform = $('#customfield_10301-val'); var $buildId = $('#input_text'); // bug平台和buildId var platform = $platform.text().trim(); var buildId = $buildId.val(); // 获取分支名 await get_branch(platform, buildId); // 填入分支 await fillInBranchTextarea('div#comment-wiki-edit textarea#comment'); // 聚焦到输入框 sleep(500).then(() => { $('#comment-wiki-edit textarea').focus(); }) break; default: } } else if (selfId === "last_branch_btn") { switch (parentId) { case "create-issue-dialog": // 填入分支 await fillInBranch('#customfield_10303'); break; case "issue-workflow-transition": // 填入分支 await fillInBranchTextarea('div#comment-wiki-edit textarea#comment'); break; // 备注 case "issue-comment-add": await fillInBranchTextarea('div#comment-wiki-edit textarea#comment'); break; default: } } } // 跳转到创建分支 $('#search_span_create').unbind("click").click(function () { var build_id = getBuildId("customfield_10303-val"); console.log(build_id) // 存储bug平台 GM_setValue('platform', $('#customfield_10301-val').text().trim()) sleep(500).then(() => { var targetUrl = getBaseUrl() + build_id; window.open(targetUrl); }) }); // 跳转到解决分支 $('#search_span_solved').unbind("click").click(function () { var build_id = getBuildId("customfield_10304-val"); // 存储bug平台 GM_setValue('platform', $('#customfield_10301-val').text().trim()) sleep(500).then(() => { var targetUrl = getBaseUrl() + build_id; window.open(targetUrl); }) }); // 切换到iOS bug模版 $('.ios').unbind("click").click(function () { changeBugPlatform('iOS') }); // 切换到Androidbug模版 $('.android').unbind("click").click(function () { changeBugPlatform('Android') }); // 切换到Webbug模版 $('.web').unbind("click").click(function () { changeBugPlatform('Web') }); // 点击关闭问题按钮,记录下填写的内容 var text_area = $('.jira-dialog-content').find('#comment') $('#issue-workflow-transition-submit').unbind("click").click(function(){ if($('#issue-workflow-transition-submit').val().trim()=="关闭问题"){ // 存储bug平台 GM_setValue('closeText',text_area.val().trim()) } }) // 点击上次填写按钮,填充上次填写的内容 $('#close-text').unbind("click").click(function(){ text_area.val(GM_getValue('closeText')) text_area.focus() }) // TODO:点击「创建」按钮时记录下所有的bug信息 const $createBtn = $('#create-issue-submit'); const $summary = $('#summary'); const $business = $('input:radio[name="customfield_12903"]:checked'); const $platform = $('input:radio[name="customfield_10301"]:checked'); const $path0 = $("#selectCFLevel0 option:selected"); const $path1 = $("#selectCFLevel1 option:selected"); const $assignee = $("#assignee-field"); const $severity = $("#customfield_10406 option:selected"); const $version = $("#versions-multi-select .value-text"); const $find = $("#customfield_10202 option:selected"); const $frequency = $("#customfield_10204 option:selected"); const $branch = $("#customfield_10303"); const $step = $("#customfield_10203"); const $tips = $("#labels-multi-select .representation .value-text"); $createBtn.unbind('click').click(function() { const bugDict = { 'summary': $summary.val(), 'business': $business.attr("id"), 'platform': $platform.attr("id"), 'path0': $path0.text(), 'path1': $path1.text(), 'assignee': $assignee.val(), 'severity': $severity.text(), 'version': $version.text(), 'find': $find.attr("value"), 'frequency': $frequency.attr("value"), 'branch': $branch.val(), 'step': $step.val(), 'tips': $tips.text() }; GM_setValue('bugDict', bugDict); }); // 点击再提一个 // 已知问题:1. 路径2无法填写 $('#once-again').unbind('click').click(function() { const bugDict = GM_getValue('bugDict'); function setValue(selector, value) { $(selector).val(value); } function setChecked(selector, value) { $(selector).attr("checked", value); } function setSelected(selector, value) { $(selector).find(`option[value='${value}']`).attr("selected", true); } console.log(bugDict); setValue("#summary", bugDict.summary); setChecked(`input[id=${bugDict.business}]`, true); setChecked(`input[id=${bugDict.platform}]`, true); setValue("#selectCFLevel0", bugDict.path0); setValue("#selectCFLevel1", bugDict.path1); setValue("#assignee-field", bugDict.assignee); // $('#assignee').append($(' 元素 let optgroup = $('.aui-field-versionspicker').find('.multi-select-select').find('[label="未发布版本"]')[0] // 获取