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.

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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);
});