Greasy Fork

JIRA Cloud

Re-theming script for JIRA Cloud

目前为 2022-03-10 提交的版本。查看 最新版本

// ==UserScript==
// @name         JIRA Cloud
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  Re-theming script for JIRA Cloud
// @author       You
// @match        https://*.atlassian.net/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=atlassian.net
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    var css = document.createElement('style');
    css.type = 'text/css';
    css.name = "custom-css";
    css.innerHTML = `

html, html body#jira {
    background-color: #eee;
}
body .cWzlMc, body .css-zvta6n, body .jsSCtF,
body .cSnBhI, body .kCUjSv, body .kZKcTI {
    background-color: #eee;
}

body .izWGlW {
    background-color: #fff;
}

body .dgbPQn {
    background-color: #fff;
    margin: 24px 12px 32px 24px;
    border-radius: 4px;
    border: solid 1px #ccc;
}

body .bzpsgq {
    overflow: visible;
    width: calc(100% - 720px);
}

body .kfVduZ {
    width: auto;
    overflow: visible;
}

body .ihzd {
    display: none;
}

body .yjkY {
    min-width: 0;
}

body .dgMUBn {
    display: inline-block;
    position: absolute;
}

body .bzpsgq {
    padding-left: 0;
}

body .klZhqF {
    padding: 0;
}

body .kZKcTI      /* ticket icon container (above fields widget) */
{
    float: right;
    margin: 0;
    padding: 0;
}

body .kZKcTI > div > div > div
{
    margin: 0;
}

body .kZKcTI button .css-1ncnk3i,    /* ticket icon (above fields widget) */
body .kZKcTI button .css-1ncnk3i > svg    /* SVG for ticket icons (above fields widget) */
{
    width: 16px;
    height: 16px;
}

body .hlFJLM /* Collapsed custom fields widget's content */
{
    max-width: 20ex;
}

body .jkTZZQ    /* widget content frame */
{
    padding-bottom: 4px;
}

/*******************************************
**********     Confluence     **************
********************************************/

body .kkPmar,    /* page header frame */
body .e1vqopgf0    /* page content frame */
{
    margin: 0 0 0 0;
    max-width: none;
}

body .rAVIf    /* floating table header */
{
    display: none;
}

/******************************************
********        editor      ***************
*******************************************/

.wcw-edit-container {
    margin: 16px 0;
}
.wcw-editor {
    width: 100%;
    height: 10em;
    border: solid 1px #eee;
    border-radius: 4px;
}
`;
    document.getElementsByTagName('head')[0].appendChild(css);

    // Add Mark-up Editor
    jQuery(document).onLoad(
    setTimeout(function(){
        var ticket = jQuery('#jira-issue-header .css-47yo1b .css-1we84oz').text();

        console.log(ticket);
        jQuery('.czMqAP').append(`<button class="wcw-old css-1y6dd5y"> Mark-up Editor </button>`);
        jQuery('.wcw-old').on('click', function(){
            jQuery('.mEYYF, .dHydut').parent().html(`<div class="wcw-edit-container"><textarea class="wcw-editor"></textarea><button class="wcw-edit-submit css-1y6dd5y">Add</button></div>`);
            jQuery('.wcw-edit-submit').on('click', function(){
                jQuery.ajax({
                    type: 'POST',
                    url: '../rest/api/2/issue/'+ticket+'/comment',
                    data: JSON.stringify({body: jQuery('.wcw-editor').val()}),
                    contentType: "application/json",
                    dataType: "json",
                    success:  function(){
                        location.reload();
                    }
                });
            });
        });
    }, 1000));


})();