Announcements > Announcements

Cyan's Sploder Tampermonkey Scripts [3] - [Easier Featuring] (01/Apr/2019)

Cyan:
Install Tampermonkey on Chrome: 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 forum addons.


Addons

➤ User Online List - last updated 09/Jan/2019 - v0.1.2
example: https://i.imgur.com/FOfkdcO.png

--- Code: ---// ==UserScript==
// @name         Cyan's Sploder Forum Addons - [User Online List]
// @require      http://code.jquery.com/jquery-3.3.1.min.js
// @namespace    http://tampermonkey.net/
// @version      0.1.2 - 09/Jan/2019
// @author       Cyan
// @match        http://*.sploder.com/*
// ==/UserScript==


if($("tbody#category_1_boards").length){
    var leftside = "<div class=information><span class=topslice><span></span></span><div class=sp_block style=overflow:hidden;width:150px;padding-top:25px;padding-right:10px;padding-bottom:20px;padding-left:10px><a href=http://forums.sploder.com/index.php?action=who>Users Online</a>:<br><div></div>";
    var usersOnline = [];

    $("div#main_content_section").before("<table><td valign=top class=leftside_td></td><td class=boardindex_td></td></table>");
    $("td.boardindex_td").append($("div#main_content_section"));
    $("td.leftside_td").append(leftside);

    $("#upshrinkHeaderIC p.smalltext a").each(function(){
        usersOnline[usersOnline.length] = $(this).clone();
        $("div.information div.sp_block br:eq(0)").after(usersOnline[usersOnline.length-1]);
    });
    $("div.information div.sp_block br:first").after("<br><span class=listtop>");

    var Guests = $("p.stats a").text().split(" Guests, ");
    var UsersOn = Guests[1].split(" Users");
    UsersOn = UsersOn[0];
    Guests = Guests[0];
    $("div.information div.sp_block:first").prepend("<br>");
    $("div.information div.sp_block div").empty();
    $("div.information div.sp_block div").append("<br><br><span class=OnlineMembers>Members: "+(usersOnline.length)+"</span><br>");
    $("div.information div.sp_block div").append("<span class=OnlineMembers>Guests: "+Guests+"</span><br>");
    $("div.information div.sp_block div").append("<span class=OnlineMembers>Hidden: "+((UsersOn)-(usersOnline.length))+"</span><br><br>");

    var userarray = [];
    $("div.information div.sp_block a").each(function(){
        userarray[parseInt($(this).attr("href").split("=").pop())] = $(this);
    });
    var i = 0;
    for(i=0;i<userarray.length;i++){
        if (userarray[i] != null){
            console.log(userarray[i]);
            $("div.information div.sp_block span.listtop").before("<br>").before("<img style=padding:2px;padding-left:10px; width=24px class=userO src= />").before(userarray[i].attr("class","userlista"));
            $("img.userO:last").attr("src","http://avatars.sploder.com/a/"+userarray[i].text().charAt(0)+"/"+userarray[i].text().charAt(1)+"/"+userarray[i].text()+"_24.png").css("vertical-align","middle").css("margin","2px");
        }
    }




    var avatarlist = {};
    avatarlist = JSON.parse(localStorage.getItem("avatars"));

    if($.isEmptyObject(avatarlist)){
        avatarlist = {};
    }

    if(!$.isEmptyObject(avatarlist)){
        $("div.sp_block a.userlista").each(function(index){
            var boardavatar = $(this).attr("href");
            if(avatarlist[boardavatar] != "blank"){
                $(this).prev().attr("src",avatarlist[boardavatar]).attr("width","24px").attr("height","24px");
            }
        });
    }

    setTimeout(function(){
        $("div.sp_block a.userlista").each(function(index){
            var boardavatar = $(this).attr("href");
            var thisL = $(this).prev();
            console.log(thisL.attr("src"));
            if(!$.isEmptyObject(avatarlist)){
                if(!(boardavatar in avatarlist) || Math.floor(Math.random() * 10) == 9) {
                    $.ajax({
                        url:boardavatar,
                        type:"GET",
                        success: function(data){
                            console.log("random deletion online-list");
                            var new_av = $(data).find("div#basicinfo img.avatar").attr("src");
                            thisL.attr("src",new_av);
                            if (new_av == null){new_av="blank";}
                            avatarlist[boardavatar] = new_av;
                            localStorage.avatars = JSON.stringify(avatarlist);
                        }
                    });
                }
            }else{
                $.ajax({
                    url:boardavatar,
                    type:"GET",
                    success: function(data){
                        var new_av = $(data).find("div#basicinfo img.avatar").attr("src");
                        thisL.attr("src",new_av);
                        if (new_av == null){new_av="blank";}
                        avatarlist[boardavatar] = new_av;
                        localStorage.avatars = JSON.stringify(avatarlist);
                    }
                });
            }
        });
    },500);
}

