Greasy Fork

Greasy Fork is available in English.

Better Gallections

Do horizontal folders bother you? What about those huge titles and wasted space?

目前为 2024-01-19 提交的版本,查看 最新版本

// ==UserScript==
// @name        Better Gallections
// @version     2.4.5
// @description Do horizontal folders bother you? What about those huge titles and wasted space?
// @author      Valognir (https://www.deviantart.com/valognir)
// @namespace   http://greasyfork.icu/en/scripts/404189-better-gallections
// @grant       GM_addStyle
// @run-at      document-start
// @match       https://www.deviantart.com/*
// ==/UserScript==


let css = `
    [data-hook="gallection_folder"], #sub-folder-gallery {
        display: inline-block !important;
        vertical-align: top !important;
    }

    [data-hook="gallection_folder"] {
        overflow-y: scroll !important;
        scrollbar-width: thin !important;
        scrollbar-color: rgba(155, 155, 155, 0.5) transparent !important;
        height: calc(100vh - 600px) !important;
        position: sticky !important;
        top: 150px !important;
        margin-right: 30px !important;
        margin-top: 5px !important;
        padding-bottom: 400px !important;
    }

    ::-webkit-scrollbar {
        width: 5px !important;
    }

    ::-webkit-scrollbar-track {
        background: transparent !important;
    }
    ::-webkit-scrollbar-thumb {
        background-color: rgba(155, 155, 155, 0.5) !important;
        border: transparent !important;
    }

    [data-hook="gallection_folder"]>div {
        display: block !important;
        height: auto !important;
    }

    [data-hook="gallection_folder"]>div>section {
        margin-bottom: 10px !important;
    }

    [data-hook="gallection_folder"]>button {
        display: none !important;
    }

    [data-hook^="gallection_folder_"] {
        padding: 0 !important;
    }

    [data-hook^="gallection_folder_"]>div:first-child,
    [data-hook^="gallection_folder_"]>div:first-child>div>div[style],
    [data-hook^="gallection_folder_"]>div:first-child>div>div[style]>img{
        width: 248px !important;
        height: 209px !important;
    }

    [data-hook^="gallection_folder_"]>div:last-child{
        position: absolute !important;
        padding: 0 !important;
        margin-top: -54px !important;
        height: 54px !important;
        width: 248px !important;
        background-color: none !important;
    }

    [data-hook^="gallection_folder_"]>div:last-child>div{
        margin: 0 !important;
        padding: 5px !important;
    }

    .theme-dark [data-hook^="gallection_folder_"]>div:last-child>div{
        background: #161A1F !important;
    }

    .theme-light [data-hook^="gallection_folder_"]>div:last-child>div{
        background: #fff !important;
    }

    .light-green [data-hook^="gallection_folder_"]>div:last-child>div{
        background: #E7EDE4 !important;
    }

    #sub-folder-gallery {
        width: 100% !important;
        min-height: 100vh !important;
    }

    [data-hook="gallection_folder"]+div:not(#sub-folder-gallery)+div {
        display: inline-block !important;
        vertical-align: top !important;
        margin-top: 12px !important;
        width: calc(100% - 310px) !important;
        min-height: 100vh !important;
    }

    [data-hook="gallection_folder"]+div:not(#sub-folder-gallery) {
        position: absolute !important;
        width: 100% !important;
        left: 350px !important;
        top: 460px !important;
    }

    #sub-folder-gallery>div:first-child>div:first-child>div:first-child>div:first-child     {
        margin-top: -1px !important;
    }

    /* sub galleries */
    #sub-folder-gallery>div:first-child>div:first-child>div:first-child>div:nth-child(2) >div:nth-child(2)>div>div {
        height: 120px !Important;
        width: 100% !Important;
    }

    #sub-folder-gallery>div:first-child>div:first-child>div:first-child>div:nth-child(2) >div:nth-child(2)>div>div>div:first-child,
    #sub-folder-gallery>div:first-child>div:first-child>div:first-child>div:nth-child(2) >div:nth-child(2)>div>div>div:first-child>div:first-child,
    #sub-folder-gallery>div:first-child>div:first-child>div:first-child>div:nth-child(2) >div:nth-child(2)>div>div>div:first-child>div:first-child>img {
        height: 100px !Important;
        width: 140px !Important;
    }

    #sub-folder-gallery>div:first-child>div:first-child>div:first-child>div:nth-child(2) >div:nth-child(2)>div>div>div:first-child {
        width: 140px !important;
        justify-content: center !important;
        margin-top: 10px !important;
        margin-bottom: 0 !important;
    }

    #sub-folder-gallery>div:first-child>div:first-child>div:first-child>div:nth-child(2) >div:nth-child(2)>div>div>div:first-child>div+div {
        display:none !important;
    }

    #sub-folder-gallery>div:first-child>div:first-child>div:first-child>div:nth-child(2) >div:nth-child(2)>div>div>div:last-child {
        width: 140px !important;
        justify-content: center !important;
        margin-top: -120px !important;
    }
`;

  let styleNode = document.createElement("style");
  styleNode.appendChild(document.createTextNode(css));
  (document.querySelector("head") || document.documentElement).appendChild(styleNode);

window.addEventListener('DOMContentLoaded', (event) => {
    var folders = document.querySelectorAll('[data-hook="gallection_folder"] section>a');

    Object.entries(folders).map(( object ) => {
        object[1].addEventListener("click", function() {
            window.scrollTo(0, 400);
        });
    });
});