V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
cookie0402
V2EX  ›  问与答

有没有什么办法能每次进入某个网页就执行对应脚本的,想把百度搜索页的热搜隐藏了

  •  
  •   cookie0402 · 33 天前 · 724 次点击
    这是一个创建于 33 天前的主题,其中的信息可能已经有所发展或是发生改变。
    第 1 条附言  ·  33 天前
    解决啦,用油猴插件,在脚本的 @match 添加要执行的网站就可以了,谢谢各位大哥。
    11 条回复    2024-08-14 16:39:46 +08:00
    cookie0402
        1
    cookie0402  
    OP
       33 天前
    写了脚本,但是每次都得手动去控制台运行
    fengci
        2
    fengci  
       33 天前
    你说的不就是 油猴子 嘛
    chuhades
        3
    chuhades  
       33 天前
    油猴。
    flysp
        4
    flysp  
       33 天前
    我自己的百度屏蔽规则

    baidu.com##div[class="result-op xpath-log"]
    baidu.com##div[id="content_right"]
    baidu.com###content_right
    baidu.com##.cr-offset
    baidu.com##.title-content.c-link.c-font-medium.c-line-clamp1
    baidu.com##.title-text.c-font-medium.c-color-t
    baidu.com##.s-hotsearch-title
    baidu.com##.tieba-custom-pass-login
    baidu.com##div[class="result-op xpath-log"]
    baidu.com##div[id="content_right"]
    baidu.com###content_right
    baidu.com##.cr-offset
    baidu.com##.title-content.c-link.c-font-medium.c-line-clamp1
    baidu.com##.title-text.c-font-medium.c-color-t
    baidu.com##.s-hotsearch-title
    baidu.com##.tieba-custom-pass-login
    baidu.com##div[class="s-isindex-wrap"]
    cookie0402
        5
    cookie0402  
    OP
       33 天前
    @flysp 也是用的油猴吗,我刚刚下载了油猴,发现添加的脚本一直没运行,是啥原因
    cookie0402
        6
    cookie0402  
    OP
       33 天前
    @flysp 这个是我的代码(function() {
    'use strict';

    // Your code here...
    var doe = document.getElementById("content_right")
    doe.style.display = 'none'
    console.log("qidong")
    })();
    pipaseqin
        7
    pipaseqin  
       33 天前
    这是隐藏知乎标题的,供参考下。

    ```
    // ==UserScript==
    // @name ZhiHu
    // @namespace http://tampermonkey.net/
    // @version 2024-08-14
    // @description try to take over the world!
    // @author You
    // @match https://www.zhihu.com/question/*
    // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
    // @grant none
    // @require https://code.jquery.com/jquery-3.7.1.min.js
    // ==/UserScript==
    /* globals jQuery, $, waitForKeyElements */

    (function() {
    'use strict';
    $(window).scroll(function() {
    if($('.QuestionHeader-title').length) {
    $('.QuestionHeader-title').css('display', 'none');
    }
    });
    })();
    ```
    Mechanical
        8
    Mechanical  
       33 天前
    用 adblock 插件更容易实现,针对性屏蔽页面元素
    yhxx
        9
    yhxx  
       33 天前
    这个需求甚至可以直接用 stylebot 之类的改一下 css 就行了
    cookie0402
        10
    cookie0402  
    OP
       33 天前
    @Mechanical 这个好像要收费
    flysp
        11
    flysp  
       33 天前
    @cookie0402 用的 Adblock 插件,配置 F12 查看页面元素,可以自定义屏蔽很多广告
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   953 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 19:42 · PVG 03:42 · LAX 12:42 · JFK 15:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.