Author Topic: Bricc's Sploder Mainsite Addons [5 Scripts] [CONSISTENT RE BADGES FIX]  (Read 393 times)

Offline Bricc

  • ├┬┴┬┴┬┴┬┴┤
  • Mainsite Employee
  • Launcher
  • *
  • Posts: 1,191
  • Karma: +0/-0
    • View Profile
    • Nem-Creator
Install Tampermonkey on Chrome to use these scripts: https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo?hl=en

How to use Tampermonkey
Once you have Tampermonkey installed on your browser, you'll find the icon to the right of your search bar. Click the icon and select [create new script]. Once you have the script editor open, simply copy and paste the code from this thread and you'll be able to start using the mainsite addons.



➤ Staff Actions On Homepage (version 0.2)
This script will only be of use to those who hold the moderator and/or reviewer badges. The moderation button is in a very unusual place, so this script removes the unnecessary buttons and adds a "Moderate site content" option to the list (containing things such as "Make your own game", "Find friends", etc).

Reviewers, surely you're fed up of having to click on some form of games page to click on the reviews page, all just to write a review. Well, this script also adds a "Write a review" option if you hold the R badge, just for convenience.

- If you don't hold either of these badges, there's no point using this script as you will not receive the options. It actually checks if you hold the position.
- This means if you're only a moderator and not reviewer, you won't have an out of place moderation option (and vice versa).
- There's no extra options for editors, since they already have an option in the list to feature games.

If the moderation option does not consistently show up, under the modpanel() function, change the number inside of the brackets on the line below to a higher number.

Code: [Select]
// ==UserScript==
// @name         Bricc's Sploder Mainsite Addons - [Staff Actions On Homepage]
// @require      http://code.jquery.com/jquery-3.3.1.min.js
// @namespace    http://tampermonkey.net/
// @version      0.2
// @author       Bricc
// @match        http://www.sploder.com/
// ==/UserScript==

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

async function modpanel() {
  await sleep(1000);
  $.ajax({
    crossDomain : true,
    url: "http://www.sploder.com/awards/",
    beforeSend: function( xhr ) {
      xhr.overrideMimeType( "text/plain; charset=x-user-defined" );
    }
  })
    .done(function( data ) {
      if (data.indexOf("Administrate all awards »") >= 0) {
      var y2 = document.getElementsByClassName('actions');
      var list2 = y2[0];
      var revtext = "Moderate site content";
      var entry2 = document.createElement('li');
      list2.appendChild(entry2);
      var a2 = document.createElement('a');
      entry2.appendChild(a2);
      a2.href = "/games/moderation/";
      a2.appendChild(document.createTextNode(revtext));
    }
  });
}

function newreview() {
  $.ajax({
    crossDomain : true,
    url: "http://www.sploder.com/games/reviews/",
    beforeSend: function( xhr ) {
      xhr.overrideMimeType( "text/plain; charset=x-user-defined" );
    }
  })
    .done(function( data ) {
      if (data.indexOf("Create a new review »") >= 0) {
      var y2 = document.getElementsByClassName('actions');
      var list2 = y2[0];
      var revtext = "Write a review";
      var entry2 = document.createElement('li');
      list2.appendChild(entry2);
      var a2 = document.createElement('a');
      entry2.appendChild(a2);
      a2.href = "/games/reviews/create/";
      a2.appendChild(document.createTextNode(revtext));
    }
  });
}

modpanel();
newreview();

➤ Online Status On Comments (version 0.3)

