Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name SA:MP Auto post reply
- // @namespace SAMP
- // @description Auto reply on thread when it's possible
- // @include http://forum.sa-mp.com/showthread.php*
- // @include https://forum.sa-mp.com/showthread.php*
- // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
- // @version 1
- // @grant none
- // @authro coapsyfactor
- // ==/UserScript==
- $(document).ready(function () {
- var form = $('#qrform'),
- regex = new RegExp(/[A-Z]*([0-9])\w+/g),
- errorMsg = null,
- waitTimeout = null;
- if (form.length == 0) {
- return;
- }
- form.on('submit', function (e) {
- var counter = 0, waitTime;
- errorMsg = {
- length: 0
- };
- try {
- clearTimeout(waitTimeout);
- } catch (e) {}
- var interval = setInterval(function () {
- if (counter == 10) {
- clearInterval(interval);
- counter = 0;
- return;
- }
- errorMsg = $('#qr_error_td li');
- if (errorMsg.length) {
- clearInterval(interval);
- errorMsg.filter(function () {
- return regex.test($(this).html());
- });
- waitTime = parseInt(new String($(errorMsg[0]).text()).match(/[A-Z]*([0-9])\w+/g)[1]) + 3;
- if (!waitTimeout) {
- var timeout = setTimeout(function () {
- clearInterval(interval);
- clearTimeout(timeout);
- if ($(form).find('textarea').val().length > 4) {
- $(form).submit();
- }
- }, waitTime * 1000);
- }
- } else {
- counter++;
- }
- }, 1000);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment