V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
YiPeng0505
V2EX  ›  分享发现

突发奇想,让 chatpgt 写了个 V2EX 内容居中的油猴小工具

  •  
  •   YiPeng0505 · 322 天前 · 850 次点击
    这是一个创建于 322 天前的主题,其中的信息可能已经有所发展或是发生改变。
    用笔记本逛 V2EX 的时候老是得稍微扭一下脖子,有那么些许不得劲,于是:

    👨‍💻:请写一个油猴脚本,屏蔽 https://www.v2ex.com/ 网站内的<div id = “Rightbar”></div> 里的内容,并且让<div id = “Main”></div> 里的内容居中显示

    💻:
    // ==UserScript==
    // @name Hide V2EX right bar and center main content
    // @namespace v2ex-hide-rightbar-center-content
    // @description Hide the right bar and center main content on V2EX website.
    // @version 1
    // @grant none
    // @match https://www.v2ex.com/*
    // ==/UserScript==

    (function() {
    'use strict';

    // Hide the right bar
    var rightBar = document.querySelector('#Rightbar');
    if (rightBar) {
    rightBar.style.display = 'none';
    }

    // Center the main content
    var mainContent = document.querySelector('#Main');
    if (mainContent) {
    mainContent.style.margin = '0 auto';
    mainContent.style.maxWidth = '1000px'; // Optional: limit the maximum width of center content
    }
    })();
    2 条回复    2023-06-08 22:50:38 +08:00
    autoxbc
        1
    autoxbc  
       322 天前
    这届 GPT 不行啊,应该写成 CSS 然后用 GM_addStyle 加载
    itlaohui
        2
    itlaohui  
       320 天前
    改成 css 是这样?

    #Rightbar {
    display: none;
    }

    #Main {
    margin: 0 auto;
    max-width: 1000px;
    }
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1151 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 18:23 · PVG 02:23 · LAX 11:23 · JFK 14:23
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.