This one's pretty self explanatory. I wasn't sure how exactly to make it look (even though it's fine as it is now), so there are a couple of options I've left as variables if you want to fiddle with them (if you know what you're doing). After installing this script, you will see the online status image that shows on profiles above people's usernames on comments.

Code: [Select]
// ==UserScript==
// @name         Bricc's Sploder Mainsite Addons - [Online Status On Comments]
// @require      http://code.jquery.com/jquery-3.3.1.min.js
// @namespace    http://tampermonkey.net/
// @version      0.3
// @author       Bricc
// @match        http://www.sploder.com/*
// ==/UserScript==

var statusImageSize = 80;
var commentBoxPadding = "10px 20px 10px 20px";

function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

var t = false;
var check = $("html").html();
var sub2 = check.substring(check.indexOf('title="My Account">')+19);
var myusername = sub2.substring(0,sub2.indexOf('</a></p>'));

$("body").on("DOMSubtreeModified", "#us_content_messages", async function() {
    if (t == false){
        t = true;
        await sleep(10);
        var x = -1;
        $('.us_message').each(function (index, value) {
            x += 1;
        });
        $('.us_message').each(function (index, value) {
            var html = $(this).children()[1].innerHTML;
            var sub = html.substring(48);
            if (myusername != sub.substring(0,sub.indexOf("/"))) {
                var img = $('<img style="padding-top:15px" width="' + statusImageSize + 'px"><div style="height:15px;width:100%;"></div>');
                img.attr('src', "http://sploder.net/status.php?u=" + sub.substring(0,sub.indexOf("/")));
                img.insertBefore($(this).children()[1]);
            } else {
                var imgy = $('<img style="padding-top:15px" width="0px"><div style="height:0px;width:100%;"></div>');
                imgy.attr('src', "http://sploder.net/status.php?u=" + sub.substring(0,sub.indexOf("/")));
                imgy.insertBefore($(this).children()[1]);
            }
            $(this).css('padding',commentBoxPadding);
            if (index == x) {
                t = false;
            }
        });
    }
});

➤ No Lordeldar No More! (version 0.1)

It's pretty common to be fed up of seeing Lordeldar's terrible games throughout the website. As part of our movement to make Sploder great again, courtesy of I, you can remove all of Lordeldar's games from the Sploder.com website. Your welcome.

Code: [Select]
// ==UserScript==
// @name         Bricc's Sploder Mainsite Addons - [No Lordeldar No More!]
// @require      http://code.jquery.com/jquery-3.3.1.min.js
// @namespace    http://tampermonkey.net/
// @version      0.1
// @author       Bricc
// @match        http://www.sploder.com/*
// ==/UserScript==

function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

$('.game').each(async function (index, value) {
    await sleep(10);
    var game = $(this).children()[0].innerHTML;
    var un = game.substring(game.indexOf("/games/members/")+15)
    var username = un.substring(0,un.indexOf("/play/"));
    if (username == "lordeldar") {
        if (window.location.pathname == "/games/members/lordeldar/") {
            $(this).css("display","none");
        } else {
            $(this).css("visibility","hidden");
        }
    }
});

if (window.location.pathname == "/games/members/lordeldar/") {
    $('.set').each(async function (index, value) {
        await sleep(10);
        $(this).append('<p class="prompt">No good games found!</p>');
    });
}

➤ Best Friends (version 0.1)

Currently, it is impossible to access the manage all friends page, meaning if you have a lot of friends, they won't all show up on the main friends page and you won't be able to add them as best friends.

But now you can! This script will add an extra option under "Find friends" (on the friends page) called "Best friends", which contains a textbox and a button. All you have to do is type in the person's username, press "Best" and ta-da, you're now besties!

Code: [Select]
// ==UserScript==
// @name         Bricc's Sploder Mainsite Addons - [Best Friends]
// @require      http://code.jquery.com/jquery-3.3.1.min.js
// @namespace    http://tampermonkey.net/
// @version      0.1
// @author       Bricc
// @match        http://www.sploder.com/friends/
// ==/UserScript==

function refresh() {
    window.location.replace("http://www.sploder.com/friends/");
}

function editFriend (action, friend_id) {
    $.ajax({
        type: "GET",
        dataType: "text",
        url: "http://www.sploder.com/friends/friends.php",
        data: "action=friend_" + action + "&friendid=" + friend_id,
        success: refresh,
    });
}

function letsbest(username) {
    $.ajax({
        url:"http://www.sploder.com/games/members/" + username + "/",
        type:'GET',
        success: function(data){
            var ss = data.substring(data.indexOf("http://cdn.sploder.com/users/")+29);
            var ss2 = ss.substring(ss.indexOf("http://cdn.sploder.com/users/")+29);
            var ss3 = ss2.substring(ss2.indexOf("/user")+5);
            var uid = ss3.substring(0,ss3.indexOf("_"));
            editFriend("best", uid);
        }
    });
}

$("body").on("click", "button", function(event) {
    letsbest($('#tobest').val());
});

$('<div class="friend_chooser" id="bests"><h4>Best a friend:</h4><label for="friendRemote">Enter your friend\'s username: </label><input type="text" id="tobest" name="search" autocomplete="off" class="ac_input"> <button id="besty" style="    background-image: url(../chrome/input_bkgd.gif);border: 1px solid #89a;font-size: 13px;padding: 3px;    background: #000;color: #ec0;border: 1px solid #9bacce;text-decoration: none;">Best</button><ul id="result"><li>&nbsp;</li></ul></div>').insertBefore("#friends");

➤ Consistent RE Badges (version 0.2)

A lot of staff members have their R and E badges being visually inconsistent. This script fixes that and gives badges to the people that should have them. (It checks the staff list for staff members.)

Code: [Select]
// ==UserScript==
// @name         Bricc's Sploder Mainsite Addons - [Consistent RE Badges]
// @require      http://code.jquery.com/jquery-3.3.1.min.js
// @namespace    http://tampermonkey.net/
// @version      0.2
// @author       Bricc
// @match        http://www.sploder.com/games/members/*
// ==/UserScript==

function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

var checkusername = "";
var R = false;
var E = false;

function checkE() {
    $('.contentpromo').each(function (index, value) {
        if ($(this).parent().children()[0].innerHTML == "Editors") {
            $(this).children("li").each(function(i,v) {
                var u = v.innerHTML.substring(v.innerHTML.indexOf("/games/members/")+15);
                var username = u.substring(0,u.indexOf("/"));
                if (username == checkusername) {
                    E = true;
                }
            });
        }
    });
}
function checkR() {
    $('.contentpromo').each(function (index, value) {
        if ($(this).parent().children()[0].innerHTML == "Reviewers") {
            $(this).children("li").each(function(i,v) {
                var u = v.innerHTML.substring(v.innerHTML.indexOf("/games/members/")+15);
                var username = u.substring(0,u.indexOf("/"));
                if (username == checkusername) {
                    R = true;
                }
            });
        }
    });
    if (R == true) {
        $(".mprofstatus").children()[2].remove();
        $("<img src='/chrome/role_reviewer.gif' width='24' height='28' alt='reviewer' title='reviewer'>").insertAfter($(".mprofstatus").children()[1]);
    }
    if (E == true) {
        $(".mprofstatus").children()[1].remove();
        $("<img src='/chrome/role_editor.gif' width='24' height='28' alt='editor' title='editor'>").insertAfter($(".mprofstatus").children()[0]);
    }
}

$("body").append("<div id='extra'></div>");
$("#extra").load("http://www.sploder.com/members/staff/ .memberboard", function(){
    var url = window.location.pathname.substring(window.location.pathname.indexOf("/games/members/")+15);
    url = url.substring(url.indexOf("/")+1);
    if (url.indexOf("/") < 0) {
        var name = $(".mprofvitals").children()[0].innerHTML.substring($(".mprofvitals").children()[0].innerHTML.indexOf('/">')+3);
        name = name.substring(0,name.indexOf("<"));
        checkusername = name;
        checkE();
        checkR();
        $("#extra").remove();
    } else {
        $("#extra").remove();
    }
});

I'll add more scripts whenever I feel like one should be made! I'm not an expert at JavaScript or jQuery, but since I do code I can adapt and will most likely be able to bring you some cool features!
« Last Edit: April 25, 2019, 06:36 pm by Bricc »


Moderator, Moderator Recruiter, Reviewer, Editor
 

Offline seanthechinaman

  • MRE
  • Launcher
  • ***
  • Posts: 1,027
  • Karma: +5/-0
    • View Profile
Re: Bricc's Sploder Mainsite Addons [1 Script]
« Reply #1 on: April 20, 2019, 09:04 pm »
Invalid Userscript, according to Tampermonkey.
 

Offline Bricc

  • ├┬┴┬┴┬┴┬┴┤
  • Mainsite Employee
  • Launcher
  • *
  • Posts: 1,191
  • Karma: +0/-0
    • View Profile
    • Nem-Creator
Re: Bricc's Sploder Mainsite Addons [1 Script]
« Reply #2 on: April 20, 2019, 09:08 pm »
Invalid Userscript, according to Tampermonkey.

Give me a sec, I'll fix that. I'll also be adding a new script along with it.


Moderator, Moderator Recruiter, Reviewer, Editor
 

Offline Bricc

  • ├┬┴┬┴┬┴┬┴┤
  • Mainsite Employee
  • Launcher
  • *
  • Posts: 1,191
  • Karma: +0/-0
    • View Profile
    • Nem-Creator
Re: Bricc's Sploder Mainsite Addons [2 Scripts]
« Reply #3 on: April 20, 2019, 09:21 pm »
Tomorrow, I plan to add coloured circles to show online/offline status (rather than the default images), as well as making the "Moderate site content" more reliable (it appears to be very temperamental right now).


Moderator, Moderator Recruiter, Reviewer, Editor
 

Offline Bricc

  • ├┬┴┬┴┬┴┬┴┤
  • Mainsite Employee
  • Launcher
  • *
  • Posts: 1,191
  • Karma: +0/-0
    • View Profile
    • Nem-Creator
Re: Bricc's Sploder Mainsite Addons [2 Scripts]
« Reply #4 on: April 20, 2019, 09:24 pm »
Updated the Staff Actions On Homepage script. The "Moderate site content" link is reliable now and should appear every time. :)


Moderator, Moderator Recruiter, Reviewer, Editor
 

Offline seanthechinaman

  • MRE
  • Launcher
  • ***
  • Posts: 1,027
  • Karma: +5/-0
    • View Profile
Re: Bricc's Sploder Mainsite Addons [2 Scripts]
« Reply #5 on: April 20, 2019, 09:33 pm »
I'm noticing no changes with the Staff Actions script, how is that supposed to look?
 

Offline Bricc

  • ├┬┴┬┴┬┴┬┴┤
  • Mainsite Employee
  • Launcher
  • *
  • Posts: 1,191
  • Karma: +0/-0
    • View Profile
    • Nem-Creator
Re: Bricc's Sploder Mainsite Addons [2 Scripts]
« Reply #6 on: April 21, 2019, 04:13 am »
I'm noticing no changes with the Staff Actions script, how is that supposed to look?

Will send a screenshot later, I’m currently on mobile. Are you using Google Chrome?


Moderator, Moderator Recruiter, Reviewer, Editor
 

Offline seanthechinaman

  • MRE
  • Launcher
  • ***
  • Posts: 1,027
  • Karma: +5/-0
    • View Profile
Re: Bricc's Sploder Mainsite Addons [2 Scripts]
« Reply #7 on: April 21, 2019, 05:25 am »
Will send a screenshot later, I’m currently on mobile. Are you using Google Chrome?

Of course.
 

Offline Ethan2009

  • Local annoyance.
  • Mainsite Employee
  • Mortar
  • *
  • Posts: 3,564
  • Karma: +3/-0
  • Failure.
    • View Profile
Re: Bricc's Sploder Mainsite Addons [2 Scripts]
« Reply #8 on: April 21, 2019, 10:53 am »
It works! nice
8)
 

