StopMultipleMessageForumOnly

Block spam on over-clicking

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

Advertisement:

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

Advertisement:

// ==UserScript==
// @name    StopMultipleMessageForumOnly
// @namespace Forum
// @author    Kmaschta, MockingJay
// @date    19/09/2015
// @version   1.2.1
// @description Block spam on over-clicking
// @match   https://www.dreadcast.net/Forum*
// @match   https://www.dreadcast.net/FAQ*
// @require   http://code.jquery.com/jquery-latest.min.js
// @grant   none
// ==/UserScript==

// CHANGELOG
// 1.1: Set cursor to 'wait' when locked

jQuery.noConflict();

function unlock_button(elem, onclick, content) {
    elem.attr('onclick', onclick);
    elem.removeAttr('style');
    elem.html(content);
    elem.removeClass('locked');
}

function lock_button(elem) {
    // Save event action
    var onclick = elem.attr('onclick');
    var content = elem.html();

    // Lock button
    elem.removeAttr('onclick');
    elem.unbind('click');
    elem.html('Verrouillé');
    elem.attr('style', 'cursor: wait;');
    elem.addClass('locked');

    // Still unlock after 5s
    var tid = setTimeout(function() {
        if(elem.hasClass('locked')) {
            unlock_button(elem, onclick, content);
            elem.unbind('dblclick');
        }
    }, 5000);

    // Unlock button on dbl click
    elem.dblclick(function() {
        clearTimeout(tid);
        unlock_button(elem, onclick, content);
        // Rebind lock on click
        elem.click(function() { lock_button(elem); });
    });
}

$(document).ready( function() {
    // Forum "Poster" button
    $('#zone_reponse .bouton.poster').not('.locked').click(function() {
        lock_button($(this));
    });

    // IG "Envoyer" response message
    /*$(document).ajaxComplete(function() {
        $('.zone_reponse .btnTxt').not('.locked').unbind('click').click(function() {
            lock_button($(this));
        });
    });*/

    console.log('StopMultipleMessage on');
});