大家没事的时候老是会来L站摸鱼,刷帖子
奈何有的话题标题是在是太骚,想看但是看的时候title处老是显示着那骚气的标题,非常不利于摸鱼人和i人
ps:因为同事没事会路过,万一不小心看到了,那我的名声算是毁于一旦了。所以配合着chagpt弄了个油猴脚本去除了观看具体话题时候的标题
(本人主后端,前端一坨屎,求各位前端大佬放过)脚本可能会有bug,有前端大佬可以的话可以帮忙优化一下
js脚本已修正,刚开始拷贝错版本了,match有问题
end:我最终用的是上面这个脚本(最开始发帖时候粘错代码了,尴尬,第二个刚开始有问题,目前应该也行,我这边没有实验过,如果不行就请使用上面这个js脚本)
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 2024-07-17
// @description try to take over the world!
// @author You
// @match https://linux.do/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant GM.xmlHttpRequest
// @grant GM_addStyle
// ==/UserScript==
(function() {
'use strict';
// 选择器可以根据实际情况调整
const selector = '.header-title';
// 创建一个 MutationObserver 实例
const observer = new MutationObserver(function(mutationsList, observer) {
for (let mutation of mutationsList) {
if (mutation.type === 'childList' || mutation.type === 'subtree') {
const element = document.querySelector(selector);
if (element) {
element.style.display = 'none'; // 隐藏元素
}
}
}
});
// 配置 MutationObserver 监听的目标节点及选项
const config = { childList: true, subtree: true };
// 监听整个文档的变化
observer.observe(document.body, config);
// 初始检查一次
const initialElement = document.querySelector(selector);
if (initialElement) {
initialElement.style.display = 'none';
}
})();
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 2024-07-17
// @description try to take over the world!
// @author You
// @match https://linux.do/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
(function() {
'use strict';
const scriptContent = `
(function() {
const selector = '.header-title';
const observer = new MutationObserver(function(mutationsList, observer) {
for (let mutation of mutationsList) {
if (mutation.type === 'childList' || mutation.type === 'subtree') {
const element = document.querySelector(selector);
if (element) {
element.style.display = 'none';
}
}
}
});
const config = { childList: true, subtree: true };
observer.observe(document.body, config);
const initialElement = document.querySelector(selector);
if (initialElement) {
initialElement.style.display = 'none';
}
})();
`;
const script = document.createElement('script');
script.textContent = scriptContent;
document.body.appendChild(script);
})();