Fxp Message scribble

Spam those douchebags

Verzia zo dňa 25.10.2020. Pozri najnovšiu verziu.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, Greasemonkey alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey alebo Userscripts.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie správcu používateľských skriptov.

(Už mám správcu používateľských skriptov, nechajte ma ho nainštalovať!)

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

(Už mám správcu používateľských štýlov, nechajte ma ho nainštalovať!)

// ==UserScript==
// @name         Fxp Message scribble
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Spam those douchebags
// @author       MrTarnegol
// @match        https://www.fxp.co.il/*
// @grant        none
// ==/UserScript==

'use strict';

const SIZES = 5;
window.SIZES = SIZES;

const getText = () => {
    const selector = '.cke_editor iframe'
    const element = $(selector)[0];
    if (element !== undefined) {
        const doc = element.contentWindow.document;
        return doc.getElementsByClassName("forum")[0].innerText;
    }
    return '';
}
window.getText = getText;

const setText = (text) => {
    const selector = '.cke_editor iframe'
    const element = $(selector)[0];
    if (element !== undefined) {
        var doc = element.contentWindow.document;
        doc.getElementsByClassName("forum")[0].innerText = text;
        return true;
    }
    return false;
}
window.setText = setText;

const randomSize = () => {
    return Math.floor(Math.random() * SIZES) + 1;
}
window.randomSize = randomSize;

const letterWithSize = (letter, size = randomSize()) => {
    return letter != ' ' ? `[SIZE=${size}]${letter}[/SIZE]` : ' ';
}
window.letterWithSize = letterWithSize;

const scribbleText = (text) => {
    return text.split('').reduce((a, b) => a + letterWithSize(b), '');
}
window.scribbleText = scribbleText;

const scribble = () => {
    console.log('MrTarnegol scribbling begin!');

    const text = getText();
    const scribbled = scribbleText(text);
    setText(scribbled);

    CKEDITOR.tools.callFunction(5, this);
}
window.scribble = scribble;

const scribbleButton = () => {
    const button = document.createElement('button');
    button.style.position = 'fixed';
    button.style.bottom = '0'; //'200px';
    button.style.left = 0;
    button.style.backgroundColor = '#73AD21';
    button.style.padding = '15px 40px';
    button.style.fontSize = '18px';
    button.innerText = 'ערבל טקסט';
    button.onclick = scribble;
    return button;
}

const start = () => {
    if (window.top == window.self) {
        const btn = scribbleButton();
        document.body.appendChild(btn);
    }
}

start();