墨刀菜单active定位居中!
当前为
// ==UserScript==
// @name modao-pin
// @namespace http://tampermonkey.net/
// @version 2024-07-11-3
// @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';
var itv = setInterval(()=>{
if(document.querySelector('#workspace').children.length>0){
setTimeout(()=>{
document.querySelector('.rn-list-item.active').scrollIntoView({ behavior: "smooth", block:'center' })
// 创建一个新的 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 = '220px';
// 或者添加一个样式类
button.className = 'pin-button';
// 绑定一个事件
button.addEventListener('click',function(){
document.querySelector('.rn-list-item.active').scrollIntoView({ behavior: "smooth", block:'center' })
})
// 将按钮添加到页面的 body 元素中
document.body.appendChild(button);
},500)
clearInterval(itv)
}
},500)
})();