Twitter ARPLS

معالجة نص التغريدة بالتدقيق الإملائي والتشكيل وغيرها من الأدوات

当前为 2020-02-18 提交的版本,查看 最新版本

// ==UserScript==
// @name            Twitter ARPLS
// @description     معالجة نص التغريدة بالتدقيق الإملائي والتشكيل وغيرها من الأدوات
// @version         1.0
// @author          @RAKAN938
// @namespace       https://twitter.com/rakan938
// @match           https://twitter.com/*
// @match           https://mobile.twitter.com/*
// @connect         tahadz.com
// @connect         arabic-keyboard.org
// @require         https://code.jquery.com/jquery-latest.js
// @require         https://unpkg.com/popper.js@1
// @require         https://unpkg.com/tippy.js@5
// @resource        __CSS_THEME_TIP https://unpkg.com/[email protected]/themes/light-border.css
// @resource        __CSS_GOOGLE_ICON https://fonts.googleapis.com/icon?family=Material+Icons
// @grant           GM_getResourceText
// @grant           GM_addStyle
// @grant           GM.setValue
// @grant           GM.getValue
// @grant           GM.deleteValue
// @grant           GM.xmlHttpRequest
// ==/UserScript==

(function() {
    'use strict';

    $.fn.selectText = function() {
        var range, selection;
        return this.each(function() {
            if (document.body.createTextRange) {
                range = document.body.createTextRange();
                range.moveToElementText(this);
                range.select();
            } else if (window.getSelection) {
                selection = window.getSelection();
                range = document.createRange();
                range.selectNodeContents(this);
                selection.removeAllRanges();
                selection.addRange(range);
            }
        });
    };

    $.fn.clsAddDel = function(_b, ...args) {
         var _arg = [];
         for (var i = 0; i < args.length; ++i) _arg[i] = args[i].substr(1);
         return _b ? this.addClass(_arg.join(' ')) : this.removeClass(_arg.join(' '));
    };

    $.fn.textInHtml = function () {
        var tm = $("<pre />").html(this.eq(0).html());
        tm.find("div").contents().replaceWith(function() { return "\n" + this.innerHTML; });
        return tm.text();
    };

    String.prototype.removeTashkeel = function () {
         return this.replace(new RegExp('[\u0618\u0619\u061A\u064B\u064C\u064D\u064E\u064F\u0650\u0651\u0652\u0657\u065D]+', 'g'), '');
    };

    String.prototype.removeTatweel = function () {
         return this.replace(new RegExp('[\u0640]+', 'g'), '');
    };

    String.prototype.removeNonArbicSpace = function () {
         return this.replace(new RegExp('[^'+rgxAllArabic+'\\s]+', 'g'), '');
    };

    function unEmptyText(_str){
         if(_str === null) return false;
         if(_str === undefined) return false;
         if(typeof _str === 'undefined') return false;
         if(_str.length === 0) return false;
         if(_str.trim().length === 0) return false;
         return true;
    }

    function colorValues(e){if(e){if("transparent"===e.toLowerCase())return[0,0,0,0];if("#"===e[0])return e.length<7&&(e="#"+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]+(e.length>4?e[4]+e[4]:"")),[parseInt(e.substr(1,2),16),parseInt(e.substr(3,2),16),parseInt(e.substr(5,2),16),e.length>7?parseInt(e.substr(7,2),16)/255:1];if(-1===e.indexOf("rgb")){var r=document.body.appendChild(document.createElement("fictum")),t="rgb(1, 2, 3)";if(r.style.color=t,r.style.color!==t)return;if(r.style.color=e,r.style.color===t||""===r.style.color)return;e=getComputedStyle(r).color,document.body.removeChild(r)}return 0===e.indexOf("rgb")?(-1===e.indexOf("rgba")&&(e+=",1"),e.match(/[\.\d]+/g).map(function(e){return+e})):void 0}}

    function wScrollbar(c, b1, b2, n, w){
         var wd = (c + '::-webkit-scrollbar{width:' + w + 'px;}');
         var ws = function(t1, t2){
              return c + '::-webkit-scrollbar-' + t1 + '{background:' + t2 + ';' + (n ? 'border-bottom-left-radius:' + siz.cnr.bx + 'px;' : '') + '}';
         };
         return (w > 0 ? wd : '') + ws('track', b1) + ws('thumb', b2);
    }

    function hiGWid(h, w, b, o, h1){
         var ov = '';
         switch (o) {
              case 1:
                   ov = ' overflow:hidden;';
                   break;
              case 2:
                    ov = ' overflow:auto;';
                    break;
              default:
                    ov = '';
                    break;
         }
         return (h1 ? "height:"+h+"px; " : "")+"max-height:"+h+"px; width:"+w+(b ? "px" : "")+"; max-width:"+w+(b ? "px" : "")+";"+ov;
    }

    function dotCls(tx){
        return tx.substr(1);
    }

    function opCol(op, tx){
         return 'rgba('+(tx !== undefined ? tx : clr.prim_deft)+', '+op+')';
    }
    //=======================================================================================================================
    var elmTwet, msgInterval, xhrAjax, oldHtmlShrink, outTag = '?![^<>]*>', rgxAllArabic = '\u0600-\u06FF';
    window.tippyMainInstances = [], window.tippyCopyInstances = [], window.tippySpellcheckInstances = [];

    var cls = {
        sty: '#rakan938_arpls_style',
        btn: '.rakan938_arpls_btn',
        tip: '.rakan938_arpls_tip',
        wap: '.rakan938_arpls_wap',
        man: '.rakan938_arpls_man',
        hed: '.rakan938_arpls_hed',
        ico: '.rakan938_arpls_ico',
        nav: '.rakan938_arpls_nav',
        cnt: '.rakan938_arpls_cnt',
        txt: '.rakan938_arpls_txt',
        tit: '.rakan938_arpls_tit',
        hed_btns: '.rakan938_arpls_hed_btns',
        hed_sprite: '.rakan938_arpls_hed_sprite',
        material_ico: '.material-icons',
        select_ico: '.rakan938_arpls_selct_ico',
        hover_ico: '.rakan938_arpls_hover_ico',
        chosse_ico: '.rakan938_arpls_chosse_ico',
        dis_ico: '.rakan938_arpls_dis',
        btnOk: '.rakan938_arpls_btn_ok',
        btnClose: '.rakan938_arpls_btn_close',
        wait: '.rakan938_arpls_wait',
        wait_ico: '.rakan938_arpls_wait_ico',
        wait_txt: '.rakan938_arpls_wait_txt',
        wait_ext: '.rakan938_arpls_wait_ext',
        nav_shrink: '.rakan938_arpls_nav_shrink',
        nav_spellcheck: '.rakan938_arpls_nav_spellcheck',
        nav_tashkeel: '.rakan938_arpls_nav_tashkeel',
        nav_insertion: '.rakan938_arpls_nav_insertion',
        nav_settings: '.rakan938_arpls_nav_settings',
        ico_main: '.rakan938_arpls_ico_main',
        hover_main: '.rakan938_arpls_ico_main_hover',
        copy_hed: '.rakan938_arpls_copy_hed',
        copy_cnt: '.rakan938_arpls_copy_cnt',
        copy_fot: '.rakan938_arpls_copy_fot',
        copy_oky: '.rakan938_arpls_copy_oky',
        copy_ext: '.rakan938_arpls_copy_ext',
        settings: '.rakan938_arpls_settings',
        settings_even: '.rakan938_arpls_settings_even',
        settings_both: '.rakan938_arpls_settings_both',
        settings_both_title: '.rakan938_arpls_settings_both_title',
        settings_both_btn: '.rakan938_arpls_settings_both_btn',
        settings_title: '.rakan938_arpls_settings_title',
        settings_link: '.rakan938_arpls_settings_link',
        settings_link_last: '.rakan938_arpls_settings_link_last',
        settings_btn_rest: '.rakan938_arpls_settings_btn_rest',
        settings_btn_account: '.rakan938_arpls_settings_btn_account',
        msg: '.rakan938_arpls_msg',
        msg_txt: '.rakan938_arpls_msg_txt',
        msg_img: '.rakan938_arpls_msg_img',
        msg_ico: '.rakan938_arpls_msg_ico',
        finsh: '.rakan938_arpls_finsh',
        zoom: '.rakan938_arpls_zoom',
        zoom_up: '.rakan938_arpls_zoom_up',
        zoom_down: '.rakan938_arpls_zoom_down',
        zoom_rest: '.rakan938_arpls_zoom_rest',
        incorrect_word: '.rakan938_arpls_incorrect_word',
        incorrect_main: '.rakan938_arpls_incorrect_main',
        incorrect_title: '.rakan938_arpls_incorrect_title',
        incorrect_table: '.rakan938_arpls_incorrect_table'
    };

    var key = {
         copy: 'rakan938_arpls_key_msg_copy',
         paste: 'rakan938_arpls_key_msg_paste'
    }

    var clr = {
        back_deft: '255, 255, 255',
        text_deft: '51, 51, 51',
        prim_deft: '29, 161, 242',
        cl_shadow: '0, 0, 0',
        prim_clor: '1.00',
        icon_brdr: '0.50',
        text_scnd: '0.40',
        back_slct: '0.20',
        hovr_brdr: '0.10',
        back_prim: '0.08',
        msg_error: 'darkred',
        msg_faild: 'darkorange',
        msg_doney: 'darkgreen',
        msg_await: 'darkblue'
    };

    var siz = {
        box_wid: 300,
        box_hig: 150,
        nav_wid: 40,
        stg_hig: 20,
        cnr: {bx: 4, mn: 50},
        bar: 30,
        brd: 1,
        pdg: 5,
        scr: {nav: 5, cnt: 8},
        fnt: {tit: 12, txt: 14, ico: 18, min: 20}
    };

    var tim = {
         chk: 1000,
         msg: 4000,
         run: 10,
         cpy: 100,
         xhr: 30000
    };

    var ico = {
         main: 'format_shapes',
         close: 'close',
         ok: 'done',
         copy: 'file_copy',
         spellCheck: 'spellcheck',
         tashkeel: 'playlist_add_check',
         shrink: 'format_clear',
         settings: 'settings',
         error: 'error_outline',
         done: 'check_circle_outline',
         fail: 'warning',
         wait: 'hourglass_empty',
         zoomIn: 'text_rotate_up',
         zoomOut: 'text_rotation_down',
         rest: 'undo'
    };

    var   thm = 'light-border',
          ppa = 'process-ajax',
          dtt = 'data-title',
          sci = 'data-id',
          sco = 'data-old',
          scc = 'data-incorrect';

     var sty = ""
              + ".tippy-content{padding:0px 0px;}"
              + '.tippy-tooltip.'+thm+'-theme{border-color:'+opCol(clr.icon_brdr)+';}'
              + cls.tip+"{display:none;}"
              + cls.wap+"{"+hiGWid(siz.box_hig, siz.box_wid, 1, 0, 1)+" font-family:system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Ubuntu,'Helvetica Neue',sans-serif;}"
              + cls.man+"::after{content:''; clear:both; display:table;}"
              + cls.hed+"{background:"+opCol(clr.back_prim)+"; border-bottom:"+opCol(clr.icon_brdr)+" "+siz.brd+"px dashed; border-top-left-radius:"+siz.cnr.bx+"px; border-top-right-radius:"+siz.cnr.bx+"px; float:left; "+hiGWid((siz.bar - siz.brd), siz.box_wid, 1, 1, 1)+"}"
              + cls.tit+"{font-size:"+siz.fnt.tit+"px; float:right; padding:"+siz.pdg+"px; "+hiGWid((siz.bar - siz.brd), "calc(100% - "+((siz.bar * 2) + (siz.pdg * 2) + (siz.brd + 1))+"px)", 0, 1, 1)+" color:"+opCol(clr.text_scnd)+";}"
              + cls.hed_btns+"{float:left; "+hiGWid((siz.bar - siz.brd), (siz.bar * 2), 1, 1, 1)+" display:flex;}"
              + cls.hed_sprite+"{float:left; "+hiGWid((siz.bar - siz.brd), siz.brd, 1, 1, 1)+" border-left:"+opCol(clr.hovr_brdr)+" "+siz.brd+"px solid;}"
              + cls.material_ico+"{color:"+opCol(clr.icon_brdr)+"; font-size:"+siz.fnt.ico+"px; text-align:center; width:100%; height:100%; cursor:pointer; display:grid; align-items:center;}"
              + cls.ico_main+"{color:"+opCol(clr.prim_clor)+"; font-size:"+siz.fnt.min+"px;}"
              + cls.hover_main+"{background:"+opCol(clr.hovr_brdr)+"; transition:all 0.5s ease; border-radius:"+siz.cnr.mn+"px;}"
              + cls.select_ico+"{color:"+opCol(clr.prim_clor)+"; background:"+opCol(clr.back_slct)+";}"
              + cls.hover_ico+"{color:"+opCol(clr.prim_clor)+"; background:"+opCol(clr.hovr_brdr)+";}"
              + cls.dis_ico+"{color:"+opCol(clr.hovr_brdr)+"; cursor:auto; pointer-events:none;}"
              + cls.nav+"{background:"+opCol(clr.back_prim)+"; border-left:"+opCol(clr.icon_brdr)+" "+siz.brd+"px dashed; border-bottom-right-radius:"+siz.cnr.bx+"px; float:right; "+hiGWid((siz.box_hig - siz.bar), (siz.nav_wid - siz.brd), 1, 2, 1)+" display:grid;}"
              + wScrollbar(cls.nav, opCol(clr.back_slct), opCol(clr.text_scnd), 0, siz.scr.nav)
              + cls.cnt+"{font-size:"+siz.fnt.txt+"px; color:rgb("+clr.text_deft+"); background:rgb("+clr.back_deft+"); border-bottom-left-radius:"+siz.cnr.bx+"px; float:left; "+hiGWid(((siz.box_hig - siz.bar) - 1), (siz.box_wid - siz.nav_wid), 1, 2, 1)+"}"
              + wScrollbar(cls.cnt, opCol(clr.back_prim), opCol(clr.text_scnd), 1, siz.scr.cnt)
              + cls.txt+"{padding:"+siz.pdg+"px; text-align:justify;}"
              + cls.copy_hed+"{border-top-left-radius:"+siz.cnr.bx+"px; border-top-right-radius:"+siz.cnr.bx+"px; display:flex; justify-content:flex-end;}"
              + cls.copy_hed+" i{"+hiGWid(siz.bar, siz.bar, 1, 0, 1)+"}"
              + cls.copy_cnt+"{padding:"+siz.pdg+"px; background:"+opCol(clr.hovr_brdr)+";}"
              + cls.copy_cnt+" span{font-size:large; font-weight:bold;}"
              + cls.copy_fot+"{padding:"+siz.pdg+"px;}"
              + cls.copy_fot+" input{vertical-align:middle; margin:"+siz.pdg+"px;}"
              + cls.settings+"{display:none; background:rgb("+clr.back_deft+"); "+hiGWid(((siz.box_hig - siz.bar) - 1), (siz.box_wid - siz.nav_wid), 1, 2, 1)+" position:absolute; top:"+siz.bar+"px; left:0px; border-bottom-left-radius:"+siz.cnr.bx+"px;}"
              + wScrollbar(cls.settings, opCol(clr.back_prim), opCol(clr.text_scnd), 1, siz.scr.cnt)
              + cls.settings+" a{text-decoration:none; color:"+opCol(clr.prim_clor)+";}"
              + cls.settings+" a:hover{text-decoration:underline;}"
              + cls.settings_even+"{background:"+opCol(clr.back_prim)+";}"
              + cls.settings_both+"{padding:"+siz.pdg+"px; clear:both; display:table;}"
              + cls.settings_both_title+"{float:right; font-weight:bold; display:flex; align-items:center;}"
              + cls.settings_both_btn+"{font-size:"+siz.fnt.tit+"px; color:"+opCol(clr.prim_clor)+"; cursor:pointer; direction:ltr; float:left; display:flex; align-items:center; justify-content:center; border-radius:"+siz.cnr.bx+"px; border:"+opCol(clr.icon_brdr)+" "+siz.brd+"px solid;}"
              + cls.settings_title+"{font-weight:bold; padding:"+siz.pdg+"px;}"
              + cls.settings_link+"{direction:ltr; padding:0px "+siz.pdg+"px 0px "+siz.pdg+"px;}"
              + cls.settings_link_last+"{direction:ltr; padding:0px "+siz.pdg+"px "+siz.pdg+"px "+siz.pdg+"px;}"
              + cls.msg+"{display:none; color:rgb("+clr.back_deft+"); border-bottom-left-radius:"+siz.cnr.bx+"px; "+hiGWid(siz.bar, ((siz.box_wid - siz.nav_wid) - 2), 1, 0, 1)+" position:absolute; top:"+((siz.box_hig - siz.bar) - 1)+"px; left:1px;}"
              + cls.msg+" span{display:grid; align-items:center;}"
              + cls.msg+" i{color:rgb("+clr.back_deft+") !important;}"
              + cls.msg_txt+"{float:right; "+hiGWid(siz.bar, (((siz.box_wid - siz.nav_wid) - 2) - (siz.bar * 2)  - (siz.pdg * 2)), 1, 2, 1)+" padding-left:"+siz.pdg+"px; padding-right:"+siz.pdg+"px;}"
              + cls.msg_img+"{float:right; pointer-events:none;}"
              + cls.msg_ico+"{float:left;}"
              + cls.msg_img+", "+cls.msg_ico+"{"+hiGWid(siz.bar, siz.bar, 1, 1, 1)+" justify-content:center;}"
              + cls.zoom+"{"+hiGWid(((siz.bar / 2) + siz.brd + 1), (((siz.nav_wid / 2) * 3) + (siz.brd * 3)), 1, 1, 1)+" background:rgb("+clr.back_deft+"); position:absolute; top:"+siz.bar+"px; left:"+(siz.bar * 2)+"px; display:grid; justify-content:center; border-bottom-left-radius:"+siz.cnr.bx+"px; border-bottom-right-radius:"+siz.cnr.bx+"px; box-shadow:0px 2px 2px 0px "+opCol(clr.back_slct, clr.text_deft)+";}"
              + cls.zoom+" div{background:"+opCol(clr.back_prim)+"; border-bottom-left-radius:"+siz.cnr.bx+"px; border-bottom-right-radius:"+siz.cnr.bx+"px; display:flex;}"
              + cls.zoom+" i{"+hiGWid(((siz.bar / 2) + siz.brd), (siz.nav_wid / 2), 1, 1, 1)+"}"
              + cls.zoom+" span{border-left:"+opCol(clr.hovr_brdr)+" "+siz.brd+"px solid;}"
              + cls.incorrect_word+"{color:"+clr.msg_error+"; border-bottom:"+siz.brd+"px dotted "+clr.msg_error+"; cursor:pointer;}"
              + cls.incorrect_main+"{background:rgb("+clr.back_deft+"); "+hiGWid(150, 120, 1, 0, 0)+" border-radius:"+siz.cnr.bx+"px; position:relative; padding-bottom:"+siz.brd+"px;}"
              + cls.incorrect_title+"{background:"+opCol(clr.back_prim)+"; color:"+opCol(clr.text_scnd)+"; "+hiGWid((siz.bar - siz.brd), 120, 1, 1, 1)+" font-size:"+siz.fnt.tit+"px; border-bottom:"+opCol(clr.icon_brdr)+" "+siz.brd+"px dashed; border-top-left-radius:"+siz.cnr.bx+"px; border-top-right-radius:"+siz.cnr.bx+"px; display:grid; align-items:center;}"
              + cls.incorrect_title+" span{padding:"+siz.pdg+"px;}"
              + cls.incorrect_table+"{"+hiGWid(120, 120, 1, 2, 0)+" border-bottom-left-radius:"+siz.cnr.bx+"px; border-bottom-right-radius:"+siz.cnr.bx+"px;}"
              + wScrollbar(cls.incorrect_table, opCol(clr.back_prim), opCol(clr.text_scnd), 1, siz.scr.cnt)
              + cls.incorrect_table+" table{width:100%; border-collapse:collapse;}"
              + cls.incorrect_table+" table tbody td{padding:"+siz.pdg+"px; cursor:pointer;}"
              + cls.incorrect_table+" table tbody tr:nth-child(odd) td{background:transparent;}"
              + cls.incorrect_table+" table tbody tr:nth-child(even) td{background:"+opCol(clr.back_prim)+";}"
     ;

     var lngAR = {
          iconSmile: 'إضافة رمز تعبيري',
          msgPaste: 'بعد النسخ: أضغط دائمًا لصق (Ctrl+V) لتطبيق التغييرات',
          msgRestSettings: 'هل تريد بالتأكيد استعادة الإعدادات الافتراضية؟',
          copyClipboard: 'سيتم نسخ النص الجديد للحافظة',
          neverShowAgain: 'عدم الإظهار مرة أخرى',
          ok: '፧፧ موافق',
          close: '፧፧ إغلاق',
          cancel: '፧፧ إلغاء الأمر',
          copy: '፧፧ نسخ',
          spellcheck: '፧፧ تدقيق إملائي - عربي',
          tashkeel: '፧፧ تشكيل',
          shrink: '፧፧ تقليص',
          settings: '፧፧ إعدادات',
          upFont: '፧፧ تكبير حجم الخط',
          downFont: '፧፧ تصغير حجم الخط',
          restFont: '፧፧ استعادة حجم الخط الافتراضي',
          libraries: '፧፧ المكتبات',
          emptyText: 'الرجاء كتابة نص عربي!',
          pleaseWait: 'الرجاء الانتظار...',
          restSettings: '፧፧ استعادة الإعدادات الافتراضية',
          devTitle: '፧፧ فكرة, تصميم وتطوير',
          succeedSpellcheck: 'تم التدقيق الإملائي بنجاح',
          succeedTashkeel: 'تم التشكيل بنجاح',
          succeedShrink: 'تم التقليص بنجاح',
          failSpellcheck: 'خطأ, لم يتم التدقيق الإملائي!',
          failTashkeel: 'خطأ, لم يتم التشكيل!',
          failShrink: 'خطأ, لم يتم التقليص!',
          selectWord: 'اختر الكلمة الصحيحة:'
     }
    //=======================================================================================================================
    GM_addStyle(GM_getResourceText("__CSS_THEME_TIP"));
    GM_addStyle(GM_getResourceText("__CSS_GOOGLE_ICON"));
    GM_addStyle(sty);
    //=======================================================================================================================
    function changeAllColor(_ths){
         if($(cls.sty).length) return;
         var _imx = ' !important';
         $.each(_ths.attr('class').split(' '), function(i, v) {
              if(! $(cls.sty).length){
                   var c = $('svg.'+v).css('color');
                   if(unEmptyText(c)){
                        var _rgba = colorValues(c);
                        if(_rgba !== null && _rgba !== undefined){
                             var _rgb = _rgba[0]+', '+_rgba[1]+', '+_rgba[2];
                             var _css = ''
                                   + '.tippy-tooltip.'+thm+'-theme{border-color:'+opCol(clr.icon_brdr, _rgb)+_imx+';}'
                                   + cls.hed+'{background:'+opCol(clr.back_prim, _rgb)+_imx+'; border-bottom-color:'+opCol(clr.icon_brdr, _rgb)+_imx+';}'
                                   + cls.tit+'{color:'+opCol(clr.text_scnd, _rgb)+_imx+';}'
                                   + cls.material_ico+'{color:'+opCol(clr.icon_brdr, _rgb)+_imx+';}'
                                   + cls.ico_main+'{color:'+opCol(clr.prim_clor, _rgb)+_imx+';}'
                                   + cls.hover_main+'{background:'+opCol(clr.hovr_brdr, _rgb)+_imx+';}'
                                   + cls.select_ico+'{color:'+opCol(clr.prim_clor, _rgb)+_imx+'; background:'+opCol(clr.back_slct, _rgb)+_imx+';}'
                                   + cls.hover_ico+'{color:'+opCol(clr.prim_clor, _rgb)+_imx+'; background:'+opCol(clr.hovr_brdr, _rgb)+_imx+';}'
                                   + cls.dis_ico+'{color:'+opCol(clr.hovr_brdr, _rgb)+_imx+';}'
                                   + cls.nav+'{background:'+opCol(clr.back_prim, _rgb)+_imx+'; border-left-color:'+opCol(clr.icon_brdr, _rgb)+_imx+';}'
                                   + wScrollbar(cls.nav, (opCol(clr.back_slct, _rgb) + _imx), (opCol(clr.text_scnd, _rgb) + _imx), 0, 0)
                                   + wScrollbar(cls.cnt, (opCol(clr.back_prim, _rgb) + _imx), (opCol(clr.text_scnd, _rgb) + _imx), 0, 0)
                                   + wScrollbar(cls.settings, (opCol(clr.back_prim, _rgb) + _imx), (opCol(clr.text_scnd, _rgb) + _imx), 0, 0)
                                   + cls.settings+'{color:'+opCol(clr.prim_clor, _rgb)+_imx+';}'
                                   + cls.settings+' a{color:'+opCol(clr.prim_clor, _rgb)+_imx+';}'
                                   + cls.settings_even+'{background:'+opCol(clr.back_prim, _rgb)+_imx+';}'
                                   + cls.settings_both_btn+'{color:'+opCol(clr.prim_clor, _rgb)+_imx+'; border-color:'+opCol(clr.icon_brdr, _rgb)+_imx+';}'
                                   + cls.copy_cnt+'{background:'+opCol(clr.hovr_brdr, _rgb)+_imx+';}'
                                   + cls.hed_sprite+'{border-left-color:'+opCol(clr.hovr_brdr, _rgb)+_imx+';}'
                                   + cls.zoom+' div{background:'+opCol(clr.back_prim, _rgb)+_imx+';}'
                                   + cls.zoom+' span{border-left-color:'+opCol(clr.hovr_brdr, _rgb)+_imx+';}'
                                   + cls.incorrect_title+'{color:'+opCol(clr.text_scnd, _rgb)+_imx+'; background:'+opCol(clr.back_prim, _rgb)+_imx+'; border-bottom-color:'+opCol(clr.icon_brdr, _rgb)+_imx+';}'
                                   + wScrollbar(cls.incorrect_table, (opCol(clr.back_prim, _rgb) + _imx), (opCol(clr.text_scnd, _rgb) + _imx), 0, 0)
                                   + cls.incorrect_table+' table tbody tr:nth-child(even) td{background:'+opCol(clr.back_prim, _rgb)+_imx+';}'
                             ;
                             $('<style id="'+dotCls(cls.sty)+'">'+_css+'</style>').appendTo('head');
                             return false;
                        }
                   }
              }
         });
    }
    //=======================================================================================================================
    setInterval(function(){
         $('div[aria-label="'+lngAR.iconSmile+'"]').each(function(){
              var _ths = $(this).parent();
              var _pnt = _ths.parent();
              if(! _pnt.find(cls.btn).length){
                   var elClone = _ths.clone().clsAddDel(1, cls.btn);
                   changeAllColor($(elClone).find('svg'));
                   $(elClone).find('svg').replaceWith(htmIconMain());
                   _pnt.append(elClone);
                   addIcoMain($(this));
              }
         });
    }, tim.chk);

    function addIcoMain(_ths){
         addPopup();
         const insMain = tippy(cls.btn, {
              theme: thm,
              maxWidth: siz.box_wid,
              trigger: 'click',
              interactive: true,
              popperOptions: {
                   positionFixed: true
              },
              appendTo: document.body,
              flipOnUpdate: true,
              inlinePositioning: true,
              content: $(cls.tip).eq(0).html(),
              onShown(instance){
                   showPopup(_ths);
              },
              onHide(instance) {
                   return hidePopup();
              }
         });
         window.tippyMainInstances = tippyMainInstances.concat(insMain);
    }

    function hidePopup(){
         $(cls.ico).attr(ppa, '0').clsAddDel(0, cls.select_ico, cls.hover_ico, cls.chosse_ico);
         $(cls.tit).text("");
         elmTxt().attr('contenteditable', 'false').css('font-size', siz.fnt.txt + 'px').html("");
         $(cls.settings).hide();
         stopAjax();
         xhrAjax = null;
         oldHtmlShrink = null;
         return true;
    }

    function showPopup(_ths){
         msgRest();
         $(cls.zoom).hide();
         elmTwet = elmTweet(_ths);
         if(elmTwet !== null && elmTwet !== undefined){
              if(! new RegExp('['+rgxAllArabic+']+').test(elmTwet.text())){
                   elmTxt().html('');
                   msgCall(1, null, function(){setTimeout(function(){msgRest();},tim.run);});
              }else{
                   elmTxt().html(elmTwet.html());
              }
         }
         showPopupCopy();
    }

    function elmTweet(_ths){
         try {
              var pn = _ths.parents('div');
              for(var i = 0; i < pn.length; i++){
                   var el = pn.eq(i).find('.public-DraftEditor-content');
                   if(el.length) return el;
              }
         } catch (e) {}
         return null;
    }
    //=======================================================================================================================
    function showPopupCopy(){
         const insCopy = tippy(cls.btnOk, {
              theme: thm,
              trigger: 'click',
              interactive: true,
              popperOptions: {
                   positionFixed: true
              },
              flipOnUpdate: true,
              inlinePositioning: true,
              content: htmPopup_copy(),
              onShown(instance){
                   $(cls.ico).css('pointer-events', 'none');
              },
              onHide(instance) {
                   $(cls.ico).css('pointer-events', 'auto');
                   $(cls.ico + ':not('+cls.chosse_ico+')').clsAddDel(0, cls.select_ico, cls.hover_ico);
                   $(cls.copy_fot + " input").prop('checked', false);
                  return true;
              }
         });
         window.tippyCopyInstances = tippyCopyInstances.concat(insCopy);
         tippyCopyInstances.forEach(instance => {instance.enable();});
    }

    function checkCopy(){
         (async () => {
              var KeyMsgCopy = await GM.getValue(key.copy, false);
              if(KeyMsgCopy){
                   tippyCopyInstances.forEach(instance => {instance.disable();});
                   setCopy();
              }
         })();
    }

    function showMsgPaste(){
         (async () => {
             var KeyMsgPaste = await GM.getValue(key.paste, false);
             if(! KeyMsgPaste){
                  if (confirm(lngAR.msgPaste)) GM.setValue(key.paste, true);
             }
         })();
    }

    function setCopy(){
         setTimeout(function () {
              elmTxt().attr('contenteditable', 'true').selectText();
              setTimeout(function () {
                   document.execCommand('selectAll', false, null);
                   document.execCommand('copy', false, null);
                   tippyCopyInstances.forEach(instance => {instance.hide();});
                   tippyMainInstances.forEach(instance => {instance.hide();});
                   setTimeout(function () {
                        elmTwet.focus();
                        document.execCommand('selectAll', false, null);
                        tippyMainInstances.forEach(instance => {instance.hide();});
                        showMsgPaste();
                   }, tim.cpy);
              }, tim.cpy);
         }, tim.cpy);
    }
    //=======================================================================================================================
    function applyShrink(){
         oldHtmlShrink = elmTxt().html();
         msgCall(0, null, function(){setTimeout(function(){stopAjax();},tim.run);});
         $(cls.nav_shrink).attr(ppa, '1').clsAddDel(0, cls.finsh).clsAddDel(1, cls.dis_ico).css('pointer-events', 'none');
         try{
             if($(cls.nav_shrink).attr(ppa) == 1){
                   elmTxt().find('*').each(
                        function (_i1, _t1) {
                            if($(_t1).text().trim().length < 1){
                                 $(this).remove();
                            }
                        }
                   );
                   replaceTxt('('+outTag+')([.]+){2}', '\u060C');
                   replaceTxt('('+outTag+')([^\u002F-\u0039\u0041-\u005A\u0061-\u007A\u0620-\u063F\u0641-\u064A\u0660-\u0669])\\1+', '$1');
                   replaceTxt('('+outTag+')(&(nbsp|lt|gt|amp|quot|apos|cent|pound|yen|euro|copy|reg);)\\1+', '$1');
                   replaceTxt('('+outTag+')(\u0640)+', '');
                   var _oldWord = 'رسول;جل جلاله;جلى جلاله;ريال;محمد;بسم الله الرحمن الرحيم;بسم الله;صلى الله عليه وسلم;الله'.split(';');
                   var _repWord = 'ﷶ;ﷻ;ﷻ;﷼;ﷴ;﷽;﷽;ﷺ;ﷲ'.split(';');
                   $.each(
                        _oldWord,
                        function (_i, _v) {
                             replaceTxt('([^\u0620-\u0652#_])('+outTag+')('+_v+')([^\u0620-\u0652])', '$1'+_repWord[_i]+'$3');
                        }
                   );
                   finshAjax(cls.nav_shrink, true, lngAR.succeedShrink);
             }
         }catch(_err) {
             if($(cls.nav_shrink).attr(ppa) == 1) finshAjax(cls.nav_shrink, false, lngAR.failShrink);
         }
    }
    //=======================================================================================================================
    function applySpellcheck(){
         msgCall(0, null, function(){setTimeout(function(){stopAjax();},tim.run);});
         $(cls.nav_spellcheck).attr(ppa, '1').clsAddDel(0, cls.finsh).clsAddDel(1, cls.dis_ico).css('pointer-events', 'none');
         var _text = texNeat();
         try{
             xhrAjax = GM.xmlHttpRequest({
                  method: 'GET',
                  url: 'https://tahadz.com/cgi-bin/mishkal.cgi/ajaxGet?text='+encodeURIComponent(_text)+'&action=SpellCheck&order=0&lastmark=1',
                  headers: {
                       'Content-Type': 'application/x-javascript;charset=UTF-8',
                       'Accept' : 'application/json'
                  },
                  timeout: tim.xhr,
                  onload: function(_res) {
                       try{
                            if($(cls.nav_spellcheck).attr(ppa) == 1){
                                 var _result = true;
                                 $.each($.parseJSON(_res.responseText).result, function (_i, _v) {
                                      var chosen = _v.chosen;
                                      if(chosen.toLowerCase() === 'taha' || chosen.toLowerCase() === 'zerrouki') {
                                          _result = false;
                                          return false;
                                      }
                                      if(! unEmptyText(chosen.removeTatweel().removeTashkeel().removeNonArbicSpace())) return;
                                      var suggest = _v.suggest;
                                      if(! unEmptyText(suggest.removeTatweel().removeTashkeel().removeNonArbicSpace())) return;
                                      suggest = suggest.split(new RegExp(';', 'g')).filter(e => e !== chosen);
                                      suggest = [...new Set(suggest)];
                                      if(suggest.length < 1) return;
                                      suggest = suggest.join(';') + ";" + chosen;
                                      replaceTxt(
                                           '([^'+rgxAllArabic+'])('+outTag+')('+chosen+')([^'+rgxAllArabic+'])',
                                           '$1'+
                                           '<span class="'+dotCls(cls.incorrect_word)+' '+dotCls(cls.ico)+'" '+sco+'="'+chosen+'" '+scc+'="'+suggest+'" '+sci+'="'+dotCls(cls.incorrect_word)+'_'+_i+'">' +
                                                  chosen +
                                           '</span>' +
                                           '$3'
                                      );
                                 });
                                 if(_result){
                                      addPopupSpellcheck();
                                      finshAjax(cls.nav_spellcheck, true, lngAR.succeedSpellcheck);
                                      if($(cls.nav_shrink).hasClass(dotCls(cls.chosse_ico))) oldHtmlShrink = elmTxt().html();
                                 }else{
                                      finshAjax(cls.nav_spellcheck, false, lngAR.failSpellcheck);
                                 }
                            }
                       }catch(_err) {
                            if($(cls.nav_spellcheck).attr(ppa) == 1) finshAjax(cls.nav_spellcheck, false, lngAR.failSpellcheck);
                       }
                  },
                  ontimeout: function(){if($(cls.nav_spellcheck).attr(ppa) == 1) finshAjax(cls.nav_spellcheck, false, lngAR.failSpellcheck);},
                  onerror: function(){if($(cls.nav_spellcheck).attr(ppa) == 1) finshAjax(cls.nav_spellcheck, false, lngAR.failSpellcheck);}
             });
         }catch(_err) {
              if($(cls.nav_spellcheck).attr(ppa) == 1) finshAjax(cls.nav_spellcheck, false, lngAR.failSpellcheck);
         }
    }

    function addPopupSpellcheck(){
         const insSC = tippy(cls.incorrect_word, {
              theme: thm,
              trigger: 'click',
              interactive: true,
              popperOptions: {
                   positionFixed: true
              },
              flipOnUpdate: true,
              inlinePositioning: true,
              sticky: true,
              content: htmPopup_incorrect(),
              onShown(instance){
                   $(instance.reference).clsAddDel(1, cls.select_ico);
                   var _id = $(instance.reference).attr(sci);
                   var _suggest = $(instance.reference).attr(scc).split(new RegExp(';', 'g'));
                   var _html = '';
                   $.each(_suggest, function (_i, _v) {
                        _html += '<tr><td class="" '+sci+'="'+_id+'">'+_v+'</td></tr>';
                   });
                   $('.tippy-content').find(cls.incorrect_table + ' tbody').html(_html);
              },
              onHide(instance) {
                   $(instance.reference).clsAddDel(0, cls.select_ico);
                   return true;
              }
         });
         window.tippySpellcheckInstances = tippySpellcheckInstances.concat(insSC);
    }

    function elmIncorrectWord(_ths){
         return $(cls.incorrect_word+'['+sci+'="'+$(_ths).attr(sci)+'"]');
    }
    //=======================================================================================================================
    function applyTashkeel(){
         msgCall(0, null, function(){setTimeout(function(){stopAjax();},tim.run);});
         $(cls.nav_tashkeel).attr(ppa, '1').clsAddDel(0, cls.finsh).clsAddDel(1, cls.dis_ico).css('pointer-events', 'none');
         var _text = texNeat();
         tashkeelMishkal(_text, function(_val){
            if(unEmptyText(_val)){
                  resultTashkeel(cls.nav_tashkeel, _val);
                  if($(cls.nav_shrink).hasClass(dotCls(cls.chosse_ico))) oldHtmlShrink = elmTxt().html();
            }else{
                 tashkeelArabicKeyboard(_text, function(_val){
                      if(unEmptyText(_val)){
                           resultTashkeel(cls.nav_tashkeel, _val);
                           if($(cls.nav_shrink).hasClass(dotCls(cls.chosse_ico))) oldHtmlShrink = elmTxt().html();
                      }else{
                           if($(cls.nav_tashkeel).attr(ppa) == 1){
                                finshAjax(cls.nav_tashkeel, false, lngAR.failTashkeel);
                           }
                      }
               });
            }
        });
    }

    function tashkeelMishkal(_text, _callback){
         try{
             xhrAjax = GM.xmlHttpRequest({
                  method: 'GET',
                  url: 'https://tahadz.com/cgi-bin/mishkal.cgi/ajaxGet?text='+encodeURIComponent(_text)+'&action=Tashkeel2&order=0&lastmark=1',
                  headers: {
                       'Content-Type': 'application/x-javascript;charset=UTF-8',
                       'Accept' : 'application/json'
                  },
                  timeout: tim.xhr,
                  onload: function(_res) {
                       try{
                            var _result = '';
                            $.each($.parseJSON(_res.responseText).result, function (_i, _v) {
                                 _result += _v.chosen + ' ';
                                 if(_v.chosen.toLowerCase() === 'taha' || _v.chosen.toLowerCase() === 'zerrouki'){
                                      _result = '';
                                      return false;
                                 }
                            });
                            _callback(_result.replace(new RegExp('[_\\n\\s]+', 'g'), ' ').trim());
                       }catch(_err) {
                            _callback(null);
                       }
                  },
                  ontimeout: function(){_callback(null);},
                  onerror: function(){_callback(null);}
             });
         }catch(_err) {
             _callback(null);
         }
    }

    function tashkeelArabicKeyboard(_text, _callback){
         try{
             xhrAjax = GM.xmlHttpRequest({
                  method: 'GET',
                  url: 'http://arabic-keyboard.org/tashkeel/import.php?area='+encodeURIComponent(_text)+'&lastLetter=false',
                  headers: {
                       'Content-Type': 'text/html;charset=UTF-8'
                  },
                  timeout: tim.xhr,
                  onload: function(_res) {
                       try{
                            _callback($.parseJSON(_res.responseText).output.replace(new RegExp('[_\\n\\s]+', 'g'), ' ').trim());
                       }catch(_err) {
                            _callback(null);
                       }
                  },
                  ontimeout: function(){_callback(null);},
                  onerror: function(){_callback(null);}
             });
         }catch(_err) {
             _callback(null);
         }
    }

    function resultTashkeel(_ths, _val){
         if($(_ths).attr(ppa) == 1){
              var _html = elmTxt().html().removeTatweel().removeTashkeel();
              elmTxt().html(_html);
              $.each(
                   _val.split(' '),
                   function(_i, _v) {
                        replaceTxt('([^'+rgxAllArabic+'])('+outTag+')('+_v.removeTashkeel()+')([^'+rgxAllArabic+'])', '$1'+_v+'$3');
                   }
              );
              finshAjax(_ths, true, lngAR.succeedTashkeel);
         }
    }
    //=======================================================================================================================
    function stopAjax(){
        try{if(xhrAjax !== null) xhrAjax.abort();}catch(_err){}
        msgRest();
        $(cls.chosse_ico + ':not('+cls.finsh+')').clsAddDel(0, cls.hover_ico, cls.select_ico, cls.chosse_ico);
        $(cls.ico).attr(ppa, '0').clsAddDel(0, cls.dis_ico).css('pointer-events', 'auto');
    }

    function finshAjax(_ths, _b, _tit){
         $(_ths).css('pointer-events', 'auto').attr(ppa, '0');
         $(cls.ico).clsAddDel(0, cls.dis_ico).css('pointer-events', 'auto');
         if(_b){
              $(_ths).clsAddDel(1, cls.finsh);
              msgCall(3, _tit, function(){setTimeout(function(){msgRest();},tim.run);});
         }else{
              $(_ths).clsAddDel(0, cls.select_ico, cls.chosse_ico);
              msgCall(2, _tit, function(){setTimeout(function(){msgRest();},tim.run);});
         }
    }
    //=======================================================================================================================
    function msgRest(){
         $(cls.msg).hide();
         clearInterval(msgInterval);
         $(cls.ico).clsAddDel(0, cls.dis_ico).css('pointer-events', 'auto');
         $(cls.wap).unbind('click');
         $(cls.msg_ico).unbind('click');
         $(cls.msg_ico).show();
    }

    function msgCall(_typ, _tit, _funHide){
         msgRest();
         var _ico, _col, _ext, _ext_t, _hid, _tim, _txt;
         switch (_typ) {
               case 1:
                    _col = clr.msg_error;
                    _ico = ico.error;
                    _ext = true;
                    _hid = 2;
                    _tim = 0;
                    _ext_t = lngAR.close;
                    _txt = lngAR.emptyText;
                    break;
               case 2:
                    _col = clr.msg_faild;
                    _ico = ico.fail;
                    _ext = false;
                    _hid = 1;
                    _tim = tim.msg;
                    _ext_t = lngAR.close;
                    _txt = _tit;
                    break;
               case 3:
                    _col = clr.msg_doney;
                    _ico = ico.done;
                    _ext = false;
                    _hid = 1;
                    _tim = tim.msg;
                    _ext_t = lngAR.close;
                    _txt = _tit;
                    break;
              default:
                    _col = clr.msg_await;
                    _ico = ico.wait;
                    _ext = false;
                    _hid = 2;
                    _tim = 0;
                    _ext_t = lngAR.cancel;
                    _txt = lngAR.pleaseWait;
                    break;
         }
         $(cls.msg).css('background', _col);
         $(cls.msg_img + ' i').text(_ico);
         $(cls.msg_txt).text(_txt);
         $(cls.msg_ico).attr(dtt, _ext_t);
         $(cls.ico + ":not("+cls.btnClose+")").clsAddDel(1, cls.dis_ico).css('pointer-events', 'none');
         if(_ext){
              $(cls.msg_ico).hide();
         }
         if(_hid===1){
              $(cls.wap).click(function() { _funHide(); });
         }else if(_hid===2){
              $(cls.msg_ico).click(function() { _funHide(); });
         }
         if(_tim > 0){
              msgInterval = setInterval(function(){ _funHide(); }, _tim);
         }
         $(cls.msg).show();
    }
    //=======================================================================================================================
    function htmIconMain(){
         return "<i class='"+dotCls(cls.material_ico)+" "+dotCls(cls.ico_main)+"'>"+ico.main+"</i>";
    }

    function htmPopup_hed(){
         return ""
               + "<div class='"+dotCls(cls.hed)+"'>"
                    + "<div class='"+dotCls(cls.tit)+"'></div>"
                    + "<div class='"+dotCls(cls.hed_btns)+"'>"
                         + "<i class='"+dotCls(cls.material_ico)+" "+dotCls(cls.ico)+" "+dotCls(cls.btnClose)+"' "+dtt+"='"+lngAR.close+"'>"+ico.close+"</i>"
                         + "<i class='"+dotCls(cls.material_ico)+" "+dotCls(cls.ico)+" "+dotCls(cls.dis_ico)+" "+dotCls(cls.btnOk)+"' "+dtt+"='"+lngAR.copy+"'>"+ico.copy+"</i>"
                    + "</div>"
                    + "<div class='"+dotCls(cls.hed_sprite)+"'></div>"
               + "</div>";
    }

    function htmPopup_msg(){
         return ""
               + "<div class='"+dotCls(cls.msg)+"'>"
                    + "<span class='"+dotCls(cls.msg_img)+"'><i class='"+dotCls(cls.material_ico)+"'></i></span>"
                    + "<span class='"+dotCls(cls.msg_txt)+"'></span>"
                    + "<span class='"+dotCls(cls.msg_ico)+"' "+dtt+"='"+lngAR.cancel+"'><i class='"+dotCls(cls.material_ico)+"'>"+ico.close+"</i></span>"
               + "</div>";
    }

    function htmPopup_nav(){
         return ""
               + "<div class='"+dotCls(cls.nav)+"'>"
               + "<i class='"+dotCls(cls.material_ico)+" "+dotCls(cls.ico)+" "+dotCls(cls.dis_ico)+" "+dotCls(cls.nav_shrink)+"' "+ppa+"='0' "+dtt+"='"+lngAR.shrink+"'>"+ico.shrink+"</i>"
                    + "<i class='"+dotCls(cls.material_ico)+" "+dotCls(cls.ico)+" "+dotCls(cls.dis_ico)+" "+dotCls(cls.nav_spellcheck)+"' "+ppa+"='0' "+dtt+"='"+lngAR.spellcheck+"'>"+ico.spellCheck+"</i>"
                    + "<i class='"+dotCls(cls.material_ico)+" "+dotCls(cls.ico)+" "+dotCls(cls.dis_ico)+" "+dotCls(cls.nav_tashkeel)+"' "+ppa+"='0' "+dtt+"='"+lngAR.tashkeel+"'>"+ico.tashkeel+"</i>"
                    + "<i class='"+dotCls(cls.material_ico)+" "+dotCls(cls.ico)+" "+dotCls(cls.dis_ico)+" "+dotCls(cls.nav_settings)+"' "+ppa+"='0' "+dtt+"='"+lngAR.settings+"'>"+ico.settings+"</i>"
               + "</div>";
    }

    function htmPopup_zoom(){
         return ""
               + "<div class='"+dotCls(cls.zoom)+"'>"
                    + "<div>"
                         + "<i class='material-icons "+dotCls(cls.ico)+" "+dotCls(cls.zoom_up)+"' "+dtt+"='"+lngAR.upFont+"'>"+ico.zoomIn+"</i>"
                         + "<span></span>"
                         + "<i class='material-icons "+dotCls(cls.ico)+" "+dotCls(cls.zoom_down)+"' "+dtt+"='"+lngAR.downFont+"'>"+ico.zoomOut+"</i>"
                         + "<span></span>"
                         + "<i class='material-icons "+dotCls(cls.ico)+" "+dotCls(cls.zoom_rest)+"' "+dtt+"='"+lngAR.restFont+"'>"+ico.rest+"</i>"
                    + "</div>"
               + "</div>";
    }

    function htmPopup_incorrect(){
         return ""
              + "<div class='"+dotCls(cls.incorrect_main)+"'>"
                   + "<div class='"+dotCls(cls.incorrect_title)+"'><span>"+lngAR.selectWord+"</span></div>"
                   + "<div class='"+dotCls(cls.incorrect_table)+"'>"
                        + "<table>"
                             + "<tbody></tbody>"
                        + "</table>"
                   + "</div>"
              + "</div>";
    }

    function htmPopup_cnt(){
         return ""
               + "<div class='"+dotCls(cls.cnt)+"'>"
                    + "<div class='"+dotCls(cls.txt)+"' contenteditable='false'></div>"
                    + htmPopup_settings()
                    + htmPopup_msg()
                    + htmPopup_zoom()
               + "</div>";
    }

    function htmPopup_copy(){
         return ""
                    + "<div class='"+dotCls(cls.copy_hed)+"'>"
                         + "<i class='"+dotCls(cls.material_ico)+" "+dotCls(cls.copy_ext)+"' "+dtt+"='"+lngAR.cancel+"'>"+ico.close+"</i>"
                         + "<i class='"+dotCls(cls.material_ico)+" "+dotCls(cls.copy_oky)+"' "+dtt+"='"+lngAR.ok+"'>"+ico.ok+"</i>"
                    + "</div>"
                    + "<div class='"+dotCls(cls.copy_cnt)+"'>"
                         + "<span>"+lngAR.copyClipboard+"</span>"
                    + "</div>"
                    + "<div class='"+dotCls(cls.copy_fot)+"'>"
                         + "<label><input type='checkbox'>"+lngAR.neverShowAgain+"</label>"
                    + "</div>";
    }

    function addPopup(){
        if($(cls.tip).length) return;
        var _htm = ""
               + "<div class='"+dotCls(cls.tip)+"'>"
                    + "<div class='"+dotCls(cls.wap)+"'>"
                         + "<div class='"+dotCls(cls.man)+"'>"
                              + htmPopup_hed()
                              + htmPopup_nav()
                              + htmPopup_cnt()
                         + "</div>"
                    + "</div>"
               + "</div>";
        $('body').append(_htm);
        initClick();
    }
    //=======================================================================================================================
    function htmPopup_settings(){
         var   wh_1 = hiGWid(siz.bar, (siz.box_wid - siz.nav_wid - siz.nav_wid - (siz.pdg * 4) + 1), 1, 2, 1),
               wh_2 = hiGWid(siz.bar, (siz.nav_wid - siz.brd), 1, 1, 1),
               wh_3 = hiGWid(siz.bar, (siz.box_wid - siz.nav_wid - (siz.nav_wid * 2) - (siz.pdg * 4) + 1), 1, 2, 1),
               wh_4 = hiGWid(siz.bar, ((siz.nav_wid * 2) - 1), 1, 1, 1);
         return ""
               + "<div class='"+dotCls(cls.settings)+"'>"
                    + "<div class='"+dotCls(cls.settings_both)+" "+dotCls(cls.settings_even)+"'>"
                         + "<div class='"+dotCls(cls.settings_both_title)+"' style='"+wh_1+"'>"+lngAR.restSettings+"</div>"
                         + "<div class='"+dotCls(cls.settings_both_btn)+"' style='"+wh_2+"'>"
                              + "<i class='"+dotCls(cls.material_ico)+" "+dotCls(cls.ico)+" "+dotCls(cls.settings_btn_rest)+"' "+dtt+"='"+lngAR.ok+"'>"+ico.ok+"</i>"
                         + "</div>"
                    + "</div>"

                    + "<div class='"+dotCls(cls.settings_title)+"'>"+lngAR.libraries+"</div>"
                    + "<div class='"+dotCls(cls.settings_link)+"'>- <a target='_blank' href='https://jquery.com'>https://jquery.com</a></div>"
                    + "<div class='"+dotCls(cls.settings_link)+"'>- <a target='_blank' href='https://atomiks.github.io/tippyjs'>https://atomiks.github.io/tippyjs</a></div>"
                    + "<div class='"+dotCls(cls.settings_link_last)+"'>- <a target='_blank' href='https://google.github.io/material-design-icons'>https://google.github.io/material-design-icons</a></div>"

                    + "<div class='"+dotCls(cls.settings_even)+" "+dotCls(cls.settings_title)+"'>"+lngAR.spellcheck+"</div>"
                    + "<div class='"+dotCls(cls.settings_even)+" "+dotCls(cls.settings_link_last)+"'>- <a target='_blank' href='http://www.tahadz.com/mishkal'>http://www.tahadz.com/mishkal</a></div>"

                    + "<div class='"+dotCls(cls.settings_title)+"'>"+lngAR.tashkeel+"</div>"
                    + "<div class='"+dotCls(cls.settings_link)+"'>- <a target='_blank' href='http://www.tahadz.com/mishkal'>http://www.tahadz.com/mishkal</a></div>"
                    + "<div class='"+dotCls(cls.settings_link_last)+"'>- <a target='_blank' href='http://www.arabic-keyboard.org/tashkeel'>http://www.arabic-keyboard.org/tashkeel</a></div>"

                    + "<div class='"+dotCls(cls.settings_both)+" "+dotCls(cls.settings_even)+"'>"
                         + "<div class='"+dotCls(cls.settings_both_title)+"' style='"+wh_3+"'>"+lngAR.devTitle+"</div>"
                         + "<div class='"+dotCls(cls.settings_both_btn)+" "+dotCls(cls.ico)+" "+dotCls(cls.settings_btn_account)+"' style='"+wh_4+"'>@RAKAN938</div>"
                    + "</div>"
               + "</div>";
    }

    function restSettings(){
         if (confirm(lngAR.msgRestSettings)){
              (async () => {
                   await GM.deleteValue(key.copy);
                   await GM.deleteValue(key.paste);
                   tippyMainInstances.forEach(instance => {instance.hide();});
              })();
         }
    }
    //=======================================================================================================================
    function texNeat(){
         return elmTxt()
                .textInHtml()
                .replace(new RegExp('_+', 'g'), ' ')
                .removeTatweel()
                .removeTashkeel()
                .removeNonArbicSpace()
                .replace(new RegExp('[_\\n\\s]+', 'g'), ' ')
                .trim();
    }

    function replaceTxt(_rx, _to){
         elmTxt().find('*').each(
              function (_i, _t) {
                   $(this).html(
                        function (_k, _x) {
                             return _x.replace(new RegExp(_rx, 'g'), _to);
                        }
                   );
              }
         );
    }

    function elmTxt(){
         return $('.tippy-content').find(cls.txt).eq(0);
    }
    //=======================================================================================================================
    function toggleNav(_ths){
         if($(_ths).hasClass(dotCls(cls.chosse_ico))){
              $(_ths).clsAddDel(0, cls.chosse_ico, cls.select_ico).clsAddDel(1, cls.hover_ico);
              $(cls.ico).clsAddDel(0, cls.dis_ico).css('pointer-events', 'auto');
              return false;
           }else{
              $(_ths).clsAddDel(0, cls.hover_ico).clsAddDel(1, cls.select_ico, cls.chosse_ico);
              $(cls.ico + ":not("+cls.btnClose+", "+_ths+", "+cls.settings+" *)").clsAddDel(1, cls.dis_ico).css('pointer-events', 'none');
              return true;
         }
    }

    function removeNav(_ths, _callback) {
         if(_callback !== undefined) _callback();
         $(_ths).attr(ppa, '0').clsAddDel(0, cls.select_ico, cls.chosse_ico, cls.finsh);
         $(cls.ico).clsAddDel(0, cls.dis_ico).css('pointer-events', 'auto');
    }
    //=======================================================================================================================
    function initClick(){
         $('body')
        .on("click", cls.btnClose, function(){
             if($(this).hasClass(dotCls(cls.dis_ico))) return;
             tippyMainInstances.forEach(instance => {instance.hide();});
        })
        .on("click", cls.btnOk, function(e){
             if($(this).hasClass(dotCls(cls.dis_ico))) return;
             $(this).clsAddDel(0, cls.hover_ico).clsAddDel(1, cls.select_ico);
             checkCopy();
        })
        .on("click", cls.nav_shrink, function(){
             if($(this).hasClass(dotCls(cls.dis_ico))) return;
             if(toggleNav(cls.nav_shrink)){
                  applyShrink();
             }else{
                  removeNav(cls.nav_shrink, function(){
                       if(unEmptyText(oldHtmlShrink)) elmTxt().html(oldHtmlShrink);
                  });
             }
        })
        .on("click", cls.nav_spellcheck, function(){
             if($(this).hasClass(dotCls(cls.dis_ico))) return;
             if(toggleNav(cls.nav_spellcheck)){
                  applySpellcheck();
             }else{
                  removeNav(cls.nav_spellcheck, function(){
                       $(cls.incorrect_word).each(function(){
                            $(this).replaceWith($(this).attr(sco));
                       });
                  });
             }
        })
        .on("click", cls.nav_tashkeel, function(){
             if($(this).hasClass(dotCls(cls.dis_ico))) return;
             if(toggleNav(cls.nav_tashkeel)){
                  applyTashkeel();
             }else{
                  removeNav(cls.nav_tashkeel, function(){
                       elmTxt().html(elmTxt().html().removeTatweel().removeTashkeel());
                  });
             }
        })
        .on("click", cls.nav_settings, function(e){
             if($(this).hasClass(dotCls(cls.dis_ico))) return;
             if(toggleNav(cls.nav_settings)){
                  $(cls.settings).show();
             }else{
                  $(cls.settings).hide();
             }
        })
        .on("click", cls.copy_ext, function(){
             tippyCopyInstances.forEach(instance => {instance.hide();});
        })
        .on("click", cls.copy_oky, function(){
             if($(cls.copy_fot + " input").prop("checked")) GM.setValue(key.copy, true);
             setCopy();
        })
        .on("click", cls.zoom_up, function(){
             elmTxt().css('font-size', (parseFloat(elmTxt().css('font-size')) * 1.2) + 'px');
        })
        .on("click", cls.zoom_down, function(){
             elmTxt().css('font-size', (parseFloat(elmTxt().css('font-size')) * 0.8) + 'px');
        })
        .on("click", cls.zoom_rest, function(){
             elmTxt().css('font-size', siz.fnt.txt + 'px');
        })
        .on("click", cls.incorrect_table + " td", function(){
             elmIncorrectWord(this).text($(this).text()).css('border-bottom', 'hidden');
             if(elmIncorrectWord(this).attr(sco) === $(this).text()){
                  elmIncorrectWord(this).css('border-bottom', '');
             }else{
                  elmIncorrectWord(this).css('border-bottom', 'hidden');
             }
             tippySpellcheckInstances.forEach(instance => {instance.hide();});
        })
        .on("click", cls.settings_btn_rest, function(){
             restSettings();
        })
        .on("click", cls.settings_btn_account, function(){
             window.location.href = '/RAKAN938';
        })
        .on("mouseenter", cls.ico + ", " + cls.copy_oky + ", " + cls.copy_ext, function(){
             if($(this).hasClass(dotCls(cls.dis_ico))) return;
             if(! $(this).hasClass(dotCls(cls.select_ico))) $(this).clsAddDel(1, cls.hover_ico);
             $(cls.tit).text($(this).attr(dtt));
        })
        .on("mouseenter", cls.msg_ico, function(){
             $(cls.tit).text($(this).attr(dtt));
        })
        .on("mouseenter", cls.ico_main, function(){
             $(this).parent().clsAddDel(1, cls.hover_main);
        })
        .on("mouseover", cls.txt + ", " + cls.zoom, function(){
             $(cls.zoom).show();
        })
        .on("mouseenter", cls.incorrect_table + " tr", function(){
             $(this).clsAddDel(1, cls.select_ico);
        })
        .on("mouseleave", cls.ico + ", " + cls.copy_oky + ", " + cls.copy_ext, function(){
             if($(this).hasClass(dotCls(cls.dis_ico))) return;
             $(this).clsAddDel(0, cls.hover_ico);
             $(cls.tit).text("");
        })
        .on("mouseleave", cls.ico_main, function(){
             $(this).parent().clsAddDel(0, cls.hover_main);
        })
        .on("mouseleave", cls.msg_ico, function(){
             $(cls.tit).text("");
        })
        .on("mouseout", cls.txt, function(){
             $(cls.zoom).hide();
        })
        .on("mouseout", cls.zoom, function(e){
             if (e.relatedTarget == elmTxt() ||  $.contains(elmTxt(), e.relatedTarget)) return;
             $(cls.zoom).hide();
        })
        .on("mouseleave", cls.incorrect_table + " tr", function(){
             $(this).clsAddDel(0, cls.select_ico);
        });
    }
    //=======================================================================================================================

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址