Force Full Editor

Forces WYSIWYG editors to always use the full editor if possible

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name Force Full Editor
// @description Forces WYSIWYG editors to always use the full editor if possible
// @author qsniyg
// @version 0.2
// @namespace Violentmonkey Scripts
// @include *
// @grant none
// @run-at document-start
// ==/UserScript==

(function() {
    var ck;
    Object.defineProperty(window, "CKEDITOR", {
        get: function() {
            if (ck && ck.replace && !ck.replace.injected) {
                var oldreplace = ck.replace;
                oldreplace.injected = true;
                ck.replace = function() {
                    if (arguments.length >= 2) {
                        if (typeof arguments[1] === "object") {
                            delete arguments[1]["toolbarGroups"];
                            delete arguments[1]["toolbar"];
                            delete arguments[1]["removeButtons"];
                        }
                    }
                    return oldreplace.apply(this, arguments);
                };
            }
            return ck;
        },
        set: function(x) {
            ck = x;
        }
    });
    var jq = null;
    Object.defineProperty(window, "jQuery", {
        get: function() {
            return jq;
        },
        set: function(x) {
            jq = x;
            if (jq && jq.fn) {
                var kendo;
                Object.defineProperty(jq.fn, "kendoEditor", {
                    get: function() {
                        if (kendo) {
                            var oldkendo = kendo;
                            kendo = function() {
                                if (arguments.length >= 1 && typeof arguments[0] === "object") {
                                    if (!arguments[0].tools) {
                                        arguments[0].tools = [];
                                    }
                                    
                                    var tools = [
                                        "bold", "italic", "underline", "strikethrough", "subscript", "superscript",
                                        "fontName", "fontSize", "foreColor", "backColor",
                                        "justifyLeft", "justifyCenter", "justifyRight", "justifyFull",
                                        "insertUnorderedList", "insertOrderedList", "indent", "outdent",
                                        "createLink", "unlink", "insertImage", "insertFile",
                                        "tableWizard", "createTable", "addColumnLeft", "addColumnRight", "addRowAbove", "addRowBelow", "deleteRow", "deleteColumn",
                                        "formatting", "cleanFormatting",
                                        "insertHtml", "viewHtml",
                                        "print", "pdf"
                                    ];
                                    
                                    for (var i = 0; i < tools.length; i++) {
                                        var tool = tools[i];
                                        
                                        var in_array = false;
                                        for (var j = 0; j < arguments[0].tools.length; j++) {
                                            var atool = arguments[0].tools[j];
                                            if (typeof atool === "string") {
                                                if (atool === tool) {
                                                    in_array = true;
                                                    break;
                                                }
                                            } else {
                                                if (atool.name === tool) {
                                                    in_array = true;
                                                    break;
                                                }
                                            }
                                        }
                                        
                                        if (in_array)
                                            continue;
                                        
                                        arguments[0].tools.push(tool);
                                    }
                                }
                                return oldkendo.apply(this, arguments);
                            }
                        }
                        return kendo;
                    },
                    set: function(x) {
                        kendo = x;
                    }
                })
            }
        }
    });
})();