Offline Bricc

  • ├┬┴┬┴┬┴┬┴┤
  • Mainsite Employee
  • Launcher
  • *
  • Posts: 1,191
  • Karma: +0/-0
    • View Profile
    • Nem-Creator
Re: Bricc's Sploder Mainsite Addons [2 Scripts] [USERS ONLINE FIXED]
« Reply #9 on: April 21, 2019, 11:19 am »
Fixed the Online Status On Comments script with some help from Cyan (thanks bro). The online statuses now update every time you switch comments and do so much faster than before (almost instantly). :)


Moderator, Moderator Recruiter, Reviewer, Editor
 

Offline Bricc

  • ├┬┴┬┴┬┴┬┴┤
  • Mainsite Employee
  • Launcher
  • *
  • Posts: 1,191
  • Karma: +0/-0
    • View Profile
    • Nem-Creator
Re: Bricc's Sploder Mainsite Addons [2 Scripts] [USERS ONLINE UPDATE]
« Reply #10 on: April 25, 2019, 08:53 am »
Updated Online Status On Comments script. Now you'll only see the online status of other users. You really don't need to see if you're online yourself... Plus, this way it looks much neater and also loads everything that little bit quicker. :)


Moderator, Moderator Recruiter, Reviewer, Editor
 

Offline Ethan2009

  • Local annoyance.
  • Mainsite Employee
  • Mortar
  • *
  • Posts: 3,564
  • Karma: +3/-0
  • Failure.
    • View Profile
