_ Modao-Add-Pin

墨刀菜单active定位居中!

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         _ Modao-Add-Pin
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  墨刀菜单active定位居中!
// @author       You
// @match        https://modao.cc/app/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=modao.cc
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    function run(wrapper){
        wrapper.style.overflow = 'unset';
        document.querySelector('.rn-list-item.active').scrollIntoView({ behavior: "instant", block:'center', inline: "nearest" })
        wrapper.style.overflow = 'hidden';
    }
    function createDom(wrapper){
        // 创建一个新的 button 元素
        var button = document.createElement('button');

        // 设置按钮的文本内容为 "Pin"
        button.textContent = 'Pin';

        // 可以添加一些内联样式,例如:
        button.style.width = '32px';
        button.style.height = '32px';
        button.style.backgroundColor = '#1684fc';
        button.style.color = 'white';
        button.style.border = 'none';
        button.style.cursor = 'pointer';
        //button.style.position = 'fixed';
        //button.style.left = '332px';
        //button.style.top = '230px';
        button.style.zIndex = '999';

        // 或者添加一个样式类
        button.className = 'pin-button';

        // 绑定一个事件
        button.addEventListener('click',function(){
            run(wrapper)
        })
        return button
    }
    var itv = setInterval(()=>{
        if(document.querySelector('#workspace').children.length>0){
            clearInterval(itv)
            const wrapper = document.querySelector('.preview-content-container')
            setTimeout(()=>{
                run(wrapper)

                const btnDom = createDom(wrapper)

                // 先copy个分割线,加进去
                const lineDom = document.querySelector('.wrapper-padding').cloneNode()
                document.querySelector('#preview-setting-list div.wrapper').appendChild(lineDom);
                // 将按钮添加到页面的 body 元素中
                document.querySelector('#preview-setting-list div.wrapper').appendChild(btnDom);
            },200)
        }
    },500)
})();