YiPeng0505

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

  •  
  •   YiPeng0505 · Jun 6, 2023 · 1821 views
    This topic created in 1106 days ago, the information mentioned may be changed or developed.
    用笔记本逛 V2EX 的时候老是得稍微扭一下脖子,有那么些许不得劲,于是:

    👨‍💻:请写一个油猴脚本,屏蔽 https://v2ex.xtra.eu.org/ 网站内的<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://v2ex.xtra.eu.org/*
    // ==/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 replies    2023-06-08 22:50:38 +08:00
    autoxbc
        1
    autoxbc  
       Jun 6, 2023
    这届 GPT 不行啊,应该写成 CSS 然后用 GM_addStyle 加载
    itlaohui
        2
    itlaohui  
       Jun 8, 2023
    改成 css 是这样?

    #Rightbar {
    display: none;
    }

    #Main {
    margin: 0 auto;
    max-width: 1000px;
    }
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3380 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 51ms · UTC 10:57 · PVG 18:57 · LAX 03:57 · JFK 06:57
    ♥ Do have faith in what you're doing.