Ninja text

auto ninja text

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        Ninja text
// @namespace   awkward_potato
// @description auto ninja text
// @include     https://forums.oneplus.net/threads/144608/*
// @version     1.0
// @author      awkward_potato
// @grant       none
// ==/UserScript==
$('input.primary:first').click(function() {
    var frame = document.getElementsByClassName('redactor_textCtrl')[0].contentWindow.document.getElementsByTagName("body")[0];
    var a = document.getElementsByClassName('redactor_textCtrl')[0].contentWindow.document.getElementsByTagName("p");
    
    a[0].innerHTML = '[COLOR=#ffffff]'+a[0].innerHTML;
    a[a.length - 1].innerHTML = a[a.length - 1].innerHTML +'[/COLOR]';
    
    var message = frame.innerHTML;
    var p2 = message.match(/(\[\/QUOTE\])/igm);
    
    var numMisc = (p2 === null) ? 0 : p2.length;
    message = message.replace(/(\[QUOTE[\s\S]*?\])/igm, '[QUOTE][COLOR=#ecebea]');
    message = message.replace(/(style\=\"color\: \#ffffff\")/igm,'');
    
    for (var i = 0; i < numMisc; i++) {message = message.replace(/(\[\/QUOTE\])/im, '[/COLOR]'+p2[i]);}
    frame.innerHTML = message;
});