Re: Bricc's Sploder Mainsite Addons [3 Scripts] [NEW EPIC SCRIPT]
« Reply #11 on: April 25, 2019, 09:29 am »
No lordeldar no more! More like No torture no more!
8)
 

Offline Bricc

  • ├┬┴┬┴┬┴┬┴┤
  • Mainsite Employee
  • Launcher
  • *
  • Posts: 1,191
  • Karma: +0/-0
    • View Profile
    • Nem-Creator
Re: Bricc's Sploder Mainsite Addons [3 Scripts] [NEW EPIC SCRIPT]
« Reply #12 on: April 25, 2019, 09:30 am »
No lordeldar no more! More like No torture no more!

#MakeSploderGreatAgain


Moderator, Moderator Recruiter, Reviewer, Editor
 

Offline Ethan2009

  • Local annoyance.
  • Mainsite Employee
  • Mortar
  • *
  • Posts: 3,564
  • Karma: +3/-0
  • Failure.
    • View Profile
Re: Bricc's Sploder Mainsite Addons [3 Scripts] [NEW EPIC SCRIPT]
« Reply #13 on: April 25, 2019, 09:31 am »
#MakeSploderGreatAgain
#MakeSploderGreatAgain
#tooVague
#You're forgetting the concept has been done to death, this particular take on it was rather weak. our arena was really small and the enemy fences can be destroyed ( which i assume was unintentional )
8)
 

