Skip to content

Instantly share code, notes, and snippets.

@NanoAi
Last active August 10, 2018 06:35
Show Gist options
  • Save NanoAi/404207d0f118f620f3a2c2cc91ec87d2 to your computer and use it in GitHub Desktop.
Save NanoAi/404207d0f118f620f3a2c2cc91ec87d2 to your computer and use it in GitHub Desktop.
DiscordModification.js
var imageBlur = document.createElement('style');
var headStyle = document.createElement('style');
var imgCSS = ".da-container img,.da-container video{filter:brightness(-1);-webkit-filter:brightness(-1)}"
imgCSS += ".da-container img:hover,.da-container video:hover{filter:brightness(1)!important;-webkit-filter:brightness(1)!important}"
var injCSS = ".da-messageGroupBlocked{display:none!important;}.emoji-picker .scroller .emoji-item.disabled{opacity:0.2;}";
/* injCSS += ".avatar-large{background-size: 50px 50px;height: 50px;width: 50px;}.emoji.jumboable{height: 48px;width: 48px;}"; */
headStyle.innerHTML = injCSS;
Element.prototype.remove = function () {
this.parentElement.removeChild(this);
}
NodeList.prototype.remove = HTMLCollection.prototype.remove = function () {
for (var i = this.length - 1; i >= 0; i--) {
if (this[i] && this[i].parentElement) {
this[i].parentElement.removeChild(this[i]);
}
}
}
function BindCustom() {
setTimeout(function () {
var button;
var menu = document.MenuOption;
var data = document.ImageCensoring;
var context = document.querySelector("[class^=contextMenu]");
if (menu == [] || menu.option == null) {
button = (context.querySelector("[class^=itemGroup]")).cloneNode(true);
var option = button.querySelector("div:not([class^=itemToggle]").cloneNode(true);
var junk = button.querySelectorAll("[class^=item]");
if( junk ){ junk.remove(); }
button.appendChild(option);
function toggleState() {
if (data.state == 0) {
data.state = 1;
imageBlur.innerHTML = imgCSS;
button.querySelector("input[type='checkbox']").checked = true;
} else {
data.state = 0;
imageBlur.innerHTML = "";
button.querySelector("input[type='checkbox']").checked = false;
}
}
if( typeof(data.state) == "undefined" ){ toggleState(); }
button.onclick = toggleState;
button.span = button.querySelector("[class^=label]");
button.span.textContent = "Image Censoring";
menu.button = button;
menu.option = option;
} else {
button = menu.button;
button.appendChild(menu.option);
}
button.querySelector("input[type='checkbox']").checked = (data.state == 1 && true || false);
context.appendChild(button);
}, 1)
}
var checkArea = setInterval(function(){
var textarea = document.getElementsByTagName("textarea")[0];
if (textarea && textarea.oncontextmenu === null) {
textarea.oncontextmenu = BindCustom;
console.log("Textfield - Bound!");
}
},500);
function clearMods(){
var textarea = document.getElementsByTagName("textarea")[0];
imageBlur.remove();
headStyle.remove();
textarea.oncontextmenu = null;
clearTimeout(checkArea);
document.ImageCensoring = null;
document.MenuOption = null;
checkArea = null;
BindCustom = null;
injCSS = null;
imgCSS = null;
headStyle = null;
imageBlur = null;
console.log("Modifications Cleared!");
}
document.body.appendChild(imageBlur);
document.head.appendChild(headStyle);
document.ImageCensoring = [];
document.MenuOption = [];
@NanoAi
Copy link
Author

NanoAi commented May 27, 2018

This should work on Windows, OSX and Linux!

HOW TO USE

  1. Open Discord.
  2. Press ctrl+shift+i (command+option+i on OSX). 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 either restart/refresh Discord or enter clearMods(); in console.

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!

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