rearrange-O-Don

more useful space in Mastodon

目前为 2023-06-06 提交的版本。查看 最新版本

// ==UserScript==
// @name         rearrange-O-Don
// @license      DWTFYW
// @namespace    http://pureandapplied.com.au/composeToFirstColumn
// @version      0.1.1
// @description  more useful space in Mastodon
// @author       stib
// @match        https://*.social/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=aus.social
// @run-at       document-ready
// @grant        none
// ==/UserScript==

(function() {
    // Identify the source and destination containers using appropriate selectors
    let elementList = [
        // listed in reverse order, bcs they get inserted at the top each time
        'form.compose-form',
        'div.navigation-bar',
        'div.search',
        'nav.drawer__header',
    ];
    window.addEventListener('load', reorganiseODon);

    function reorganiseODon(){
        // first column is the target for where we're moving stuff
        let destinationContainer = document.querySelector('div.column');

        if (destinationContainer){
            console.log("hacking the Mastodon UI to make things more compact");
            for (let i = 0; i < elementList.length; i++){
                let fc = destinationContainer.firstChild;
                console.log(fc);
                let src = document.querySelector(elementList[i]);
                if (src && fc) {
                    // remove superfluous padding
                    src.style.paddingLeft = 0;
                    src.style.paddingRight = 0;
                    // move to the destination column
                    destinationContainer.insertBefore(src, fc);
                }
            }
        }
        //hide the empty column
        let origColumn = document.querySelector('div.drawer');
        origColumn.style.display = 'none';
        //give a little bit of space to the first column
        destinationContainer.style.paddingLeft = "10px";
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址