Offline Bricc

  • ├┬┴┬┴┬┴┬┴┤
  • Mainsite Employee
  • Launcher
  • *
  • Posts: 1,191
  • Karma: +0/-0
    • View Profile
    • Nem-Creator
Consistent RE Badges updated to version 0.2. There was a bug where the staff members list would appear at the very bottom of game pages and that is no longer an issue.


Moderator, Moderator Recruiter, Reviewer, Editor
 

Online star34

  • Soldier
  • Cruiser
  • ****
  • Posts: 415
  • Karma: +0/-0
    • View Profile
    • Youtube Channel
I think the comments should look like this.


In 544 days sploder dies :(
Will update monthly
http://bit.ly/2R8vHYj
 

Offline Ethan2009

  • Local annoyance.
  • Mainsite Employee
  • Mortar
  • *
  • Posts: 3,564
  • Karma: +3/-0
  • Failure.
    • View Profile
I think the comments should look like this.

you are correct, all comments should rage and say REEEEEEEEEEEEEEEEEEEEEEE
8)
 

Online star34

  • Soldier
  • Cruiser
  • ****
  • Posts: 415
  • Karma: +0/-0
    • View Profile
    • Youtube Channel
Most of the comments I get are like that, just stating that my games are really hard.

And I meant he should put the online status beside the other buttons.


In 544 days sploder dies :(
Will update monthly
http://bit.ly/2R8vHYj
 

Offline Ethan2009

  • Local annoyance.
  • Mainsite Employee
  • Mortar
  • *
  • Posts: 3,564
  • Karma: +3/-0
  • Failure.
    • View Profile
Most of the comments I get are like that, just stating that my games are really hard.

And I meant he should put the online status beside the other buttons.
Ik lol, I was joking
8)
 

Offline lordeldar

  • Lidl man
  • Lieutenant
  • Heavy Cruiser
  • *****
  • Posts: 10,555
  • Karma: +263/-0
    • View Profile
Oh wow you actually released it  >:D

Achievements:
56 features (61 including collabs)
MSM
Reviewer
Editor
Lt
Voted best Private of 2011
Voted best MSM of 2012 and 2013
Voted best Lt of 2014
 

Offline Bricc

  • ├┬┴┬┴┬┴┬┴┤
  • Mainsite Employee
  • Launcher
  • *
  • Posts: 1,191
  • Karma: +0/-0
    • View Profile
    • Nem-Creator
Oh wow you actually released it  >:D

I'm doing the community a favour.


Moderator, Moderator Recruiter, Reviewer, Editor
 

Offline Ethan2009

  • Local annoyance.
  • Mainsite Employee
  • Mortar
  • *
  • Posts: 3,564
  • Karma: +3/-0
  • Failure.
    • View Profile
I'm doing the community a favour.
So true
8)