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.

  1. // ==UserScript==
  2. // @version 2.0.0
  3. // @author Nmaster64
  4. // @namespace http://twitter.com/nmaster64
  5. // @match https://*.rainwave.cc/*
  6. // @exclude /rainwave.cc/(forums|pages|api)/
  7. // @name Rainwave v5: Pin Request Pane
  8. // @description Adds a pin/close button to the top-right of the requests pane. Pane stays fully open w/o hovering when pinned.
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. // Helper Functions
  13. var rwAddStyles = function(css) {
  14. var rwStyle = document.createElement('style');
  15. rwStyle.textContent = css.join("\n");
  16. document.head.appendChild(rwStyle);
  17. }
  18. var rwReady = function(cb) {
  19. if(document.readyState == "complete" || document.readyState == "loaded") {
  20. cb();
  21. } else {
  22. window.addEventListener("load", cb, false);
  23. }
  24. };
  25.  
  26. // Style Updates
  27. rwAddStyles([
  28. 'body.full div.panel.requests.pinned { transform:translateX(-100%) !important; background: rgba(38, 39, 42, .9); }',
  29. 'body.full div.panel.requests.pinned ul.request_icons li { visibility:visible; opacity:.5; }',
  30. 'body.full div.panel.requests > div.close { display:block !important; }',
  31. 'body.full div.panel.requests > div.close > img { display:none; }',
  32. 'body.full div.panel.requests > div.close > img.pin { display:block !important; }',
  33. 'body.full div.panel.requests.pinned > div.close > img { display:block; }',
  34. 'body.full div.panel.requests.pinned > div.close > img.pin { display:none !important; }',
  35. ]);
  36.  
  37. // Pin Button
  38. rwReady(function() {
  39. var requestsPane = document.querySelector('body.full div.panel.requests');
  40. var closeBtn = requestsPane.querySelector('div.close');
  41.  
  42. var pinImg = document.createElement('img');
  43. pinImg.setAttribute('class', 'pin');
  44. pinImg.setAttribute('src', 'https://rainwave.cc/static/images4/request_pause.png');
  45. closeBtn.appendChild(pinImg);
  46.  
  47. closeBtn.addEventListener('click', function(e) {
  48. requestsPane.classList.toggle('pinned');
  49. }, false);
  50. });