Various Sponge Userscripts

Emoji Changer

*Release v2*

Here is a userscript that is used to modify the emoji types that are shown on the forums. The emojis supported are Twitter, Google, Apple, Emoji One and None. All emojis are received straight from sponge forums via https. This has undergone fairly heavy use testing and does not seem to affect the performance of the forums in any way, but, if you find any way to extend or optimize it I will take it into consideration and modify it if need be. The script is fairly straightforward, just read the first part of it to learn how to configure it. Otherwise it is installed exactly like any other userscript on Tamermonkey or Greasemonkey. Enjoy!


// ==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);



Desktop Notifications

*Beta v1.0*

This is a userscript that will run on chrome (I don’t know about firefox) that will give you a desktop notification when you receive a personal message, get a reply, or get a mention, or a thread that you are tracking is replied to. It is currently in a very early beta and will be improved later. Just install it and it should work out of the box.

// ==UserScript==
// @name         Sponge Desktop Notifications
// @namespace    http://altechcode.com
// @version      0.1
// @description  Enables Sponge Desktop Notifictions
// @author       Alexander Allen (RobodudeMC)
// @match        https://forums.spongepowered.org/*
// @grant        none
// ==/UserScript==

var current = 0;
current = $.cookie("cook_not");
if(current === undefined || !current){
    current = "0";
}

var focused = true;

window.onfocus = function() {
    focused = true;
};
window.onblur = function() {
    focused = false;
};

current = parseInt(current);

function notify(message) {
    if (!Notification) {
        alert('Please us a modern version of Chrome, Firefox, Opera or Firefox.');
        return;
    }

    if (Notification.permission !== "granted")
        Notification.requestPermission();

    var notification = new Notification('Sponge Forums', {
        icon: 'https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQMaQ_eO_yCf3ixbXTPjyfxosX_f3G3_hEYNIUZEBQ70Ebgay58',
        body: message
    });


    notification.onclick = function () {
        window.focus();
        this.cancel();
    }
}

function check() {
    if(focused == true){
        //return;
    }
    var n = $('*.badge-notification').not('*.new-posts').not('*.clicks').not("*.unread").length;
    if(n > 0){
        var stramt = $('*.badge-notification').not('*.new-posts').not('*.clicks').not("*.unread")[0].innerText;
        var amt = parseInt(stramt);
        if(n > 2){
            stramt = $('*.badge-notification').not('*.new-posts').not('*.clicks')[1].innerText;
            amt += parseInt(stramt);
        }
        if(amt > current){
            notify("You have " + stramt + " new notifications. Click to see them.");
        }
        current = amt;
        $.cookie("cook_note", current);
    }else{
        $.cookie("cook_note", 0);
    }

}

function refresh(){
    if(focused == false){
        window.location.reload();
    }
}

check();

setInterval(function(){check()}, 500);
setInterval(function(){refresh()}, 100000);
3 Likes

Cool!

Test Emojis

:smile: :smiley: :wink: :blush:

Very nice. Good release. Works pretty great.

@RobodudeMC you are the best! Thanks!

Thanks :slight_smile: who here would be interested in my desktop notification userscript? I made it a while ago but I will improve it a bit and post it if anyone wants.

3 Likes

I’d like one. It’d be nice to get notifications on replies. Does it also notify on messages? If so that would be extremely useful.

Yeah thats the support I still need to add to it. When I get it working pretty reliably I will post it.

1 Like

Updated OP, feedback is welcome!

Liking the look of it all, and the notification banners. If I notice anything I’ll be sure to post.

When not scrolled down on a topic all the way, and one switches tabs a notification appears saying you have ‘POSTS LEFT IN THREAD new notifications’ This is on chrome, windows 7, tampermonkey.

Ill take a look at that right now! Thanks for letting me know.

I went ahead and tweaked it, you might want to test it and make sure it will still notify you on PMs and other notifications.

Fixed some bugs in Desktop Notifications!

Ok, desktop notifications seem to work decently now. Please report any bugs. Original post updated.

2 Likes