百家号AI优化助手

优化掉百家号首页遮挡收益的AI助手页面,并修改特定元素的样式

目前為 2024-08-28 提交的版本,檢視 最新版本

// ==UserScript==
// @name         百家号AI优化助手
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  优化掉百家号首页遮挡收益的AI助手页面,并修改特定元素的样式
// @author       @诸葛
// @license      MIT
// @match        https://baijiahao.baidu.com/*
// @match        https://baijiahao.baidu.com/builder/rc/home
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

    function hideAICopilot() {
        const element = document.getElementById("AICopilot");
        if (element) {
            element.style.display = "none";
        }
    }

    function modifyMarginRight() {
        const targetElement = document.querySelector('.cheetah-row.cheetah-public.css-11lc5sr');
        if (targetElement) {
            targetElement.style.marginRight = '-500px';
        }
    }

    hideAICopilot();
    modifyMarginRight();

    const intervalID = setInterval(() => {
        hideAICopilot();
        modifyMarginRight();
    }, 1000);

    setTimeout(() => {
        clearInterval(intervalID);
    }, 10000);

})();