Dev Shoutbox/Forum Tampermonkey scripts

Discussion in 'Hobbies' started by Dolph1n, Oct 18, 2017.

  1. Dolph1n

    Dolph1n Time is an adventure- if you know when to look. VIP

    With the recent ban on shoutbox bots, I decided to rebel against the administration and make this thread so that people with cool scripts for the website/sb can share them for us all to use.

    To kick things off, I'll post a script I wrote that gives you a desktop notification whenever someone mentions your name in shoutbox.

    Make sure that you have Tampermonkey installed, and this is the script:

    https://pastebin.com/raw/FkfArHBP

    Make sure you modify the name strings on lines 34, 36, and 38.

    also @XpropIayer i stole some of your code, sorry bro
     
    Last edited: Oct 18, 2017
    • Useful Useful x 5
    • Like Like x 1
    • Funny Funny x 1
    • Informative Informative x 1
  2. Adrian Shephard

    Adrian Shephard VIP Silver

    Very useful
     
    • Like Like x 1
  3. Xproplayer

    Xproplayer VIP Silver

    lol... thats what the code started as. @Yatty wrote it. Yours is ugly af.

    But w/e code is code.

    I'm probably going to turn my combobreaker into an alerter so I can break chains still, but the code was written by @Opalium and wouldn't release without his permission as it was a more of a proof of concept.
     
    • Like Like x 2
  4. Yatty ☄️

    Yatty ☄️ Yatt'em VIP Silver

    No easy to use customizable settings area? garbage.

    Btw since I'm nice I'll paste the original code back in here.
    Code:
    // ==UserScript==
    // @name         Taigachat Notifier
    // @namespace    seriousgmod.com
    // @version      1.2.3
    // @description  Alerts you when your name is mentioned
    // @author       Lamp(OC)/Yatty
    // @include      https://www.seriousgmod.com/chat/
    // @include      https://www.seriousgmod.com/chat/popup
    // @include      https://www.seriousgmod.com/
    // @grant        none
    // ==/UserScript==
    
    // ==Settings==
    var yourName = "Yatty"; // Your name or the text that will trigger the notification (not case-sensitive)
    var changeFaviconEnabled = true; // Enable/disable changing the favicon when notifying
    var soundEnabled = true; // Enable/disable playing sound when notifying
    var PushNotificationEnabled = true; // Enable/disable sending push/desktop/browser notification when notifying
    var modifyRefreshRateEnabled = true; // Enable/disable modifying the chat refresh rate for faster response and greater reliability
    var customRefreshRate = 0.1; // The new refresh rate to use when modifying refresh rate is enabled; Time in seconds between chat refreshes
    var soundFileURL = "http://a.pomf.cat/sqlnkb.mp3"; // URL to notification sound file
    var alertFaviconURL = "http://www.iconj.com/ico/i/2/i27q0ochtu.ico"; // URL to notification favicon file
    // ============
    
    var msg;
    var isNotified = false;
    var sound = new Audio(soundFileURL);
    if(PushNotificationEnabled) checkNotification();
    if(modifyRefreshRateEnabled) {setTimeout(function () {taigachat.refreshtime = customRefreshRate;
                                                          taigachat.focusedRefreshTime = customRefreshRate;
                                                          taigachat.unfocusedRefreshTime = customRefreshRate;
                                                          taigachat.tabUnfocusedRefreshTime = customRefreshRate;
                                                         },1000);}
    window.onblur = denotify;
    
    setInterval(function() {
        msg = $(".taigachat_messagetext").last()[0].innerText;
        if (msg.toLowerCase().includes(yourName.toLowerCase())) notify();
    }, 1000);
    
    function notify() {
        if (!isNotified) {
            if (changeFaviconEnabled) changeFavicon(alertFaviconURL);
            if (soundEnabled) sound.play();
            if (PushNotificationEnabled) {var idk = new Notification('“'+msg+'”');}
        }
        isNotified = true;
    }
    
    function denotify() {
        if (isNotified) {
            if (changeFaviconEnabled) changeFavicon('/favicon.ico');
            isNotified = false;
        }
    }
    
    // http://stackoverflow.com/a/2995536
    document.head = document.head || document.getElementsByTagName('head')[0];
    function changeFavicon(src) {
        var link = document.createElement('link'),
            oldLink = document.getElementById('dynamic-favicon');
        link.id = 'dynamic-favicon';
        link.rel = 'shortcut icon';
        link.href = src;
        if (oldLink) {
            document.head.removeChild(oldLink);
        }
        document.head.appendChild(link);
    }
    
    // derived from https://jsfiddle.net/3sdr9Lqj/2/
    function checkNotification() {
        if (!("Notification" in window)) {
            alert("This browser does not support push notifications.");
        } else if (Notification.permission !== 'denied') {
            Notification.requestPermission(function(permission) {
                if (!('permission' in Notification)) {
                    Notification.permission = permission;
                }
    
            });
        }
    }
    Also ontop of that I have a few others that I'll just show off~ These are mainly related to just SGM but I have pages of active scripts for other sites as well.

    [​IMG] - Makes multipage threads into one facebook-esk page(pretty nice for things like the faces thread and a few other threads)

    [​IMG] - Allows anyone with this script to view custom set names that allow for bbcode/html support(also works in SB~)

    [​IMG] - Pretty self explanitory~ Autorates posts made by white/blacklisted users on posts. Don't really use this one too much but yea~ Powerful in the wrong hands?

    [​IMG] - Still not 100% working but allows for multiple instances of SB rooms(other rooms aren't logged like main SB) Yea~ I doubt I'll ever really release this one. Easily exploited and just all around trollish in nature.

    [​IMG] - Hides ignored members in SB. Kinda broken but requires effort to fix. idc enough about it to fix.
     
    • Winner Winner x 2
    • Like Like x 1
    • Disagree Disagree x 1
  5. Dolph1n

    Dolph1n Time is an adventure- if you know when to look. VIP

    For a minute there I wondered why you rated my post funny.
     
    • Funny Funny x 1
  6. Xproplayer

    Xproplayer VIP Silver

    CAn you share the player nicknames?
    Also how do you do the white-listing, is it by username or user id?
     
    • Like Like x 2
  7. Yatty ☄️

    Yatty ☄️ Yatt'em VIP Silver

    Maybe one day~
    Username for now but user id might be the better choice
     
  8. Yatty ☄️

    Yatty ☄️ Yatt'em VIP Silver

    By popular demand. I figured I'd actually release this since it's somewhat done. However I will be removing the database side from the code to prevent issues. It's all client-sided.
    Code:
    // ==UserScript==
    // @name         SGM - Custom Usernames
    // @version      1.3
    // @description  Replaces Usernames on Profile Page and other pages
    // @author       sapphy(Idea)/Yatty
    // @match          https://www.seriousgmod.com/*
    // @grant        none
    
    // ==/UserScript==
    (function() {
        'use strict';
    
        // [ID, Replacement, If the original name should be replaced]
        var replacements = [
            [10789, "Yattem", false],
            [138, "Sky", false],
            [6775, "Xboo", false]
        ];
    
        function replace() {
            var usernames = document.getElementsByClassName('username');
            main:
            for (var i = 0; i < usernames.length; ++i) {
                var item = usernames[i].children[0];
                if (item) {
                    if (usernames[i].href) {
                        var id = usernames[i].href.split(".").slice(-1)[0].split("/")[0];
                        for (var i2 = 0; i2 < replacements.length; ++i2) {
                            var replacement = replacements[i2];
                            if (id == replacement[0]) {
                                if (!item.innerHTML.includes(replacement[1])) {
                                    if(replacement[2]){
                                        item.innerHTML = replacement[1];
                                    } else {
                                        item.innerHTML = item.innerHTML + " <span style=\"color: grey;\">(" + replacement[1] + ")</span>";
                                    }
                                }
                            }
                        }
                    } else {
                        if (usernames[i].tagName == "H1") {
                            id = window.location.href.split("/").slice(-2)[0].split(".").slice(-1)[0];
                            for (var i2 = 0; i2 < replacements.length; ++i2) {
                                var replacement = replacements[i2];
                                if (id == replacement[0]) {
                                    if (!item.innerHTML.includes(replacement[1])) {
                                        if(replacement[2]){
                                            item.innerHTML = replacement[1];
                                        } else {
                                            item.innerHTML = item.innerHTML + " <span style=\"color: grey;\">(" + replacement[1] + ")</span>";
                                        }
                                    }
                                }
                            }
                        }
                        if (usernames[i].tagName == "H3") {
                            var id = item.href.split(".").slice(-1)[0].split("/")[0];
                            for (var i2 = 0; i2 < replacements.length; ++i2) {
                                var replacement = replacements[i2];
                                if (id == replacement[0]) {
                                    if (!item.innerHTML.includes(replacement[1])) {
                                        if(!item.className.includes("StatusTooltip")){
                                            if(replacement[2]){
                                                item.innerHTML = replacement[1];
                                            } else {
                                                item.innerHTML = item.innerHTML + " <span style=\"color: grey;\">(" + replacement[1] + ")</span>";
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    
        replace();
    
        setInterval(function() {
            replace();
        }, 10);
    })();
     
    • Winner Winner x 3
  9. Xproplayer

    Xproplayer VIP Silver

    like
     
    • Like Like x 2
    • Informative Informative x 1
  10. Xproplayer

    Xproplayer VIP Silver

    Someone help me come up with something funny to do with this. I'm thinking perhaps messages with keywords get jumbod?

    [​IMG]
     
  11. Xproplayer

    Xproplayer VIP Silver

    Updated proper notifier, won't spam notifications anymore and enables local taigachat modification. To edit please change var yourname and enable / disable sound, push notifications, and change favicon




    https://hastebin.com/cuhupadini.hs


    Code:
    // ==UserScript==
    // @name         Taigachat Notifier Clean
    // @namespace    seriousgmod.com
    // @version      2.0
    // @description  Alerts you when your name is mentioned
    // @author       Lamp(OC)/Yatty/ Xproplayer
    // @include      https://www.seriousgmod.com/chat/
    // @include      https://www.seriousgmod.com/chat/popup
    // @include      https://www.seriousgmod.com/
    // @grant        none
    // ==/UserScript==
    
    // ==Settings==
    var yourName = "xpro"; // Your name or the text that will trigger the notification (not case-sensitive)
    var changeFaviconEnabled = true; // Enable/disable changing the favicon when notifying
    var soundEnabled = true; // Enable/disable playing sound when notifying
    var PushNotificationEnabled = false; // Enable/disable sending push/desktop/browser notification when notifying
    var modifyRefreshRateEnabled = true; // Enable/disable modifying the chat refresh rate for faster response and greater reliability
    var customRefreshRate = 1; // The new refresh rate to use when modifying refresh rate is enabled; Time in seconds between chat refreshes
    var soundFileURL = "http://a.pomf.cat/sqlnkb.mp3"; // URL to notification sound file
    var alertFaviconURL = "http://a.pomf.cat/rlnuys.ICO"; // URL to notification favicon file
    // ============
    
    if(PushNotificationEnabled) checkNotification();
    
    var msg;
    var ding;
    var isNotified = false;
    var sound = new Audio(soundFileURL);
    var msghtml;
    
    
    if(modifyRefreshRateEnabled) {setTimeout(function () {taigachat.refreshtime = customRefreshRate;
                                                          taigachat.focusedRefreshTime = customRefreshRate;
                                                          taigachat.unfocusedRefreshTime = customRefreshRate;
                                                          taigachat.tabUnfocusedRefreshTime = customRefreshRate;
                                                         },1000);}
    window.onblur = denotify;
    
    
    setInterval(function() {
        msg = $(".taigachat_messagetext").last()[0].innerText;
        if (msg.toLowerCase().includes(yourName.toLowerCase()) && msg != ding) {
            $(".taigachat_messagetext").last()[0].style.fontSize = "large";
            notify();
        }
        ding = msg;
    
    }, 1000);
    
    
    
    function notify() {
        if (!isNotified) {
            if (changeFaviconEnabled) changeFavicon(alertFaviconURL);
            if (soundEnabled) sound.play();
            if (PushNotificationEnabled) {var idk = new Notification('“'+msg+'”');}
        }
        isNotified = true;
    }
    
    function denotify() {
        if (isNotified) {
            if (changeFaviconEnabled) changeFavicon('/favicon.ico');
            isNotified = false;
        }
    }
    
    
    document.head = document.head || document.getElementsByTagName('head')[0];
    function changeFavicon(src) {
        var link = document.createElement('link'),
            oldLink = document.getElementById('dynamic-favicon');
        link.id = 'dynamic-favicon';
        link.rel = 'shortcut icon';
        link.href = src;
        if (oldLink) {
            document.head.removeChild(oldLink);
        }
        document.head.appendChild(link);
    }
    
    function checkNotification() {
        if (!("Notification" in window)) {
            alert("This browser does not support push notifications.");
        } else if (Notification.permission !== 'denied') {
            Notification.requestPermission(function(permission) {
                if (!('permission' in Notification)) {
                    Notification.permission = permission;
                }
    
            });
        }
    }
    
    $(document).ready(function() {
        taigachat.canModify = true;
        taigachat.canModifyAll = true;
    });
     
    • Confusing Confusing x 1
  12. TLCFanboy

    TLCFanboy (◕‿◕✿) VIP Bronze

    Does anyone happen to have the text color changer and the new posts on the full shout box?

    I deleted tamper monkey by an accident and lost all of my scripts :(

    Oh and the lines to add a image to the notifier @Xproplayer
     
  13. Xproplayer

    Xproplayer VIP Silver

    An image to the notifier? Also those scripts should be in this thread.