Bugzilla - reveal the Depends and Blocks bug titles

It reveals the the Depends and Blocks bug titles via a keyboard shortcut

Від 30.11.2015. Дивіться остання версія.

// ==UserScript==
// @name        Bugzilla - reveal the Depends and Blocks bug titles
// @namespace   darkred
// @description It reveals the the Depends and Blocks bug titles via a keyboard shortcut
// @include     https://bugzilla.mozilla.org/show_bug.cgi?id=*
// @version     1
// @grant       none
// @require     http://code.jquery.com/jquery-2.1.4.min.js
// @require     https://cdnjs.cloudflare.com/ajax/libs/keypress/2.1.3/keypress.min.js
// ==/UserScript==



var flag = 1;

var listener = new window.keypress.Listener();


listener.simple_combo('`', function() {
    console.log('You pressed `');
    if (flag === 1) {
        flag = 0;
        var depends = $('#dependson_input_area').siblings();
        var blocks = $('#blocked_input_area').siblings();
        var combined = [].concat(Array.prototype.slice.call(depends), Array.prototype.slice.call(blocks));

        for (var i = 0; i < combined.length; i++) {
            combined[i].innerHTML = '(' + combined[i].innerHTML + ')  ' + combined[i].title;
            combined[i].outerHTML += '<br/>';
        }

    } else {

        var regex = /^https:\/\/bugzilla\.mozilla\.org\/show_bug\.cgi\?id=(.*)$/;
        console.log('You pressed ~');

        var depends = $('#dependson_input_area').siblings();
        var blocks = $('#blocked_input_area').siblings();
        var combined = [].concat(Array.prototype.slice.call(depends), Array.prototype.slice.call(blocks));

        if (flag === 0) {
            flag = 1;
            for (var i = 0; i < combined.length; i += 2) {
                combined[i].innerHTML = combined[i].href.match(regex)[1];
            }

            for (var i = (combined.length) - 1; i => 0; i -= 2) {
                // if (typeof(combined[i]) !== 'undefined' ){
                combined[i].remove();
                // }
            }
        }
    }

});