--- End code ---


➤ Topics on Boardindex - last updated 10/Jan/2019 - v0.1.1
example: https://i.imgur.com/Ve600Di.png

--- Code: ---// ==UserScript==
// @name         Cyan's Sploder Forum Addons - [Topis on Boardindex]
// @require      http://code.jquery.com/jquery-3.3.1.min.js
// @namespace    http://tampermonkey.net/
// @version      0.1.1 - 10/Jan/2019
// @author       Cyan
// @match        http://*.sploder.com/*
// ==/UserScript==


var avatarlist = {};
avatarlist = JSON.parse(localStorage.getItem("avatars"));

if($.isEmptyObject(avatarlist)){
    avatarlist = {};
}

if(!$.isEmptyObject(avatarlist)){
    $("div.sp_block a.userlista").each(function(index){
        var boardavatar = $(this).attr("href");
        if(avatarlist[boardavatar] != "blank"){
            $(this).prev().attr("src",avatarlist[boardavatar]).attr("width","24px").attr("height","24px");
        }
    });
}

function loadavs(){
    if(!$.isEmptyObject(avatarlist)){
        $("table tbody tr td.icon2").each(function(index){
            var boardavatar = $(this).parent().find("td.subject p a").attr("href");
            if(avatarlist[boardavatar] != "blank"){
                $(this).find("img").attr("src",avatarlist[boardavatar]).attr("width","24px").attr("height","24px");
            }
        });
    }
}
loadavs();

function showbody() {
    $("table.subtopics tr").each(function(){
        var username = $(this).find("td.subject div p a:not(.navPages):first");
        var usernameAvatar = "http://avatars.sploder.com/a/" + username.text().substr(0,1) + "/" + username.text().substr(1,1) + "/" + username.text() + "_24.png"
        $(this).find("td.icon2 img").attr("src", usernameAvatar.toLowerCase());
    });

    $("table.subtopics tr").each(function(){
        $(this).find("td.icon2 img").attr("width","24px").attr("height","24px")
        if ( $(this).find("td.subject div a img").length ) {
            if ( $(this).find("td.icon1 img[src*=my]").length ) {
                $(this).find("td").addClass("topicnew");
            }else{
                $(this).find("td").addClass("topicunread");
            }
            $(this).find("td img[alt*=New]").hide();
            var newlinktopic = $(this).find("td.subject div a img[alt=New]").parent().attr("href");
            $(this).find("td.subject div span a").attr("href",newlinktopic);
        }
    });
}


if($("tbody#category_1_boards").length){
    var i = 0;
    $("div.cat_bar").each(function(){
        $(this).addClass("cat_bar_boardindex");
    });
    $("tr[id*=board_].windowbg2").each(function(){
        $(this).addClass("boardheader");
        var boardId = $(this).attr("id").split("_")[1];
        $("body").after("<tr style=display:none; id=placeholder_subtopic_"+boardId+"></tr>");
    });

    $("tr[id*=placeholder_subtopic_]").each(function(){
        var ex_board = {"93":5,"8":5,"239":0,"137":0};
        var thisboard = $(this).attr("id").split("_")[2];
        var Tcount = 10;
        console.log(ex_board["93"]);
        if(ex_board[thisboard]  != undefined){ Tcount = ex_board[thisboard]; }
        if(Tcount > 0){
            $.ajax({
                url:"//forums.sploder.com/index.php?board="+thisboard+".0",
                type:"GET",
                success: function(data){
                    $("#placeholder_subtopic_"+thisboard+":first").html($(data).find("div#messageindex tbody").html());

                    if( $("#placeholder_subtopic_"+thisboard+"").length ) {
                        $( "#placeholder_subtopic_"+thisboard+" tr td:nth-child(1)" ).each(function() {
                            $(this).attr("width", "5%");
                        });
                        $( "#placeholder_subtopic_"+thisboard+" tr td:nth-child(2)" ).each(function() {
                            $(this).attr("width", "5%");
                        });

                        if($("tr#board_"+thisboard+"_children").length){ $("tr#board_"+thisboard+"_children").after("<tr id=subtopic_"+thisboard+"_ class=mainboard><td colspan=4 class=subtopics><div class=topic_table><table class=subtopics cellspacing=0><tbody><tr></tr></tbody></table></div></td></tr>"); }else{
                            $("tr#board_"+thisboard+"").after("<tr id=subtopic_"+thisboard+"_ class=mainboard><td colspan=4 class=subtopics><div class=topic_table><table class=subtopics cellspacing=0><tbody><tr></tr></tbody></table></div></td></tr>");
                        }
                        var content = $("#placeholder_subtopic_"+thisboard+":eq(0):first").html();
                        $("#subtopic_"+thisboard+"_ div table tbody tr").replaceWith(content);

                        $("#placeholder_subtopic_"+thisboard+":first").remove();
                        for (i = 0; i < 40-Tcount; i++) {
                            $("#subtopic_"+thisboard+"_ td div table tbody tr:eq("+Tcount+"):not(.windowbg2):not(.spacer)").remove();
                        }
                        showbody();
                        loadavs();
                    }
                }
            });
        }
    });
}

