LZT_RandomMessage

RandomMessage on big threads

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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.

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

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