Skip to content

Instantly share code, notes, and snippets.

@NanoAi
Last active February 4, 2020 23:48
Show Gist options
  • Save NanoAi/d6cfefa7d5c6756be06d76a77f0a235e to your computer and use it in GitHub Desktop.
Save NanoAi/d6cfefa7d5c6756be06d76a77f0a235e to your computer and use it in GitHub Desktop.
Discord Background Image
(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!
})();
@NanoAi
Copy link
Author

NanoAi commented Feb 20, 2019

This should work on Windows, Mac and Linux!

HOW TO USE

  1. Open Discord.
  2. Press ctrl+shift+i (command+option+i on Mac). This will be referred to as console.
  3. Read the warning and if you decide that you don't trust me, then don't continue.
  4. Copy and paste the code above into console.
  5. Everything should now work, to remove restart/refresh (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!

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment