Rainwave v5: Pin Request Pane

Adds a pin/close button to the top-right of the requests pane. Pane stays fully open w/o hovering when pinned.

As of 2015-12-28. See the latest version.

// ==UserScript==
// @version      1.0.1
// @author       Nmaster64
// @namespace    http://twitter.com/nmaster64
// @match        http://*.rainwave.cc/*
// @name         Rainwave v5: Pin Request Pane
// @description  Adds a pin/close button to the top-right of the requests pane. Pane stays fully open w/o hovering when pinned.
// @grant        none
// @require      https://code.jquery.com/jquery.min.js
// ==/UserScript==

jQuery(document).ready(function($) {
    
    function addGlobalStyle(css) {
        var stylesId = 'tm-custom-styles';
        if($('#'+stylesId).length < 1) {
            $('<style>').attr('id', stylesId).attr('type', 'text/css').html('').appendTo($('head'));
        }
        $('#'+stylesId).append(css);
    }
    
    addGlobalStyle('body.full div.panel.requests.pinned { transform:translateX(-100%) !important; }');
    addGlobalStyle('body.full div.panel.requests.pinned ul.request_icons li { visibility:visible !important; opacity:.5; }');
    
    addGlobalStyle('body.full div.panel.requests > div.close:first-child { display:block !important; }');
    addGlobalStyle('body.full div.panel.requests > div.close:first-child > img.close { display:none; }');
    addGlobalStyle('body.full div.panel.requests > div.close:first-child > img.pin { display:block; }');
    addGlobalStyle('body.full div.panel.requests.pinned > div.close:first-child > img.close { display:block; }');
    addGlobalStyle('body.full div.panel.requests.pinned > div.close:first-child > img.pin {  display:none; }');
    
    var $close = $('body.full div.panel.requests > div.close:first-child');
    $close.find('img').addClass('close').clone().attr('src', 'http://i.imgur.com/waouJLl.png').attr('class', 'pin').appendTo($close);
    $close.off().click(function() {
        $('body.full div.panel.requests').toggleClass('pinned');
    });
    
});