简陋的 居中 页面 对齐 按钮

居中 页面 按钮 简陋的 center page web button rough

当前为 2019-10-25 提交的版本,查看 最新版本

// ==UserScript==
// @name         简陋的 居中 页面 对齐 按钮
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description   居中 页面 按钮 简陋的 center page web button rough
// @author        批小将
// @match         *://*/*
// @grant         none
// ==/UserScript==

(function() {
    'use strict';
    let btn = document.createElement('button');
    btn.style.cssText = 'position: fixed; right: 0; top: 0; padding: 10px; border: 1px solid black; z-index: 10000';
    let textnode = document.createTextNode('center');
    btn.appendChild(textnode);
    let body = document.getElementsByTagName('body')[0];
    body.prepend(btn);

    btn.addEventListener('click', function(){
        let centercss = 'width: fit-content; margin: 0 auto; max-width: 1000px;';
        body.setAttribute('style', centercss);
    });
})();

QingJ © 2025

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