Jak zmienić klasę CSS za pomocą skryptu Greasemonkey / Tampermonkey?
Próbuję ustawić obraz tła ciała, ale tylko tam, gdzie używa klasybanner_url
. HTML jest następujący:
<body id="app_body" class="banner_url desktopapp" data-backdrop-limit="1">
Zasadniczo chciałbym wymusić na stronie użycie następującego CSS:
.banner_url {
background: url('http://www.pxleyes.com/images/contests/kiwis/fullsize/sourceimage.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
Próbuję to zrobić za pomocą Greasemonkey, jeśli to robi różnicę. Czy ktoś wie, jak mogę to zrobić? Zacząłem od następujących, ale nie miałem dużo szczęścia:
function randomBG(){
document.getElementsByClassName("banner_url").style.backgroundImage="url('http://www.pxleyes.com/images/contests/kiwis/fullsize/sourceimage.jpg')no-repeat center center fixed;";
}
randomBG();