[英]How do I change all images with the name x.png with x.png with Tampermonkey or Stylish?
I'm currently making a dark theme for my local router, the images it uses are terrible, I want to replace them, but they are added with JavaScript, after lots of research with Tampermonkey/Greasemonkey and also Stylish, I couldn't find any way to do it. 我目前正在为本地路由器制作一个黑暗的主题,它使用的图像很糟糕,我想替换它们,但是在经过Tampermonkey / Greasemonkey和时尚的大量研究之后,它们已经添加了JavaScript,我找不到任何方式做到这一点。
Only idea I had was replace images with the file name say wan_up.png with another image. 我唯一的想法是用另一个图像替换文件名为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 */
}
There are many wrappers for MutationObserver, here's an example based on setMutationHandler : 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';
})
});
Edit the URL in @match, selector for the image to replace, new image URL accordingly. 编辑@match中的URL,选择要替换的图像的选择器,相应地更改新的图像URL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.