Use CSS instead of JS for highlighting table rows

This improves performance significantly and reduces the incidence of bugs and undesireable side-effects when using this userscript in conjunction with other userscripts, userstyles and/or browser extensions that modify the look and feel of MB pages.
This commit is contained in:
Luciano Paciornick 2023-04-23 16:41:16 -04:00 committed by Aurélien Mino
parent 424b2c6937
commit 7cb81736b3

View file

@ -20,24 +20,7 @@ $(document).ready(function () {
LASTFM_APIKEY = '';
// Highlight table rows
$('table.tbl tbody tr').hover(
function () {
$(this)
.children('td')
.each(function () {
let backgroundColor = $(this).css('backgroundColor');
if (backgroundColor != 'rgb(255, 255, 0)') $(this).css('backgroundColor', '#ffeea8');
});
},
function () {
$(this)
.children('td')
.each(function () {
let backgroundColor = $(this).css('backgroundColor');
if (backgroundColor != 'rgb(255, 255, 0)') $(this).css('backgroundColor', '');
});
}
);
$('head').append('<style>table.tbl > tbody > tr:hover { background-color: #ffeea8 } table.tbl > tbody > tr:hover > td { background-color: rgba(0, 0, 0, 0) }</style>');
let re;