Gear
Gear

Reputation: 1

Script: fixed background attachment

Some forums I use don't have fixed backgrounds and I find it dizzying. I was hoping to change that with the TamperMonkey plugin but it requires scripts and I don't know how to create scripts. I found one similar albeit older topic and the scripts didn't work.

So, say I want to turn something like this: body {background: url('image') fixed;} or body {background-image: url('image');background-attachment: fixed;} Into a script. How would I go about that? I use Firefox, not sure if that's important.

Upvotes: 0

Views: 68

Answers (1)

Bets
Bets

Reputation: 586

The JavaScript equivalent for setting those two properties would be:

document.body.style.background = "url('image')";
document.body.style.backgroundAttachment = "fixed";

I'm not familiar with TamperMonkey (I had to Google what it is), but I imagine if you saved those two lines in a .js file, and added them to be loaded on whichever pages you want to override the background, that should work.

If it doesn't work, feel free to drop me a comment and I can try to help you debug it.

Upvotes: 0

Related Questions