我目前正在为我的本地路由器制作一个深色主题,它使用的图像很糟糕,我想替换它们,但它们是用 JavaScript 添加的,经过大量研究 Tampermonkey/Greasemonkey 和 Stylish,我找不到任何方式来做到这一点。
我唯一的想法是用另一个图像替换文件名 wan_up.png 的图像。
我目前正在为我的本地路由器制作一个深色主题,它使用的图像很糟糕,我想替换它们,但它们是用 JavaScript 添加的,经过大量研究 Tampermonkey/Greasemonkey 和 Stylish,我找不到任何方式来做到这一点。
我唯一的想法是用另一个图像替换文件名 wan_up.png 的图像。
#your-selector-here {
height: 0 !important;
width: 0 !important;
/* these numbers match the new image's dimensions */
padding-left: 32px !important;
padding-top: 32px !important;
background: url(http://example.com/your/image/here) no-repeat !important;
background-size: 32px 32px; /* modern CSS property to scale the new image */
}
MutationObserver 有很多包装器,下面是一个基于setMutationHandler的示例:
// ==UserScript==//
// @name Replace image
// @match http://192.168.0.1/*
// @run-at document-start
// @require https://greasyfork.org/scripts/12228/code/setMutationHandler.js
// ==/UserScript==
setMutationHandler({
processExisting: true,
selector: 'img[src*="wan_up"]',
handler: images => images.forEach(img => {
img.src = 'http://foo/bar.png';
})
});
编辑 @match 中的 URL,要替换的图像的选择器,相应的新图像 URL。