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

查看 184|回复 11
作者:cookie0402   
解决啦,用油猴插件,在脚本的 @match 添加要执行的网站就可以了,谢谢各位大哥。
解决啦,用油猴插件,在脚本的 @match 添加要执行的网站就可以了,谢谢各位大哥。
cookie0402
OP
  
写了脚本,但是每次都得手动去控制台运行
fengci   
你说的不就是 油猴子 嘛
chuhades   
油猴。
flysp   
我自己的百度屏蔽规则
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
OP
  
@flysp 也是用的油猴吗,我刚刚下载了油猴,发现添加的脚本一直没运行,是啥原因
cookie0402
OP
  
@flysp 这个是我的代码(function() {
'use strict';
// Your code here...
var doe = document.getElementById("content_right")
doe.style.display = 'none'
console.log("qidong")
})();
pipaseqin   
这是隐藏知乎标题的,供参考下。
```
// ==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   
用 adblock 插件更容易实现,针对性屏蔽页面元素
yhxx   
这个需求甚至可以直接用 stylebot 之类的改一下 css 就行了
您需要登录后才可以回帖 登录 | 立即注册

返回顶部