Banderi / Furaffinity Beta Layout Tweaks

// ==UserScript==
// @name          Furaffinity Beta Layout Tweaks
// @namespace     http://userstyles.org
// @description    Tweaks and fixes a few minor dumb layout choices here and there.
// @author        Federico Barlotti
// @match        *://*.furaffinity.net/*
// @run-at        document-start
// @version       0.3
// @license MIT
// @copyright 2020, Banderi (https://openuserjs.org/users/Banderi)
// ==/UserScript==
(function () {
  var css = "";
  if (false || (new RegExp("^(http|https)://(www.)?furaffinity\\.net/.*$")).test(document.location.href))
    css += [
      "html, body {",
      "    background-color: #454556;",
      "  }",
      "  #site-content {",
      "    margin: 10px;",
      "    padding: 10px;",
      "    -border: solid 2px black;",
      "    background-color: #25262e;",
      "  }",
      "  #responsebox {",
      "    max-width: 90%;",
      "  }",
      "  #news, .generic-message-block {",
      "    background-color: #25262e;",
      "    font-size: 16px;",
      "  }",
      "  #footer {",
      "    background-color: rgba(0, 0, 0, 0.58)!important;",
      "    box-shadow: none;",
      "  }",
      "  .comment_container .footer {",
      "    padding-top: 0px;",
      "    margin-right: 4px;",
      "  }",
      "  .comment_container .base {",
      "    position: relative;",
      "    padding-bottom: 10px;",
      "  }",
      "  .footer {",
      "    position: absolute;",
      "    top: 30px;",
      "    right: 5px;",
      "    font-size: 15px;",
      "  }",
      "  #pageid-submission .comment_container .replyto_link {",
      "    padding-right: 7px;",
      "  }",
      "  .edit_link, .replyto_link {",
      "    padding: 0px 7px 4px;",
      "    background-color: #0000002b;",
      "  }",
      "  .messagecenter-mail-content-pane {",
      "    display: flex;",
      "  }",
      "  .messagecenter-mail-note-preview-pane {",
      "    display: flex;",
      "    flex-direction: column-reverse;",
      "    justify-content: flex-end;",
      "  }",
      "  .messagecenter-mail-list-pane {",
      "    max-height: initial;",
      "  }",
      "  .notification-container {",
      "    margin-left: 10px;",
      "  }",
      "  .notification-container > strong {",
      "    margin-left: 03px;",
      "    color: #ffffff69;",
      "  }",
      "  .journal-body-theme {",
      "    background-color: #3c3c4a!important;",
      "  }",
      "  .journal-header, .journal-footer {",
      "    font-size: 14px;",
      "  }",
      "  section, .stats-page, .fa-plus-benefit-item {",
      "    border: 1px solid #69697d52;",
      "  }",
      "  section.gallery figcaption {",
      "    font-size: 15px;",
      "  }",
      "  section.gallery figure>figcaption p, section.gallery b figcaption p {",
      "    font-size: 12px;",
      "  }",
      "  section.gallery.with-checkboxes figcaption>label>p {",
      "    font-size: 15px;",
      "    line-height: 18px;",
      "    white-space: nowrap;",
      "    text-overflow: ellipsis;",
      "  }",
      "  div#messagecenter-other #messages-watches ul.message-stream div.info {",
      "    text-align: center;",
      "    margin-top: 0px;",
      "  }",
      "  div#messagecenter-other #messages-watches ul.message-stream div.info span {",
      "    font-size: 16px;",
      "    font-weight: 500;",
      "  }",
      "  div#messagecenter-other #messages-watches ul.message-stream div.info small span {",
      "    font-size: 12px;",
      "  }",
      "  div#messagecenter-other #messages-watches ul.message-stream li td.avatar {",
      "    padding: 0px;",
      "  }",
      "  div#messagecenter-other #messages-watches ul.message-stream li {",
      "    margin: 0 0 0px;",
      "  }",
      "  div#messagecenter-other #messages-watches ul.message-stream li input {",
      "    display: none;",
      "    left: -40px;",
      "    position: relative;",
      "  }",
      "  h2 {",
      "    font-size: 18px;",
      "  }",
      "  h3 {",
      "    font-size: 16px;",
      "  }",
      "  .comment_container .base h3 {",
      "    font-size: 18px;",
      "  }",
      "  #page-userpage .userpage-section-right, #page-userpage .userpage-section-left {",
      "    border: 1px solid #424750;",
      "  }",
      "  #columnpage .preview-gallery.navgallery {",
      "    flex-flow: nowrap;",
      "    margin-bottom: 5px;",
      "    background-color: #ffffff0f;",
      "  }",
      "  #columnpage .preview-gallery-container.navgallery {",
      "    overflow: unset;",
      "    align-items: center;",
      "  }",
      "  #columnpage .preview-gallery-image.navgallery {",
      "    max-height: 120px;",
      "    max-width: 100px;",
      "    min-height: unset;",
      "    min-width: unset;",
      "    border: solid 1px #ffffff1f;",
      "    border-radius: 2px;",
      "  }"
    ].join("\n");
  if (typeof GM_addStyle != "undefined") {
    GM_addStyle(css);
  }
  else if (typeof PRO_addStyle != "undefined") {
    PRO_addStyle(css);
  }
  else if (typeof addStyle != "undefined") {
    addStyle(css);
  }
  else {
    var node = document.createElement("style");
    node.type = "text/css";
    node.appendChild(document.createTextNode(css));
    var heads = document.getElementsByTagName("head");
    if (heads.length > 0) {
      heads[0].appendChild(node);
    }
    else {
      // no head yet, stick it whereever
      document.documentElement.appendChild(node);
    }

    docReady(function () {
      var n = document.querySelectorAll(".notification-container");
      var m = n.length / 2;
      for (let i = 0; i < m; i++) {
        n[i + m].innerHTML = n[i].innerHTML;
      }
      //n[3].innerHTML = n[0].innerHTML; n[4].innerHTML = n[1].innerHTML; n[5].innerHTML = n[2].innerHTML;

      var j = document.querySelector(".preview-gallery");
      j.insertAdjacentElement("afterend", j.cloneNode(true));
      j.addClassName("navgallery");
      var k = Array.from(j.children);
      var l = Number(window.location.href.match(/\d+/)[0]);
      var ind = 6;
      k.forEach(function (item, i) {
        let p = Number(item.children[0].href.match(/\d+/)[0]);
        if (l > p && ind == 6) {
          ind = i;
        }
      });
      for (let i = 0; i < 4; i++) {
        if (i < (ind - 1) && ind > 1) {
          j.removeChild(j.children[0]);
        }
        else {
          j.removeChild(j.children[2]);
        }
      }
      j.children[0].addClassName("navgallery");
      j.children[0].children[0].children[0].addClassName("navgallery");
      j.children[1].addClassName("navgallery");
      j.children[1].children[0].children[0].addClassName("navgallery");

      if (ind == 0)
        j.children[0].insertAdjacentHTML("beforebegin", '<div class="preview-gallery-container navgallery">prev &gt;</div>');
      else if (ind > 0 && ind < 6)
        j.children[0].insertAdjacentHTML("afterend", '<div class="preview-gallery-container navgallery">&lt; next <br>prev &gt;</div>');
      else
        j.children[1].insertAdjacentHTML("afterend", '<div class="preview-gallery-container navgallery">&lt; next</div>');

    });
  }
})();

function docReady(fn) {
  // see if DOM is already available
  if (document.readyState === "complete" || document.readyState === "interactive") {
    // call on next available tick
    setTimeout(fn, 1);
  }
  else {
    document.addEventListener("DOMContentLoaded", fn);
  }
}