I am trying to modify css of a page using a javascript code. My aim is to run this javascript automatically whenever I open a website in Chrome. I have tried several Chrome extensions but it seems that it doesn t do the job (Requestly, Violentmonkey, Tampermonkey).
你们是否在周围工作?
Here is my use case: I use a web app to fulfill orders. In my order page, I have several products and quantity of each product (see screenshot). I want to change the css to make the text bigger and red when the quantity is 2 (and not 1). So I am sure I don t miss anything. I cannot change anything on the web app because it is a third-party app.
这里是我的“javascript”功能,当我手工使用该文字时,它就很好地发挥了作用,但我无法找到一种办法自动做到:
function Change(word) {
//find all html elements on the page inside the body tag
let elems = document.querySelectorAll("td");
// get our replacement ready
let span = "<span style= color:blue;font-size:22px;font-weight:bold; >" + word + "</span>";
//loop through all the elements
for (let x = 0; x < elems.length; x++) {
// for each element, split by the word we re looking for, then join it back with the replacement
// put your script function here
elems[x].innerHTML = elems[x].innerHTML.split(word).join(span);
}
}
Change( 2 );
感谢你们的帮助!