Jira Hide unused bulk edit fields

Hide fields from Bulk Edit screen that are not usually bulk edited

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name          Jira Hide unused bulk edit fields
// @namespace     randomecho.com
// @description   Hide fields from Bulk Edit screen that are not usually bulk edited
// @include       https://*.atlassian.net/secure/views/bulkedit/BulkChooseOperation!default.jspa
// @include       */secure/views/bulkedit/BulkChooseOperation!default.jspa
// @include       https://*.atlassian.net/secure/views/bulkedit/BulkEditDetails.jspa
// @include       */secure/views/bulkedit/BulkEditDetails.jspa
// @grant         none
// @copyright     2017 Soon Van
// @author        Soon Van - randomecho.com
// @license       http://opensource.org/licenses/BSD-3-Clause
// @version       1.0
// ==/UserScript==

// Pre-selects the Edit Issues option on the Step 2 of 4 page before Operation Details
var bulkEditOptionOfPage2 = document.getElementById('bulk.edit.operation.name_id');
if (bulkEditOptionOfPage2) {
  bulkEditOptionOfPage2.checked = true;
}

function hideCustomFields() {
  var customFields = document.getElementsByClassName('checkbox');

  for (var i in customFields) {
    if (customFields[i].getAttribute('id').indexOf('cbcustomfield_') !== -1) {
        customFields[i].parentNode.parentNode.style.display = 'none';
    }
  }
}

function hideStandardFields() {
  var hideAwayFields = [
    'cbassignee',
    'cbcomment',
    'cbduedate',
    'cbenvironment',
    'cbissuetype',
    'cbpriority',
    'cbreporter',
    'cbversions',
  ];

  for (var i in hideAwayFields) {
    var fieldName = document.getElementById(hideAwayFields[i]);

    if (fieldName) {
      fieldName.parentNode.parentNode.style.display = 'none';
    }
  }
}

function hideUnusedTextFields() {
  var textField = document.getElementById('versions-textarea');

  if (textField) {
    textField.parentNode.parentNode.style.display = 'none';
  }
}

function hideUnusedFields() {
  hideStandardFields();

  setTimeout(function() {hideUnusedTextFields()}, 2000);

  hideCustomFields();
}

window.onload = hideUnusedFields();