I just wish I could disable smileys altogether, or maybe I just missed some option?
Added option to original post. Thanks for the idea @Magnus
EDIT: Fixed the typo
// ==UserScript==
// @name Sponge Emoji
// @namespace http://your.homepage/
// @version 0.1
// @description enter something useful
// @author You
// @match https://forums.spongepowered.org/*
// @grant none
// ==/UserScript==
var a=["apple","google","twitter","emoji_one"," "],b=4,c=a[b],d=document.getElementsByClassName("emoji"),i=0;for(i in d.length){var e=d[i],f=e.getAttribute("src")f=f.replace("emoji_one",c);f.setAttribute("src",a);if(c==""){e.setAttribute("style","visibility:hidden;width:0px;")}}
I made a minified version.
Simplified, but painfully hard to read now.
There is some glaring bugs that exist. v2 coming out soon! Gotta find a non laggy way to handle this.
Wouldnât jQuery make things easier?
Yes, that is exactly what I have been playing with
Ok, version two here! Always open to suggestions. I actually used a setInterval here and optimized the original method to reduce lag. If anyone has any ideas how I could do this easily with jQuery please speak up.
// ==UserScript==
// @name Sponge Emoji
// @namespace http://altechcode.com
// @version 1.2
// @description Personalize Emojis on Sponge Forums
// @author Alexander Allen (RobodudeMC)
// @match https://forums.spongepowered.org/*
// @grant none
// ==/UserScript==
var types = ["apple","google","twitter","emoji_one","none"];
//CONFIGURATION
//Sets emoji type set number of emoji type you want.
// 0 - Apple
// 1 - Google
// 2 - Twitter
// 3 - Emoji One
// 4 - Remove Them!
var select = 1;
//DO NOT MODIFY VALUES PAST THIS POINT
var em = types[select];
function memoji(emoji){
var all = document.getElementsByClassName("emoji");
for (var i=0, max=all.length; i < max; i++) {
var e = all[i];
var a = e.getAttribute("src");
var b = a.replace("emoji_one", emoji);
if(a != b){
e.setAttribute("src", b);
}
if(emoji == "none"){
e.setAttribute("style","visibility:hidden;width:0px;")
}
}
}
memoji(em);
setInterval(function(){
memoji(em);
}, 10);
EDIT: After some trial usage I have yet to discover any significant performance decrease or any bugs. woot!
Now to minify that!
Remember to keep the comments at the top when minifying it. Also, with JS such as this minification is really not going to give a performance increase. Especially with the way I designed it so you can select your own emoji type.
// ==UserScript==
// @name Sponge Emoji
// @namespace http://altechcode.com
// @version 1.2
// @description Personalize Emojis on Sponge Forums
// @author Alexander Allen (RobodudeMC)
// @match https://forums.spongepowered.org/*
// @grant none
// ==/UserScript==
var types = ["apple","google","twitter","emoji_one","none"];
//CONFIGURATION
//Sets emoji type set number of emoji type you want.
// 0 - Apple
// 1 - Google
// 2 - Twitter
// 3 - Emoji One
// 4 - Remove Them!
var select = 1;
var em=types[select];function memoji(emoji){var all=document.getElementsByClassName("emoji");for(var i=0,max=all.length;i<max;i++){var e=all[i];var a=e.getAttribute("src");var b=a.replace("emoji_one",emoji);if(a!=b){e.setAttribute("src",b)}if(emoji=="none"){e.setAttribute("style","visibility:hidden;width:0px;")}}}memoji(em);setInterval(function(){memoji(em)},10);
Didnât test BTW
Profit??? Minifying JS usually serves only the purpose of saving bandwidth. And as this is a Userscript minifying it is unnecessary and only harms readability.
You should probably create a separate thread for this thingy of yours
I believe I will, good idea