LZT_RandomMessage

RandomMessage on big threads

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         LZT_RandomMessage
// @namespace    MeloniuM/LZT
// @version      1.0
// @description  RandomMessage on big threads
// @author       MeloniuM
// @match        https://zelenka.guru/threads/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=zelenka.guru
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    $("<style>").prop("type", "text/css").html(".RandomMessage {background-color: rgb(34 51 40) !important;};").appendTo("head");


    $(document).ready(function(){
        let pages = $('.PageNav nav:has(.currentPage[rel="start"]) a');
        if (pages.length > 1) {
            let page = pages[Math.floor(Math.random() * (pages.length - 2) + 2)];
            XenForo.ajax(page.href, {}, function(ajaxData) {
                if (!XenForo.hasResponseError(ajaxData)) {
                    let messages = $(ajaxData.templateHtml).filter('.message');
                    let message = $(messages[Math.floor(Math.random() * messages.length)]);
                    message.addClass('RandomMessage');
                    message.xfInsert('appendTo', '#messageList', 'xfFadeIn', 0).xfActivate();
            }
            })
        }
    })
})();