如何使用TampermonKey删除这些特定的HTML元素?

发布于 2025-02-02 13:15:39 字数 694 浏览 2 评论 0 原文

好的,因此出于某种原因,YouTube做出了一些愚蠢的设计决策。问题在于,由于某种原因,他们已经做到了,以便掩盖上传日期并查​​看计数的按钮,如您在此处看到的:

我想自己修复它们。所以我所做的是使用“检查元素”删除每个按钮旁边的文本:

“在此处输入图像描述”

我认为这看起来更好。但是我不知道如何使这个永久性。我当时正在考虑使用Tampermonkey,但是我没有任何运气,因为我不知道如何为Tampermonkey编码或如何使用jQuery。

在这里,我标记了要删除的元素:

Ok, so for some reason youtube has made some dumb design decisions. The problem is that for some reason they have made it so that the like, dislike, share, etc. buttons cover up the upload date and view count as you can see here:

enter image description here(this is most likely cause the latvian words are longer than the english words but still)

I wanted to fix them for myself. So what I did was I used inspect element to remove the text next to each button:

enter image description here

In my opinion this looks way better. But I have no idea how I could make this permanent. I was thinking of using tampermonkey but I didnt have any luck with that just cause I have no idea how to code for tampermonkey or how to use jquery.

Here I have marked the elements i would like to remove:
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深爱成瘾 2025-02-09 13:15:39

如果您具有CSS的能力,则应该可以根据需要调整以下代码。只需将以下代码块复制到新的TM脚本(下面的步骤)。

// ==UserScript==
// @name         YouTube button fixer
// @namespace    http://tampermonkey.net/
// @match        https://youtube.com/*
// @grant        none
// ==/UserScript==


(function() {
    'use strict';

    document.querySelectorAll('#actions #top-level-buttons-computed .ytd-menu-renderer').forEach((el, i) => {
        el.querySelector('#text').style.display = 'block';
    });

}

使用下面答案中的说明“安装”上述脚本:

If you have some ability with CSS, you should be able to tweak the below code to work as you need. Just copy/paste the below code block into a new TM script (steps below).

// ==UserScript==
// @name         YouTube button fixer
// @namespace    http://tampermonkey.net/
// @match        https://youtube.com/*
// @grant        none
// ==/UserScript==


(function() {
    'use strict';

    document.querySelectorAll('#actions #top-level-buttons-computed .ytd-menu-renderer').forEach((el, i) => {
        el.querySelector('#text').style.display = 'block';
    });

}

Use the instructions in below answer to "install" the above script:

DuckDuckGo API - How to get more results?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文