Last active
February 4, 2020 23:48
-
-
Save NanoAi/d6cfefa7d5c6756be06d76a77f0a235e to your computer and use it in GitHub Desktop.
Discord Background Image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var matchStr = "[class^=messagesWrapper] > [class^=scrollerWrap] > [class^=scroller]" // The selection string, Discord might change this... | |
var imgURL = "https://i.imgur.com/4TiFTqP.jpg"; // Set your image URL here! | |
var delay = 60 // Higher is slower, Lower is faster but may lag. (This value is in milliseconds!) | |
var buildObserverX = function() { | |
let t; // Some micro optimization magic stuff. Is it really needed? Hell if I know... | |
let x = new MutationObserver(function (e) { | |
if (t) clearTimeout(t); | |
t = setTimeout(() => { | |
let messagesWrapper = document.querySelector(matchStr); | |
if (messagesWrapper && messagesWrapper.hasBackgroundSet !== true) { | |
init(); | |
} | |
}, delay); | |
}); | |
x.observe(document.getElementById("app-mount"), { | |
childList: true, | |
subtree: true | |
}); | |
buildObserverX = undefined; | |
} | |
let init = function() { | |
let messagesWrapper = document.querySelector(matchStr); | |
if (messagesWrapper && typeof messagesWrapper === "object") { | |
messagesWrapper.setAttribute("style", "background: linear-gradient( rgba(0, 0, 0, 0.65), rgba(54, 57, 63, 1) ), url(" + imgURL + ")!important;background-size: cover!important;"); | |
messagesWrapper.hasBackgroundSet = true; | |
} | |
if (typeof buildObserverX === "function") { | |
console.log("Binding Observer...") | |
buildObserverX(); | |
console.log("Observer Bound!") | |
} | |
} | |
init(); // Initial Launch! | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This should work on Windows, Mac and Linux!
HOW TO USE
ctrl+shift+i
(command+option+i
on Mac). This will be referred to as console.ctrl+r
) Discord.PLEASE NOTE
It is highly unlikely that you will get banned or punished in any way for using the code above. However, if something goes wrong and Discord threatens your family by name, or sends a representative to remove your reproductive organs, or if the script has any other undesirable effect. Don't blame the author of this script!
tl;dr Use at your own risk!