hwm_spam

hwm spam script

// ==UserScript==
// @name         hwm_spam
// @namespace    http://tampermonkey.net/
// @version      2.0
// @author       Лосось
// @description  hwm spam script
// @match        /^https{0,1}:\/\/((www|qrator|my)\.(heroeswm|lordswm)\.(ru|com)|178\.248\.235\.15)\/(sms|sms-create|home).php*/
// @include      /^https{0,1}:\/\/((www|qrator|my)\.(heroeswm|lordswm)\.(ru|com)|178\.248\.235\.15)\/(sms|sms-create|home).php*/
// @license MIT
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // local storage vars
    let spam_list = JSON.parse(localStorage.getItem('spam_list'));
    let subjectLS = JSON.parse(localStorage.getItem('subjectLS'));
    let msgLS = JSON.parse(localStorage.getItem('msgLS'));
    let timerLS = Number(JSON.parse(localStorage.getItem('timerLS')));
    let toogleStopSpam = JSON.parse(localStorage.getItem('toogleStopSpam'));
    let toogleStopSpamVar = toogleStopSpam;
    let isShowScriptLS = JSON.parse(localStorage.getItem('hwmSpamScriptToogle'));
    let isShowScript = isShowScriptLS;

    if (!spam_list) {
        localStorage.setItem('spam_list', JSON.stringify([]));
        location.reload();
    }
    if (!subjectLS) {
        localStorage.setItem('subjectLS', JSON.stringify('введите тему'));
        location.reload();
    }
    if (!msgLS) {
        localStorage.setItem('msgLS', JSON.stringify('введите сообщение'));
        location.reload();
    }
    if (!timerLS) {
        localStorage.setItem('timerLS', JSON.stringify(75000));
        location.reload();
    }
    if (toogleStopSpam === null) {
        localStorage.setItem('toogleStopSpam', JSON.stringify(false));
        location.reload();
    }
    if (!isShowScriptLS) {
        localStorage.setItem('hwmSpamScriptToogle', JSON.stringify(false));
    }

    // ui buttons

    let showScriptBtn = document.createElement('button');
    showScriptBtn.innerText = 'Spam script';
    showScriptBtn.style = 'position: absolute; left: 10px; top: 2px; z-index: 999998; '

    let stopSpamBtn = document.createElement('button');
    stopSpamBtn.innerText = toogleStopSpam ? 'Остановить спам' : 'Продолжить спам';
    stopSpamBtn.style = 'position: absolute; left: 100px; top: 2px; z-index: 999997;';
    
    let block = document.createElement('div');
    block.style = 'position: absolute; left: 10px; top: 24px; z-index: 999999; width: 400px; min-height: 50px; background: rgb(238,174,202); background: radial-gradient(circle, rgba(238,174,202,1) 0%, rgba(148,187,233,1) 100%); display: flex; flex-direction: column; align-items: center;';
    block.style.visibility = isShowScript ? 'visible' : 'hidden';

    let addInputNicks = document.createElement('input');
    addInputNicks.style = 'width: 400px; height: 50px; background: transparent; border: 1px solid white; color: white; font-size: 16px; margin-bottom: 3px;';
    addInputNicks.placeholder = 'вставьте или введите никнеймы';

    let timerBlock = document.createElement('div');
    timerBlock.style = 'display: flex; flex-direction: column; align-items: center; gap: 5px';

    let timer = document.createElement('div');
    timer.innerText = `Таймер ${timerLS / 1000} сек`
    timer.style = 'color: white';

    let setTimerBtn = document.createElement('input');
    setTimerBtn.style = 'border: 1px solid white; width: 120px; height: 30px; background: transparent; color: white; border-radius: 10px; margin-top: 5px;';
    setTimerBtn.placeholder = 'введите таймер';

    let subjectInput = document.createElement('input');
    subjectInput.value = subjectLS;
    subjectInput.placeholder = 'введите тему';
    subjectInput.style = 'width: 400px; height: 50px; background: transparent; border: 1px solid white; color: white; font-size: 16px; margin-bottom: 3px;';

    let msgInput = document.createElement('textarea');
    msgInput.value = msgLS;
    msgInput.placeholder = 'введите сообщение';
    msgInput.style = 'width: 400px; height: 150px; background: transparent; border: 1px solid white; color: white; font-size: 16px; margin-bottom: 3px;';

    let addMessageBtn = document.createElement('button');
    addMessageBtn.innerText = 'Добавить/изменить сообщение';
    addMessageBtn.style = 'border: 1px solid white; background: pink; width: 250px; height: 30px; margin-top: 1px; margin-bottom: 3px; cursor: pointer; font-weigth: bold; color: white; border-radius: 10px;'

    let uiList = document.createElement('ol');
    uiList.style = '';

    let deleteAllNicksBtn = document.createElement('button');
    deleteAllNicksBtn.innerText = 'удалить весь список';
    deleteAllNicksBtn.style = 'border: 1px solid white; width: 140px; height: 50px; background: transparent; color: white; cursor: pointer; border-radius: 10px;';
    deleteAllNicksBtn.addEventListener('click', () => {
        let conf = confirm('точно удалить весь список?');
        if (!conf) return;
        spam_list = [];
        localStorage.setItem('spam_list', JSON.stringify(spam_list));
        location.reload();
    });

    showScriptBtn.addEventListener('click', () => {
        isShowScript = !isShowScript;
        localStorage.setItem('hwmSpamScriptToogle', isShowScript);
        block.style.visibility = isShowScript ? 'visible' : 'hidden';
    })

    stopSpamBtn.addEventListener('click', () => {
        toogleStopSpamVar = !toogleStopSpamVar
        localStorage.setItem('toogleStopSpam', toogleStopSpamVar);
        location.reload();
    })

    setTimerBtn.addEventListener('keypress', (e) => {
         if (e.key === 'Enter') {
         localStorage.setItem('timerLS', JSON.stringify(Number(setTimerBtn.value) * 1000));
         location.reload();
         }
    })

    subjectInput.addEventListener('keypress', (e) => {
      if (e.key === 'Enter') {
         localStorage.setItem('subjectLS', JSON.stringify(subjectInput.value));
         location.reload();
      }
    })

    addMessageBtn.addEventListener('click', () => {
         localStorage.setItem('msgLS', JSON.stringify(msgInput.value));
         location.reload();
    })

    addInputNicks.addEventListener('keypress', (e) => {
        if (e.key === 'Enter') {
            let text = addInputNicks.value;
            text = text.split(',');
            text = text.filter(el => el.length !== 0);
            text = text.map(el => el.trim());
            spam_list = [...spam_list, ...text];
            localStorage.setItem('spam_list', JSON.stringify(spam_list));
            location.reload();
        }
    })

    spam_list.forEach(el => {
        let li = document.createElement('li');
        let nickname = document.createElement('span');
        let deleteNickBtn = document.createElement('button');
        deleteNickBtn.style = 'border: 1px dotted red; border-radius: 50%; cursor: pointer; margin-left: 5px;'
        deleteNickBtn.innerText = 'x';
        nickname.innerText = el;
        nickname.style = 'color: white;';
        deleteNickBtn.addEventListener('click', () => {
            spam_list = spam_list.filter(nick => nick !== el);
            localStorage.setItem('spam_list', JSON.stringify(spam_list));
            location.reload();
        })
        li.appendChild(nickname);
        li.appendChild(deleteNickBtn);
        uiList.appendChild(li);
    })

    timerBlock.appendChild(setTimerBtn);
    timerBlock.appendChild(timer);

    block.appendChild(addInputNicks);
    block.appendChild(subjectInput);
    block.appendChild(msgInput);
    block.appendChild(addMessageBtn);
    block.appendChild(deleteAllNicksBtn);
    block.appendChild(timerBlock);
    block.appendChild(uiList);
    
    document.body.appendChild(showScriptBtn);
    document.body.appendChild(stopSpamBtn);
    document.body.appendChild(block);

    if (toogleStopSpam === false) return;

    if (location.href === 'https://my.lordswm.com/sms.php') {
        if (spam_list.length === 0) return;
        location.replace('https://my.lordswm.com/sms-create.php');
    }

    if (location.href === 'https://www.heroeswm.ru/sms.php') {
        if (spam_list.length === 0) return;
        location.replace('https://www.heroeswm.ru/sms-create.php');
    }

    if (location.href === 'https://my.lordswm.com/sms-create.php') {
        if (spam_list.length === 0) return;
        let nickInput = document.getElementsByName("mailto")[0].value = spam_list[0];

        let subjectInput = document.getElementsByName("subject")[0].value = subjectLS;

        let msgInput = document.getElementsByName("msg")[0].value = msgLS;

        setTimeout(() => {
            spam_list.shift();
            localStorage.setItem('spam_list', JSON.stringify(spam_list));
            let submitBtn = document.getElementsByName("subm")[0].click();
        }, timerLS);
    }

    if (location.href === 'https://www.heroeswm.ru/sms-create.php') {
        if (spam_list.length === 0) return;
        let nickInput = document.getElementsByName("mailto")[0].value = spam_list[0];

        let subjectInput = document.getElementsByName("subject")[0].value = subjectLS;

        let msgInput = document.getElementsByName("msg")[0].value = msgLS;

        setTimeout(() => {
            spam_list.shift();
            localStorage.setItem('spam_list', JSON.stringify(spam_list));
            let submitBtn = document.getElementsByName("subm")[0].click();
        }, timerLS);
    }


})();