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.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @version      2.0.0
// @author       Nmaster64
// @namespace    http://twitter.com/nmaster64
// @match        https://*.rainwave.cc/*
// @exclude      /rainwave.cc/(forums|pages|api)/
// @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
// ==/UserScript==

// Helper Functions
var rwAddStyles = function(css) {
    var rwStyle = document.createElement('style');
    rwStyle.textContent = css.join("\n");
    document.head.appendChild(rwStyle);
}
var rwReady = function(cb) {
    if(document.readyState == "complete" || document.readyState == "loaded") {
        cb();
    } else {
        window.addEventListener("load", cb, false);
    }
};

// Style Updates
rwAddStyles([
    'body.full div.panel.requests.pinned { transform:translateX(-100%) !important; background: rgba(38, 39, 42, .9); }',
    'body.full div.panel.requests.pinned ul.request_icons li { visibility:visible; opacity:.5; }',
    'body.full div.panel.requests > div.close { display:block !important; }',
    'body.full div.panel.requests > div.close > img { display:none; }',
    'body.full div.panel.requests > div.close > img.pin  { display:block !important; }',
    'body.full div.panel.requests.pinned > div.close > img { display:block; }',
    'body.full div.panel.requests.pinned > div.close > img.pin {  display:none !important; }',
]);

// Pin Button
rwReady(function() {
    var requestsPane = document.querySelector('body.full div.panel.requests');
    var closeBtn = requestsPane.querySelector('div.close');

    var pinImg = document.createElement('img');
    pinImg.setAttribute('class', 'pin');
    pinImg.setAttribute('src', 'https://rainwave.cc/static/images4/request_pause.png');
    closeBtn.appendChild(pinImg);

    closeBtn.addEventListener('click', function(e) {
        requestsPane.classList.toggle('pinned');
    }, false);
});