LZT_RandomMessage

RandomMessage on big threads

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

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