So me and my friend are making a chrome extension. To get into detail, it’s for the Roblox Devforum, and so far, so good! Yesterday we started, and already have our button on the header and stuff, similarly to Roblox+ or RoPro.
However there is a situation (not necessarily a bug, mainly a styling issue) with the button. Whenever you hover over the button, some white square appears on the icon of the button and it just looks hideous, and we didn’t know what was causing the issue, even after reviewing multiple articles on Google, which brings us here today. The code for the extension is as follows:
modifications.js:
function getFirstulWithClass(cssClass) {
var elements = document.getElementsByTagName('ul');
for (var i = 0; i < elements.length; i++) {
if((' ' + elements[i].className + ' ').indexOf(' ' + cssClass + ' ') > -1) {
return elements[i];
}
}
}
var ul = getFirstulWithClass('icons d-header-icons');
if (ul) {
ul.innerHTML += `
<li class="header-dropdown-toggle dpp-dropdown">
<a title="DPPSettings" class="icon">
<div>
<img src="https://i.imgur.com/suZBJ8y.png" width="45" height="29" title="DSI" class="DSI">
</div>
</a>
</li>
`
}
To clarify this code, all it does is look for the header element, and injects that chunk of HTML code into the header without overriding the original Devforum header code.
Now I wanted to add a little animation to the button so that it looked very eye-appealing, so we added a new file called modifications.css, and looks as follows:
@keyframes settingsHover {
0% {
width: 45px;
height: 29px;
}
100% {
width: 48px;
height: 31px;
}
}
.DSI:hover {
animation-name: settingsHover;
animation-fill-mode: forwards;
animation-duration: .01s;
}
All this does is add a small enlargement animation to the button.
Now we tie it together in our manifest.json file as so:
"content_scripts": [
{
"matches": ["https://*.devforum.roblox.com/*"],
"css": ["modifications.css"],
"js": ["modifications.js"]
}
],
And this ultimately creates this weird box that was not intended to be added in the programming of this, that looks as so:
How can I remove this? Any help is appreciated very much!
Let me preface this by saying I am by no means experienced enough to give a true answer on this, but I don't have enough reputation to give a comment.
Could the white square somehow be the keyframe(s)? It seems shaped like the dimensions you gave and could be some CSS visual error that could be fixed with a line of code or two. For me, it seems likely that it's either a Roblox thing or most likely a CSS thing, but again, I barely can understand what's going on here and have little experience. It could be that that is something like a HTML/CSS class in the Roblox site and you could be accidentally doing something with that as well.
Take this with a grain of salt though.
so basically, the answer this was just simply adding this to CSS:
.icon {
--primary-low: transparent !important;
}