我想更改网站的背景。问题是我在Greasemonkey上的经验几乎为零。我有这个脚本:
// ==UserScript==
// @name Tamo
// @namespace TamoImageChanger
// @include https://sistema.tamo.lt*
// @version 1
// @grant none
// ==/UserScript==
var images = document.getElementsByTagName("img");
var x = 0;
while (x < images.length) {
if (images[x].src == "https://sistema.tamo.lt/Content/img/new/login_background2.jpg") {
images[x].src = "the image i want to be displayed";
}
x = x + 1;
}
但是仅当我在此网页上时,它才起作用:https :
//sistema.tamo.lt/Content/img/new/login_background2.jpg
我希望脚本通过以下方式更改此网页中的背景:https :
//sistema.tamo.lt/Prisijungimas/Login
您尝试访问的网站正在将该图像显示为背景图像,而不是图像标签。
该脚本实际上会更改所有<img/>
标签的来源。
var images = document.getElementsByTagName("img");
因此,我确实自定义了脚本以完成您想做的任何事情。为了使这更具教育意义,我将逐步解释发生了什么。
// Here I'm retrieving the tag displaying the picture by specifying exact path.
var image = document.querySelector("body > .container_2 > .col_left");
// Here I just change the background image by yours.
image.style.backgroundImage = "url('INSERT YOUR IMAGE')";
--
编辑
正如下面的Brock Adams所述,您还可以完成与GreaseMonkey样式相同的工作。
GM_addStyle("div[style*='login_background2.jpg'] {background-image: url('INSERT YOUR IMAGE')!important;} ")
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句