Skip to content

Instantly share code, notes, and snippets.

@oobleck
Last active August 29, 2015 14:02
Show Gist options
  • Save oobleck/c3dafe79c7acb8fbebd5 to your computer and use it in GitHub Desktop.
Save oobleck/c3dafe79c7acb8fbebd5 to your computer and use it in GitHub Desktop.
Bugzilla enhancements
// ==UserScript==
// @name Bugzilla Enhancements
// @namespace https://github.com/oobleck
// @version 0.0.4
// @updateURL https://gist.github.com/oobleck/c3dafe79c7acb8fbebd5
// @downloadURL https://gist.github.com/oobleck/c3dafe79c7acb8fbebd5/raw/bugzilla-enhancements.user.js
// @description Enhances bugzilla. Several fixes that were sadly lost when Userscripts.org went belly up.
// @match *://*/bugzilla/*
// @copyright 2014+, Spencer Rhodes
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
// ==/UserScript==
(function() {
'use strict';
var _BMI = {};
// Show inline attachments where applicable
var $attachments = $('#attachment_table a[href*="attachment.cgi?id="');
var $rows = $('table.bz_buglist');
var styles = '\
#comment {font-size: 1.1rem;}\
.bz_button { background: linear-gradient(#fff, #eee); border-radius: 3px; border: #666 1px solid; padding: 0.4em 0.6em; line-height: 1; display: inline-block;}\
.bz_description {position: relative; background: rgba(0,0,255,0.10); border: 1px solid blue; margin: 1.5rem 0 0.5rem; border-radius: 0.55em; box-shadow: 0 0 10px 0 rgba(0,0,0,0.25)}\
.bz_description:before {content: "Description"; position: absolute; display: block; margin-top: -2rem; font-size: 1rem; font-weight: bold;}\
#bugzilla-body {max-width: 55rem; margin: 1em auto;}\
.bz_bugitem > :first-child {text-align: left; border-right: 0.7em solid transparent;}\
.bz_critical > :first-child {background: rgba(255,0,0,0.25); color: red;}\
.bz_major > :first-child {background: rgba(255,200,0,0.5); color: inherit;}\
.bz_normal > :first-child {background: rgba(0,255,0,0.5); color: white;}\
.bz_enhancement > :first-child {background: rgba(160,0,160,0.25);}\
.bz_minor > :first-child {background: rgba(0,0,200,0.1); color: white;}\
.bz_High > :first-child {border-right-color: rgba(255,0,0,0.5);}\
.bz_Normal > :first-child {border-right-color: rgba(0,150,0,0.25);}\
.bz_Low > :first-child {border-right-color: rgba(0,0,180,0.1);}\
';
var $styles = $('<style id="bmi-bz-styles"></style>');
$styles.html(styles);
$attachments.each(function(i, el) {
var $el = $(el);
var meta = $el.next('.bz_attach_extra_info');
if (!/(action=edit)/.test(el.href) && /(jp?g|gif|png)/.test(meta.text())) {
var linkText = $el.text();
var href = el.href;
$el
.attr('target', '_blank')
.html('<img src="'+href+'" style="width:100%;max-width:500px" title="'+linkText+'"/><br>'+linkText);
}
});
$('a[id*="action"]').addClass('bz_button');
$('a[href*="show_bug"]:contains("Description")').parents('.bz_comment').addClass('bz_description');
$('head').append($styles);
// End inline attachment display
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment