LZT_RandomMessage

RandomMessage on big threads

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

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.

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

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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