Greasy Fork is available in English.
站点优化
// ==UserScript==
// @name 自用:代码随想录站点优化
// @namespace http://tampermonkey.net/
// @version 0.3
// @description 站点优化
// @author You
// @match https://programmercarl.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=programmercarl.com
// @grant none
// ==/UserScript==
// Get all elements with the class "option-box"
function removeElementByImageSource(src) {
const element = document.querySelector(`img[src="${src}"]`);
if (element) {
element.remove();
} else {
console.log(`未找到匹配的图片元素,src: ${src}`);
}
}
const optionBoxes = document.querySelectorAll('.option-box');
optionBoxes.forEach((optionBox) => {
const text = optionBox.textContent.trim();
if (text !== "侧边栏" && text.indexOf("一篇") === -1) {
optionBox.remove();
} else {
optionBox.style.opacity = 0.4;
}
});
removeElementByImageSource('/assets/img/训练营.5fb0409d.png');
removeElementByImageSource('/assets/img/网站星球宣传海报.dcf08b7f.jpg');