0

im trying to change the color of a class on bybit exchange. the problem is that the extension stops working after reloading two times and then I have to clear my cache to get it runnig again. im pretty new to programming so yeah... :) here is the code

function btn4() {

var recent = document.getElementsByClassName("rt__head full flex");

recent[0].style.backgroundColor = "lightblue";
}
btn4();

this is my manifest file below:

  "name": "Bybit orderbook color",


"version": "1.1",
  "manifest_version": 2,

  "content_scripts": [
    {
      "matches": [ "https://www.bybit.com/trade/usdt/BTCUSDT/*" ],
      "run_at": "document_idle",
      "js": [ "background.js" ]

    }

  ],

  "permissions": [ "activeTab" ]


}
Peyman
  • 25
  • 6
  • 1
    Convert your js to css as shown [here](https://stackoverflow.com/a/39234175). Your css will be `.rt__head.full.flex { background-color: lighblue !important }` – wOxxOm Dec 18 '21 at 10:33
  • @woxxom i cant use CSS because ill have to use if statement. id you take a look at the website and see the recent trades tab, youl see that there are
  • 's just below it. my end goal is to change the color of the
  • s based on their amount.
  • – Peyman Dec 18 '21 at 19:51
  • try adding a css class to the element, var recent = document.getElementsByClassName("rt__head full flex"); recent[0].classList.add('light-blue'); – ChethiyaKD Dec 18 '21 at 19:53
  • Then you'll have to use MutationObserver. – wOxxOm Dec 18 '21 at 20:33