redmine_tweaks

better style for redmine

目前為 2023-06-01 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name           redmine_tweaks
// @namespace      https://greasyfork.org/de/users/157797-lual
// @match          http*://*.redmine.tiss.tuwien.ac.at/*
// @version        1.0
// @description	   better style for redmine
// @author         lual
// @grant GM_addStyle
// @grant GM_getResourceURL
// @icon           https://icons.duckduckgo.com/ip2/www.redmine.org.ico
// @licence        CC-BY-NC-SA-4.0
// ==/UserScript==
// changes:        2011-03-17 initial
//                 2017-11-01 publish on greasyfork
//                 2020-09-29 kommentare optisch besser voneinander abtrennen
//                 2020-10-16 update auf redmine 4.1.1
//                 2022-11-10 convert deprecated @include to @match
//                 2023-06-01 make textareas bigger / add script icon / add licence / publish
/////////////////////////////////////////////////////////////////////////////////////////////////////////
var Util = {
  log: function () {
    var args = [].slice.call(arguments);
    args.unshift('%c' + SCRIPT_NAME + ':', 'font-weight: bold;color: purple;');
    console.log.apply(console, args);
  },
  storeGet: function(key) {
    if (typeof GM_getValue === "undefined") {
      var value = localStorage.getItem(key);
      if (value === "true" || value === "false") {
        return (value === "true") ? true : false;
      }
      return value;
    }
    return GM_getValue(key);
  },
  storeSet: function(key, value) {
    if (typeof GM_setValue === "undefined") {
      return localStorage.setItem(key, value);
    }
    return GM_setValue(key, value);
  },
  storeDel: function(key) {
    if (typeof GM_deleteValue === "undefined") {
      return localStorage.removeItem(key);
    }
    return GM_deleteValue(key);
  },
  //moves an item in an array - (given arr will be altered!)
  move: function(arr, old_index, new_index) {
      while (old_index < 0) {
          old_index += arr.length;
      }
      while (new_index < 0) {
          new_index += arr.length;
      }
      if (new_index >= arr.length) {
          let k = new_index - arr.length;
          while ((k--) + 1) {
              arr.push(undefined);
          }
      }
       arr.splice(new_index, 0, arr.splice(old_index, 1)[0]);
     return arr;
  }
};

var SCRIPT_NAME = 'redmine_tweaks';

Util.log('started');

//schoen farbig wird der code mit <pre><code class="ruby">der code</code></pre>
//  aber die zeilennummer sind stoerend....
// GM_addStyle(".syntaxhl .line-numbers {visibility: hidden;}");

//private tasks in der uebersicht als solche markieren...
GM_addStyle("div.journal.private-notes .wiki:before {content: 'PRIVAT';    background-clip: border-box;    background-color: #DD2222;    background-image: none;    background-origin: padding-box;    background-position: 0 0;    background-repeat: repeat;    background-size: auto auto;    border-bottom-left-radius: 2px;    border-bottom-right-radius: 2px;    border-top-left-radius: 2px;    border-top-right-radius: 2px; color: #FFFFFF;  font-size: 60%;    font-weight: bold;    margin-right: 2px;   padding-bottom: 0px;    padding-left: 2px;    padding-right: 2px;    padding-top: 2px;    position: relative;    text-transform: uppercase;}");

//kommentare optisch besser voneinander abtrennen...
GM_addStyle(".journal.has-notes { padding-top: 10px; border-top-width: 2px;border-top-color: ##3d454c; border-top-style: solid;}");
GM_addStyle("#history { border-bottom-width: 2px;border-bottom-style: solid; border-bottom-color: ##3d454c;}");

window.onload = function(){

    var textareas = document.querySelectorAll('textarea#issue_description, textarea#issue_notes, textarea#wiki-edit');

    for (const ta of textareas) {
        var rows_used = ta.value.split(/\r\n|\r|\n/).length;
        ta.rows = Math.max(ta.rows, rows_used, '40');
        Util.log(ta.id, ' rows: ', ta.rows);
    }

};