--- End code ---


➤ Easier Featuring - last updated 01/Apr/2019 - v0.1.1
example: https://i.imgur.com/sVoPztW.png

--- Code: ---// ==UserScript==
// @name         Cyan's Sploder Addons - [Easier Featuring]
// @require      http://code.jquery.com/jquery-3.3.1.min.js
// @namespace    http://tampermonkey.net/
// @version      0.1.1 - 01/Apr/2019
// @author       Cyan
// @match        http://www.sploder.com/games/*
// ==/UserScript==

if (window.location.href.indexOf(".com/games/members/") > -1) {
    localStorage.CEF_Feature = -1;
    $('body').append('<iframe onload="frameLoaded();" id="adminPage" frameBorder="0" width="0" height="0" src="http://www.sploder.com/games/admin/0/"></iframe>');
    $('div.sharebar').after('<input onclick="localStorage.CEF_Feature=1;setTimeout(function(){location.reload();},150);" type=button value=" Feature this game " style="margin-right:10px"></input> • <input onclick="localStorage.CEF_Feature=0;setTimeout(function(){location.reload();},150);" type=button value=" Unfeature this game " style="margin-left:10px"></input><br><br>');
    localStorage.CEF_gameId = $('param[name=flashvars]').val().split("=")[1];
    localStorage.CEF_gameName = $('div#content > h3:first').text();
    localStorage.CEF_gameUser = $('div#content > h4:first > a').text();
}

if (window.location.href.indexOf(".com/games/admin/") > -1) {
    if (localStorage.CEF_gameId != 0) {
        $('body').find('input[type=checkbox]:first').attr("checked","checked");
        $('body').find('input[name*=game_]:first').attr("name","game_"+localStorage.CEF_gameId);
        $('body').find('input[name*=game_score_]:first').attr("name","game_score_"+localStorage.CEF_gameId);
        $('body').find('input[name*=game_name_]:first').attr("name","game_name_"+localStorage.CEF_gameId).attr("value",localStorage.CEF_gameName);
        $('body').find('input[name*=game_author_]:first').attr("name","game_author_"+localStorage.CEF_gameId).attr("value",localStorage.CEF_gameUser);
        $('body').find('input[name*=game_oldfeatured_]:first').attr("name","game_oldfeatured_"+localStorage.CEF_gameId);
        $('body').find('input[name*=game_oldscore_]:first').attr("name","game_oldscore_"+localStorage.CEF_gameId);
        $('body').find('input[type=checkbox]:first').attr("name","game_"+localStorage.CEF_gameId);
    }
    window.setInterval(function(){
        if(localStorage.CEF_Feature==1){
            $('body').find('input[name*=game_oldfeatured_]:first').attr("value",0);
            $('body').find('input[name*=game_score_]:first').attr("value",1);
            $('input[value*=Feature]').click();
        }
        if(localStorage.CEF_Feature==0){
            $('body').find('input[name*=game_oldfeatured_]:first').attr("value",1);
            $('body').find('input[name*=game_score_]:first').attr("value",0);
            $('input[value*=Feature]').click();
        }
    }, 100);
    localStorage.CEF_gameId = 0;
    localStorage.CEF_gameName = 0;
    localStorage.CEF_gameUser = 0;
    localStorage.CEF_Feature = -1;
}

--- End code ---

sticki:
TYVM

Benno MKII:
That's amazing, now if only you could make a script for thanking ;)

Master:
My phone won’t let me copy it. :8-/

Cyan:

--- Quote from: Benno MKII on January 07, 2019, 05:11 pm ---That's amazing, now if only you could make a script for thanking ;)

--- End quote ---
unfortunately, anything of that nature isn't possible with client side scripts.
I'm not sure why thanking isn't enabled on the forums though, since it comes with smf by default.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version