// ==UserScript==
// @name Twitter ARPLS
// @description معالجة نص التغريدة بالتدقيق الإملائي والتشكيل وغيرها من الأدوات
// @version 1.1
// @author @RAKAN938
// @namespace https://twitter.com/rakan938
// @match https://twitter.com/*
// @match https://mobile.twitter.com/*
// @connect tahadz.com
// @connect arabic-keyboard.org
// @connect ummulqura.org.sa
// @require https://code.jquery.com/jquery-latest.js
// @require https://unpkg.com/popper.js@1
// @require https://unpkg.com/tippy.js@5
// @require https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment-with-locales.min.js
// @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).html());
tm.find("div").contents().replaceWith(function() { return "\n" + this.innerHTML; });
return tm.text();
};
$.fn.htmlNonSpellcheckInsertion = function () {
var tm = $("<pre />").html($(this).html());
tm.find(cls.incorrect_word).replaceWith(function() { return $(this).text(); });
tm.find(cls.insertion_word).clsAddDel(1, cls.insertion_word_dis);
return tm.html();
};
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 escapeRegExp(_str) {
return _str.replace(/[.*+?^${}()|[\]\\]/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+')';
}
moment.defineLocale('en-rakan938', {
parentLocale: 'en',
months : ['Muharram', 'Safar', 'Rabī\' Al-Awwal', 'Rabī\' Al-Alkhir', 'Jumada Al-Awwal', 'Jumada Al-Alkhir', 'Rajab', 'Sha\'ban', 'Ramadan', 'Shawwal', 'Dhu Al-Qa\'dah', 'Dhu Al-Hijjah']
});
moment.defineLocale('ar-rakan938', {
parentLocale: 'ar',
months : ['محرم', 'صفر', 'ربيع الأول', 'ربيع الآخر', 'جمادى الأولى', 'جمادى الآخرة', 'رجب', 'شعبان', 'رمضان', 'شوال', 'ذو القعدة', 'ذو الحجة'],
meridiemParse: /صباحًا|مساءً/,
isPM : function (input) {return 'مساءً' === input;},
meridiem : function (hour, minute, isLower) {
if (hour < 12) {
return 'صباحًا';
} else {
return 'مساءً';
}
}
});
//=======================================================================================================================
var thm = 'light-border', elmTwet, msgInterval, xhrAjax, htmlShrink, outTag = '?![^<>]*>',
rgxAllArabic = '\u0600-\u06FF', jsonInsertion, hijriInsertion, lastUpdateInsertion,
alertOpenInput;
window.tippyMainInstances = [], window.tippyCopyInstances = [], window.tippySpellcheckInstances = [], window.tippyInsertionInstances = [];
var lngAR = {
iconSmile: 'إضافة رمز تعبيري',
msgPaste: 'بعد النسخ: أضغط دائمًا لصق (Ctrl+V) لتطبيق التغييرات',
msgRestSettings: 'هل تريد بالتأكيد استعادة الإعدادات الافتراضية؟',
copyClipboard: 'سيتم نسخ النص الجديد للحافظة',
neverShowAgain: 'عدم الإظهار مرة أخرى',
ok: '፧፧ موافق',
close: '፧፧ إغلاق',
cancel: '፧፧ إلغاء الأمر',
copy: '፧፧ نسخ',
shrink: '፧፧ تقليص',
spellcheck: '፧፧ تدقيق إملائي - عربي',
tashkeel: '፧፧ تشكيل',
insertion: '፧፧ إدراج',
settings: '፧፧ إعدادات',
upFont: '፧፧ تكبير حجم الخط',
downFont: '፧፧ تصغير حجم الخط',
restFont: '፧፧ استعادة حجم الخط الافتراضي',
libraries: '፧፧ المكتبات',
emptyText: 'الرجاء كتابة نص عربي!',
pleaseWait: 'الرجاء الانتظار...',
restSettings: '፧፧ استعادة الإعدادات الافتراضية',
devTitle: '፧፧ فكرة, تصميم وتطوير',
devAccount: '፧፧ حساب المطوّر',
succeedSpellcheck: 'تم التدقيق الإملائي بنجاح',
succeedTashkeel: 'تم التشكيل بنجاح',
succeedShrink: 'تم التقليص بنجاح',
succeedInsertion: 'تم الإدراج بنجاح',
failSpellcheck: 'خطأ, لم يتم التدقيق الإملائي!',
failTashkeel: 'خطأ, لم يتم التشكيل!',
failShrink: 'خطأ, لم يتم التقليص!',
failInsertion: 'خطأ, لم يتم الإدراج!',
selectWord: 'اختر الكلمة الصحيحة:',
dateTitle: 'التاريخ',
timeTitle: 'الوقت',
codeTitle: 'الرمز: ',
willReplaced: 'سيتم استبداله',
b: 'ب',
titleInsertion: 'أكتب رمز أو أكثر في التغريدة لاستبداله بما يوافقه:',
WriteFormat: 'أكتب الصيغة',
hijriSettings: '፧፧ التاريخ الهجري',
hijri: 'هجري',
gregorian: 'ميلادي',
arabic: 'عربي',
einglish: 'إنجليزي',
applyAll: 'تطبيق على الكل',
defaultFormat: 'اعتمادها كصيغة افتراضية'
}
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',
background_even: '.rakan938_arpls_background_even',
subpopup: '.rakan938_arpls_subpopup',
subpopup_hed: '.rakan938_arpls_subpopup_hed',
copy_oky: '.rakan938_arpls_copy_oky',
copy_ext: '.rakan938_arpls_copy_ext',
settings: '.rakan938_arpls_settings',
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_popup: '.rakan938_arpls_incorrect_popup',
incorrect_title: '.rakan938_arpls_incorrect_title',
incorrect_table: '.rakan938_arpls_incorrect_table',
insertion: '.rakan938_arpls_insertion',
insertion_word: '.rakan938_arpls_insertion_word',
insertion_word_dis: '.rakan938_arpls_insertion_word_dis',
insertion_popup: '.rakan938_arpls_insertion_popup',
insertion_popup_sel: '.rakan938_arpls_insertion_popup_sel'
};
var twit = {
icoMain: 'div[aria-label="'+lngAR.iconSmile+'"]',
modalHeader: 'div[aria-labelledby="modal-header"]',
clsElmTwit: '.public-DraftEditor-content'
};
var key = {
copy: 'rakan938_arpls_key_msg_copy',
paste: 'rakan938_arpls_key_msg_paste',
insertion: 'rakan938_arpls_key_jsn_insertion'
}
var clr = {
back_deft: '255, 255, 255',
text_deft: '51, 51, 51',
prim_deft: '29, 161, 242',
prim_clor: '1.00',
cl_shadow: '0.90',
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: 2000,
run: 10,
cpy: 100,
xhr: 30000
};
var ico = {
main: 'format_shapes',
close: 'close',
ok: 'done',
copy: 'file_copy',
spellcheck: 'spellcheck',
tashkeel: 'playlist_add_check',
insertion: 'playlist_add',
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 atr = {
processAjax: 'process-ajax',
dataTitle: 'data-title',
dataId: 'data-id',
dataOld: 'data-old',
dataIncorrect: 'data-incorrect',
dataCode: 'data-code',
dataType: 'data-type',
dataFormat: 'data-format',
dataLang: 'data-lang',
dataAll: 'data-all',
dataDefault: 'data-default',
dateHijri: 'date-H',
dateGregorian: 'date-G',
langAR: 'ar',
langEN: 'en',
time: 'time'
};
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%; min-height:"+siz.bar+"px; 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.background_even+"{background:"+opCol(clr.back_prim)+";}"
+ cls.subpopup+" input[type='checkbox']{vertical-align:middle; margin:"+siz.pdg+"px;}"
+ cls.subpopup+" input[type='text']{width:-webkit-fill-available; direction:ltr;}"
+ cls.subpopup+" i{"+hiGWid(siz.bar, siz.bar, 1, 0, 1)+"}"
+ cls.subpopup+" h3{margin:0;}"
+ cls.subpopup+" div:not("+cls.subpopup_hed+"):not("+cls.insertion_popup_sel+"):not("+cls.incorrect_title+"):not("+cls.incorrect_table+"){padding:"+siz.pdg+"px;}"
+ cls.subpopup_hed+"{border-top-left-radius:"+siz.cnr.bx+"px; border-top-right-radius:"+siz.cnr.bx+"px; display:flex; justify-content:flex-end;}"
+ 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_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; z-index:9999; 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{min-height:"+((siz.bar / 2) + siz.brd)+"px; "+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_popup+"{background:rgb("+clr.back_deft+"); "+hiGWid(siz.box_hig, (siz.box_hig - siz.bar), 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), (siz.box_hig - siz.bar), 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((siz.box_hig - siz.bar), (siz.box_hig - siz.bar), 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)+";}"
+ cls.insertion_word+"{border:"+siz.brd+"px dotted "+clr.msg_faild+"; cursor:pointer;}"
+ cls.insertion_word_dis+"{border:none !important; cursor:none !important; pointer-events:none !important;}"
+ cls.insertion+"{display:none; background:"+opCol(clr.cl_shadow, clr.text_deft)+"; color:rgb("+clr.back_deft+"); "+hiGWid((siz.box_hig - siz.bar - (siz.pdg * 2) - 1), (siz.box_wid - siz.nav_wid - (siz.pdg * 2) - 2), 1, 2, 1)+" top:"+siz.bar+"px; left:1px; position:absolute; border-bottom-left-radius:"+siz.cnr.bx+"px; padding:"+siz.pdg+"px;}"
+ wScrollbar(cls.insertion, opCol(clr.back_prim), opCol(clr.text_scnd), 1, siz.scr.cnt)
+ cls.insertion_popup+"{text-align:right; direction:rtl; width:"+(siz.box_hig + siz.nav_wid)+"px;}"
+ cls.insertion_popup+" "+cls.subpopup_hed+" span{"+hiGWid(siz.bar, ((siz.box_hig + siz.nav_wid) - (siz.bar * 2) - (siz.pdg * 2)), 1, 1, 1)+" display:flex; align-items:center;}"
+ cls.insertion_popup_sel+"{text-align:center; display:flex;}"
+ cls.insertion_popup_sel+" span{cursor:pointer; width:50%; padding:5px;}"
+ cls.insertion_popup_sel+" span:first-of-type{float:right;}"
+ cls.insertion_popup_sel+" span:last-of-type{float:left;}"
;
//=======================================================================================================================
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+';}'
+ cls.background_even+'{background:'+opCol(clr.back_prim, _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)
+ wScrollbar(cls.insertion, (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_both_btn+'{color:'+opCol(clr.prim_clor, _rgb)+_imx+'; border-color:'+opCol(clr.icon_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(){
$(twit.icoMain).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(htmlIconMain());
_pnt.append(elClone);
dropdownMain($(this));
}
});
}, tim.chk);
function dropdownMain(_ths){
htmlMain();
const insSC = 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){showPopupMain(_ths);},
onHide(instance) {return hidePopupMain();}
});
window.tippyMainInstances = tippyMainInstances.concat(insSC);
}
function htmlIconMain(){
return "<i class='"+dotCls(cls.material_ico)+" "+dotCls(cls.ico_main)+"'>"+ico.main+"</i>";
}
function htmlMain(){
if($(cls.tip).length) return;
var _htm = ""
+ "<div class='"+dotCls(cls.tip)+"'>"
+ "<div class='"+dotCls(cls.wap)+"'>"
+ "<div class='"+dotCls(cls.man)+"'>"
+ htmlHedMain()
+ htmlNav()
+ htmlCntMain()
+ "</div>"
+ "</div>"
+ "</div>";
$('body').append(_htm);
initEventAll();
}
function htmlHedMain(){
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)+"' "+atr.dataTitle+"='"+lngAR.close+"'>"+ico.close+"</i>"
+ "<i class='"+dotCls(cls.material_ico)+" "+dotCls(cls.ico)+" "+dotCls(cls.dis_ico)+" "+dotCls(cls.btnOk)+"' "+atr.dataTitle+"='"+lngAR.copy+"'>"+ico.copy+"</i>"
+ "</div>"
+ "<div class='"+dotCls(cls.hed_sprite)+"'></div>"
+ "</div>";
}
function htmlCntMain(){
return ""
+ "<div class='"+dotCls(cls.cnt)+"'>"
+ "<div class='"+dotCls(cls.txt)+"' contenteditable='false'></div>"
+ htmlSettings()
+ htmlMsg()
+ htmlZoom()
+ popupInsertionEmpty()
+ "</div>";
}
function hidePopupMain(){
$(cls.ico).attr(atr.processAjax, '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();
$(cls.insertion).hide();
stopAjax();
xhrAjax = null;
htmlShrink = null;
hijriInsertion = null;
alertOpenInput = false;
return true;
}
function showPopupMain(_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());
}
}
dropdownCopy();
}
function elmTweet(_ths){
try {
var pn = _ths.parents('div');
for(var i = 0; i < pn.length; i++){
var el = pn.eq(i).find(twit.clsElmTwit);
if(el.length) return el;
}
} catch (e) {}
return null;
}
function initEventAll(){
initEventMain();
initEventNav();
initEventCopy();
initEventSpellcheck();
initEventInsertion();
initEventMsg();
initEventZoom();
initEventSettings();
}
function initEventMain(){
$('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("mouseenter", cls.ico_main, function(){
$(this).parent().clsAddDel(1, cls.hover_main);
})
.on("mouseleave", cls.ico_main, function(){
$(this).parent().clsAddDel(0, cls.hover_main);
})
.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(atr.dataTitle));
})
.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("");
});
}
//=======================================================================================================================
function cancelAllNav(_c){
if(_c !== cls.nav_shrink) removeNavShrink(0);
if(_c !== cls.nav_spellcheck) removeNavSpellcheck(0);
if(_c !== cls.nav_tashkeel) removeNavTashkeel(0);
if(_c !== cls.nav_insertion) removeNavInsertion(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(atr.processAjax, '0').clsAddDel(0, cls.select_ico, cls.chosse_ico, cls.finsh);
$(cls.ico).clsAddDel(0, cls.dis_ico).css('pointer-events', 'auto');
}
function icoNav(_c, _l, _i){
return "<i class='"+dotCls(cls.material_ico)+" "+dotCls(cls.ico)+" "+dotCls(cls.dis_ico)+" "+dotCls(_c)+"' "+atr.processAjax+"='0' "+atr.dataTitle+"='"+_l+"'>"+_i+"</i>";
}
function htmlNav(){
return ""
+ "<div class='"+dotCls(cls.nav)+"'>"
+ icoNav(cls.nav_shrink, lngAR.shrink, ico.shrink)
+ icoNav(cls.nav_spellcheck, lngAR.spellcheck, ico.spellcheck)
+ icoNav(cls.nav_tashkeel, lngAR.tashkeel, ico.tashkeel)
+ icoNav(cls.nav_insertion, lngAR.insertion, ico.insertion)
+ icoNav(cls.nav_settings, lngAR.settings, ico.settings)
+ "</div>";
}
function initEventNav(){
$('body')
.on("click", cls.nav_shrink, function(){
if($(this).hasClass(dotCls(cls.dis_ico))) return;
if(toggleNav(cls.nav_shrink)){
applyShrink();
}else{
removeNavShrink(1);
}
})
.on("click", cls.nav_spellcheck, function(){
if($(this).hasClass(dotCls(cls.dis_ico))) return;
if(toggleNav(cls.nav_spellcheck)){
applySpellcheck();
}else{
removeNavSpellcheck(1);
}
})
.on("click", cls.nav_tashkeel, function(){
if($(this).hasClass(dotCls(cls.dis_ico))) return;
if(toggleNav(cls.nav_tashkeel)){
applyTashkeel();
}else{
removeNavTashkeel(1);
}
})
.on("click", cls.nav_insertion, function(){
if($(this).hasClass(dotCls(cls.dis_ico))) return;
if(toggleNav(cls.nav_insertion)){
applyInsertion();
}else{
removeNavInsertion(1);
}
})
.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();
}
});
}
//=======================================================================================================================
function dropdownCopy(){
const insSC = tippy(cls.btnOk, {
theme: thm,
trigger: 'click',
interactive: true,
popperOptions: {positionFixed: true},
flipOnUpdate: true,
inlinePositioning: true,
content: htmlCopy(),
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.subpopup + " input[name='_copy']").prop('checked', false);
return true;
}
});
window.tippyCopyInstances = tippyCopyInstances.concat(insSC);
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 confirmPaste(){
(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();});
confirmPaste();
}, tim.cpy);
}, tim.cpy);
}, tim.cpy);
}
function htmlCopy(){
return ""
+ "<div class='"+dotCls(cls.subpopup)+"'>"
+ "<div class='"+dotCls(cls.subpopup_hed)+"'>"
+ "<i class='"+dotCls(cls.material_ico)+" "+dotCls(cls.copy_ext)+"' "+atr.dataTitle+"='"+lngAR.cancel+"'>"+ico.close+"</i>"
+ "<i class='"+dotCls(cls.material_ico)+" "+dotCls(cls.copy_oky)+"' "+atr.dataTitle+"='"+lngAR.ok+"'>"+ico.ok+"</i>"
+ "</div>"
+ "<div class='"+dotCls(cls.background_even)+"'>"
+ "<h3>"+lngAR.copyClipboard+"</h3>"
+ "</div>"
+ "<div>"
+ "<label><input type='checkbox' name='_copy'>"+lngAR.neverShowAgain+"</label>"
+ "</div>";
+ "</div>";
}
function initEventCopy(){
$('body')
.on("click", cls.copy_ext, function(){
tippyCopyInstances.forEach(instance => {instance.hide();});
})
.on("click", cls.copy_oky, function(){
if($(cls.subpopup + " input[name='_copy']").prop("checked")) GM.setValue(key.copy, true);
setCopy();
});
}
//=======================================================================================================================
function applyShrink(){
var _oldHtml = elmTxt().htmlNonSpellcheckInsertion();
msgCall(0, null, function(){setTimeout(function(){stopAjax();},tim.run);});
$(cls.nav_shrink).attr(atr.processAjax, '1').clsAddDel(0, cls.finsh).clsAddDel(1, cls.dis_ico).css('pointer-events', 'none');
try{
if($(cls.nav_shrink).attr(atr.processAjax) == 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');
}
);
htmlShrink = _oldHtml;
cancelAllNav(cls.nav_shrink);
finshAjax(cls.nav_shrink, true, lngAR.succeedShrink);
}
}catch(_err) {
if($(cls.nav_shrink).attr(atr.processAjax) == 1) finshAjax(cls.nav_shrink, false, lngAR.failShrink);
}
}
function removeNavShrink(_b){
var _f = function(){
if(htmlShrink !== null) elmTxt().html(htmlShrink);
};
removeNav(cls.nav_shrink, (_b ? _f : undefined));
}
//=======================================================================================================================
function applySpellcheck(){
msgCall(0, null, function(){setTimeout(function(){stopAjax();},tim.run);});
$(cls.nav_spellcheck).attr(atr.processAjax, '1').clsAddDel(0, cls.finsh).clsAddDel(1, cls.dis_ico).css('pointer-events', 'none');
$(cls.incorrect_word).replaceWith(function() { return $(this).text(); });
try{
xhrAjax = GM.xmlHttpRequest({
method: 'GET',
url: 'https://tahadz.com/cgi-bin/mishkal.cgi/ajaxGet?text='+encodeURIComponent(texNeat())+'&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(atr.processAjax) == 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)+'" '+atr.dataOld+'="'+chosen+'" '+atr.dataIncorrect+'="'+suggest+'" '+atr.dataId+'="'+dotCls(cls.incorrect_word)+'_'+_i+'">' +
chosen +
'</span>' +
'$3'
);
});
if(_result){
dropdownSpellcheck();
cancelAllNav(cls.nav_spellcheck);
finshAjax(cls.nav_spellcheck, true, lngAR.succeedSpellcheck);
}else{
finshAjax(cls.nav_spellcheck, false, lngAR.failSpellcheck);
}
}
}catch(_err) {
if($(cls.nav_spellcheck).attr(atr.processAjax) == 1) finshAjax(cls.nav_spellcheck, false, lngAR.failSpellcheck);
}
},
ontimeout: function(){if($(cls.nav_spellcheck).attr(atr.processAjax) == 1) finshAjax(cls.nav_spellcheck, false, lngAR.failSpellcheck);},
onerror: function(){if($(cls.nav_spellcheck).attr(atr.processAjax) == 1) finshAjax(cls.nav_spellcheck, false, lngAR.failSpellcheck);}
});
}catch(_err) {
if($(cls.nav_spellcheck).attr(atr.processAjax) == 1) finshAjax(cls.nav_spellcheck, false, lngAR.failSpellcheck);
}
}
function dropdownSpellcheck(){
const insSC = tippy(cls.incorrect_word, {
theme: thm,
trigger: 'click',
interactive: true,
popperOptions: {positionFixed: true},
flipOnUpdate: true,
inlinePositioning: true,
sticky: true,
content: htmlSpellcheck(),
onShown(instance){
$(instance.reference).clsAddDel(1, cls.select_ico);
var _id = $(instance.reference).attr(atr.dataId);
var _suggest = $(instance.reference).attr(atr.dataIncorrect).split(new RegExp(';', 'g'));
var _html = '';
$.each(_suggest, function (_i, _v) {
_html += '<tr><td class="" '+atr.dataId+'="'+_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+'['+atr.dataId+'="'+$(_ths).attr(atr.dataId)+'"]');
}
function removeNavSpellcheck(_b){
removeNav(cls.nav_spellcheck, function(){
$(cls.incorrect_word).replaceWith(function() { return _b ? $(this).attr(atr.dataOld) : $(this).text(); });
});
}
function htmlSpellcheck(){
return ""
+ "<div class='"+dotCls(cls.subpopup)+" "+dotCls(cls.incorrect_popup)+"'>"
+ "<div class='"+dotCls(cls.incorrect_title)+"'><span>"+lngAR.selectWord+"</span></div>"
+ "<div class='"+dotCls(cls.incorrect_table)+"'>"
+ "<table>"
+ "<tbody></tbody>"
+ "</table>"
+ "</div>"
+ "</div>";
}
function initEventSpellcheck(){
$('body')
.on("click", cls.incorrect_table + " td", function(){
elmIncorrectWord(this).text($(this).text()).css('border-bottom', 'hidden');
if(elmIncorrectWord(this).attr(atr.dataOld) === $(this).text()){
elmIncorrectWord(this).css('border-bottom', '');
}else{
elmIncorrectWord(this).css('border-bottom', 'hidden');
}
tippySpellcheckInstances.forEach(instance => {instance.hide();});
})
.on("mouseenter", cls.incorrect_table + " tr", function(){
$(this).clsAddDel(1, cls.select_ico);
})
.on("mouseleave", cls.incorrect_table + " tr", function(){
$(this).clsAddDel(0, cls.select_ico);
});
}
//=======================================================================================================================
function applyTashkeel(){
msgCall(0, null, function(){setTimeout(function(){stopAjax();},tim.run);});
$(cls.nav_tashkeel).attr(atr.processAjax, '1').clsAddDel(0, cls.finsh).clsAddDel(1, cls.dis_ico).css('pointer-events', 'none');
tashkeelMishkal(function(_val){
if(unEmptyText(_val)){
resultTashkeel(cls.nav_tashkeel, _val);
}else{
tashkeelArabicKeyboard(function(_val){
if(unEmptyText(_val)){
resultTashkeel(cls.nav_tashkeel, _val);
}else{
if($(cls.nav_tashkeel).attr(atr.processAjax) == 1){
finshAjax(cls.nav_tashkeel, false, lngAR.failTashkeel);
}
}
});
}
});
}
function tashkeelMishkal(_callback){
try{
xhrAjax = GM.xmlHttpRequest({
method: 'GET',
url: 'https://tahadz.com/cgi-bin/mishkal.cgi/ajaxGet?text='+encodeURIComponent(texNeat())+'&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(_callback){
try{
xhrAjax = GM.xmlHttpRequest({
method: 'GET',
url: 'http://arabic-keyboard.org/tashkeel/import.php?area='+encodeURIComponent(texNeat())+'&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(atr.processAjax) == 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');
}
);
cancelAllNav(cls.nav_tashkeel);
finshAjax(_ths, true, lngAR.succeedTashkeel);
}
}
function removeNavTashkeel(_b){
var _f = function(){
elmTxt().html(elmTxt().html().removeTatweel().removeTashkeel());
};
removeNav(cls.nav_tashkeel, (_b ? _f : undefined));
}
//=======================================================================================================================
function removeNavInsertion(_b){
if(_b){
removeNav(cls.nav_insertion, function(){
$(cls.insertion).hide();
$(cls.insertion_word).replaceWith(function() { return $(this).attr(atr.dataCode); });
});
}else{
$(cls.insertion_word).clsAddDel(1, cls.insertion_word_dis);
removeNav(cls.nav_insertion);
}
}
function applyInsertion(){
(async () => {
var _def = '['
+ '{"title":"'+lngAR.dateTitle+'","code":"{ت}","format":"DD-MM-YYYY","type":"'+atr.dateGregorian+'","lang":"'+atr.langAR+'"},'
+ '{"title":"'+lngAR.timeTitle+'","code":"{ق}","format":"hh%3Amm%20A","type":"'+atr.time+'","lang":"'+atr.langAR+'"}'
+ ']';
jsonInsertion = await GM.getValue(key.insertion, _def);
try{
if($(cls.insertion_word).length){
$(cls.insertion_word).clsAddDel(0, cls.insertion_word_dis);
dropdownInsertion();
cancelAllNav(cls.nav_insertion);
finshAjax(cls.nav_insertion, true, lngAR.succeedInsertion);
return;
}
if(checkInsertion()){
$(cls.insertion).hide();
msgCall(0, null, function(){setTimeout(function(){stopAjax();},tim.run);});
$(cls.nav_insertion).attr(atr.processAjax, '1').clsAddDel(0, cls.finsh).clsAddDel(1, cls.dis_ico).css('pointer-events', 'none');
try {
if(checkHijriInsertion()){
if(unEmptyText(hijriInsertion)){
replaceInsertion(hijriInsertion);
dropdownInsertion();
cancelAllNav(cls.nav_insertion);
if($(cls.nav_insertion).attr(atr.processAjax) == 1) finshAjax(cls.nav_insertion, true, lngAR.succeedInsertion);
}else{
ajaxHijriInsertion(function(_val){
replaceInsertion(_val);
dropdownInsertion();
cancelAllNav(cls.nav_insertion);
if($(cls.nav_insertion).attr(atr.processAjax) == 1) finshAjax(cls.nav_insertion, true, lngAR.succeedInsertion);
});
}
}else{
replaceInsertion(null);
dropdownInsertion();
cancelAllNav(cls.nav_insertion);
if($(cls.nav_insertion).attr(atr.processAjax) == 1) finshAjax(cls.nav_insertion, true, lngAR.succeedInsertion);
}
} catch (_err) {
if($(cls.nav_insertion).attr(atr.processAjax) == 1) finshAjax(cls.nav_insertion, false, lngAR.failInsertion);
}
}else{
tableInsertionEmpty();
$(cls.insertion).show();
}
}catch(_err) {}
})();
}
function ajaxHijriInsertion(_callback){
try{
xhrAjax = GM.xmlHttpRequest({
method: 'GET',
url: 'http://www.ummulqura.org.sa',
headers: {'Content-Type': 'text/html;charset=UTF-8'},
timeout: tim.xhr,
onload: function(_res) {
try{
var _d = $(_res.responseText).find('span[id$=_lblHDay]').text();
var _m = $(_res.responseText).find('span[id$=_lblHMonthNumber]').text();
var _y = $(_res.responseText).find('span[id$=_lblHYear]').text();
hijriInsertion = (_d + '-' + (_m - 1) + '-' + _y);
_callback(hijriInsertion);
}catch(_err) {
_callback(null);
}
},
ontimeout: function(){_callback(null);},
onerror: function(){_callback(null);}
});
}catch(_err) {
_callback(null);
}
}
function dropdownInsertion(){
const insSC = tippy(cls.insertion_word, {
theme: thm,
trigger: 'click',
interactive: true,
popperOptions: {positionFixed: true},
flipOnUpdate: true,
inlinePositioning: true,
sticky: true,
content: popupInsertionWord(),
onShown(instance){ showPopupInsertion(instance); },
onHide(instance) { return hidePopupInsertion(instance); }
});
window.tippyInsertionInstances = tippyInsertionInstances.concat(insSC);
}
function showPopupInsertion(instance){
$(instance.reference).clsAddDel(1, cls.select_ico);
var _elm = $(instance.reference);
var _cls_sel = (cls.insertion_popup + " " + cls.insertion_popup_sel);
var _cls_put = (cls.insertion_popup + " input");
var _cls_spn = (_cls_sel + " span");
var _cls_dtH = (_cls_spn + "["+atr.dataType+"='"+atr.dateHijri+"']");
var _code = _elm.attr(atr.dataCode);
var _format = _elm.attr(atr.dataFormat);
var _type = _elm.attr(atr.dataType);
var _lang = _elm.attr(atr.dataLang);
console.log('code['+_code+'] format['+_format+'] type['+_type+'] lang['+_lang+']');
$(cls.insertion_popup + " " + cls.subpopup_hed + " span").text(lngAR.codeTitle + _code);
$(_cls_put + "[type='text']").val(decodeURIComponent(_format)).attr(atr.dataCode, _code);
$(_cls_spn).clsAddDel(0, cls.select_ico, cls.chosse_ico);
if(_type === atr.time){
$(_cls_dtH).parent().hide();
}else{
$(_cls_dtH).parent().show();
if(! unEmptyText(hijriInsertion)) ajaxHijriInsertion(function(_val){hijriInsertion = _val;});
if(_type === atr.dateHijri){
$(_cls_dtH).clsAddDel(1, cls.select_ico, cls.chosse_ico);
}else{
$(_cls_spn + "["+atr.dataType+"='"+atr.dateGregorian+"']").clsAddDel(1, cls.select_ico, cls.chosse_ico);
}
}
if(_lang === atr.langAR){
$(_cls_spn + "["+atr.dataLang+"='"+atr.langAR+"']").clsAddDel(1, cls.select_ico, cls.chosse_ico);
}else{
$(_cls_spn + "["+atr.dataLang+"='"+atr.langEN+"']").clsAddDel(1, cls.select_ico, cls.chosse_ico);
}
$(_cls_put + "[type='checkbox']").prop('checked', false);
$(_cls_put + "["+atr.dataAll+"]").attr(atr.dataAll, '0');
$(_cls_put + "["+atr.dataDefault+"]").attr(atr.dataDefault, '0');
}
function hidePopupInsertion(instance){
cancelInsertion();
$(instance.reference).clsAddDel(0, cls.select_ico);
setTimeout(function(){try{if(xhrAjax !== null) xhrAjax.abort();}catch(_err){}},tim.run);
return true;
}
function replaceInsertion(_hj){
$.each(
$.parseJSON(jsonInsertion),
function(_i, _v) {
replaceTxt(
'('+outTag+')('+escapeRegExp(_v.code)+')',
'<span '
+ 'class="'+dotCls(cls.insertion_word)+' '+dotCls(cls.ico)+'" '
+ atr.dataFormat + '="'+_v.format+'" '
+ atr.dataType + '="'+_v.type+'" '
+ atr.dataLang + '="'+_v.lang+'" '
+ atr.dataCode + '="$1">'
+ formatInsertion(_v.type, _v.lang, _v.format, _hj)
+ '</span>'
);
}
);
}
function formatInsertion(_type, _lang, _format, _hj){
if(_type === atr.time && _lang === atr.langAR){
return moment().locale(atr.langAR+'-rakan938').format(decodeURIComponent(_format));
}
if(_type === atr.dateHijri && unEmptyText(_hj)){
try{
var _h = _hj.split('-');
return moment().year(_h[2]).month(_h[1]).date(_h[0]).locale(_lang+'-rakan938').format(decodeURIComponent(_format));
} catch (e) {
return moment().locale(_lang).format(decodeURIComponent(_format));
}
}
return moment().locale(_lang).format(decodeURIComponent(_format));
}
function checkHijriInsertion(){
var _r = false;
try {
$.each($.parseJSON(jsonInsertion), function(_i, _v) {
if(_v.type === atr.dateHijri){
_r = new RegExp(escapeRegExp(_v.code)).test(elmTxt().text());
return false;
}
});
} catch (e) {}
return _r;
}
function checkInsertion(){
var _code = regxCodeInsertion();
if(unEmptyText(_code)){
return new RegExp(_code).test(elmTxt().text());
}else{
return false;
}
}
function regxCodeInsertion(){
try {
var _code = '';
$.each($.parseJSON(jsonInsertion), function(_i, _v) {_code += '(' + escapeRegExp(_v.code) + ')|';});
if(unEmptyText(_code)) return _code.substr(0, (_code.length - 1));
} catch (e) {}
return '';
}
function updateInsertion(_b){
var _code = '{ق}', _format = 'hh:mm A', _type = atr.time, _lang = atr.langAR, _save = '0', _all = '0';
var _format_val = $(cls.insertion_popup + " input[type='text']").val();
if(_b === 2 && lastUpdateInsertion === _format_val) return;
if(! unEmptyText(_format_val)) return;
lastUpdateInsertion = _format_val;
if(unEmptyText(_format_val)) _format = _format_val;
var _code_val = $(cls.insertion_popup + " input[type='text']").attr(atr.dataCode);
if(unEmptyText(_code_val)) _code = _code_val;
$(cls.insertion_popup_sel + " " + cls.chosse_ico).each(function() {
if(unEmptyText($(this).attr(atr.dataType))) _type = $(this).attr(atr.dataType);
if(unEmptyText($(this).attr(atr.dataLang))) _lang = $(this).attr(atr.dataLang);
});
$(cls.insertion_popup + " input[type='checkbox']").each(function() {
var _save_val = $(this).attr(atr.dataDefault);
var _all_val = $(this).attr(atr.dataAll);
if(unEmptyText(_save_val)) _save =_save_val;
if(unEmptyText(_all_val)) _all =_all_val;
});
var _formatInsertion = formatInsertion(_type, _lang, _format, (_type === atr.dateHijri ? hijriInsertion : null));
if(_b === 1){
if(_all === '1'){
$(cls.insertion_word + "["+atr.dataCode+"='"+_code+"']")
.text(_formatInsertion)
.attr(atr.dataFormat, encodeURIComponent(_format))
.attr(atr.dataType, _type)
.attr(atr.dataLang, _lang);
console.log('Change [All] --- code['+_code+'] format['+_format+'] type['+_type+'] lang['+_lang+']');
}else{
$(cls.insertion_word + cls.select_ico)
.text(_formatInsertion)
.attr(atr.dataFormat, encodeURIComponent(_format))
.attr(atr.dataType, _type)
.attr(atr.dataLang, _lang);
console.log('Change [ONE] --- code['+_code+'] format['+_format+'] type['+_type+'] lang['+_lang+']');
}
if(_save === '1'){
console.log('UPDATE JSON');
var _jsn = JSON.parse(jsonInsertion);
$.each(_jsn, function(_i, _v) {
if(_v.code === _code){
_v.format = encodeURIComponent(_format);
_v.type = _type;
_v.lang = _lang;
return false;
}
});
jsonInsertion = JSON.stringify(_jsn);
console.log(jsonInsertion);
GM.setValue(key.insertion, jsonInsertion);
}
tippyInsertionInstances.forEach(instance => {instance.hide();});
}else{
$(cls.insertion_word + cls.select_ico).text(_formatInsertion);
console.log('Change [ONE] --- code['+_code+'] format['+_format+'] type['+_type+'] lang['+_lang+']');
}
}
function cancelInsertion(){
try{
var _elm = $(cls.insertion_word + cls.select_ico);
var _type = _elm.attr(atr.dataType);
_elm.text(
formatInsertion(
_type,
_elm.attr(atr.dataLang),
_elm.attr(atr.dataFormat),
(_type === atr.dateHijri ? hijriInsertion : null)
)
);
}catch(_err){}
}
function initEventInsertion(){
$('body')
.on("click", cls.insertion_popup_sel + " span:not("+cls.chosse_ico+")", function(){
$(this).parent().find('span').clsAddDel(0, cls.hover_ico, cls.select_ico, cls.chosse_ico);
$(this).clsAddDel(1, cls.select_ico, cls.chosse_ico);
updateInsertion(0);
})
.on("click", cls.insertion_popup + " " + cls.material_ico, function(){
if($(this).attr(atr.dataTitle) === lngAR.cancel){
tippyInsertionInstances.forEach(instance => {instance.hide();});
}else if($(this).attr(atr.dataTitle) === lngAR.ok){
updateInsertion(1);
}
})
.on("click", cls.insertion_popup + " input[type='text']", function(){
if(alertOpenInput) return;
if($(twit.modalHeader).length) openInput(this);
})
.on("change", cls.insertion_popup + " input[type='checkbox']", function(){
if(unEmptyText($(this).attr(atr.dataAll))) $(this).attr(atr.dataAll, $(this).prop("checked") ? 1 : 0);
if(unEmptyText($(this).attr(atr.dataDefault))) $(this).attr(atr.dataDefault, $(this).prop("checked") ? 1 : 0);
})
.on("keyup", cls.insertion_popup + " input[type='text']", function(){
updateInsertion(2);
})
.on("paste cut", cls.insertion_popup + " input[type='text']", function(){
setTimeout(function(){updateInsertion(2);},tim.run);
})
.on("mouseenter", cls.insertion_popup_sel + " span:not("+cls.chosse_ico+")", function(){
$(this).clsAddDel(1, cls.hover_ico);
})
.on("mouseleave", cls.insertion_popup_sel + " span:not("+cls.chosse_ico+")", function(){
$(this).clsAddDel(0, cls.hover_ico);
});
}
function tableInsertionEmpty(){
try{
if($(cls.insertion + " tr").length) return;
$.each($.parseJSON(jsonInsertion), function(_i, _v) {
var _tr = '<tr>'
+ '<td style="width:20%;">'+_v.code+'</td>'
+ '<td style="width:40%;">'+lngAR.willReplaced+'</td>'
+ '<td style="width:40%;">'+lngAR.b+_v.title+'</td>'
+ '</tr>';
$(_tr).appendTo(cls.insertion + " tbody");
});
} catch (e) {}
}
function popupInsertionEmpty(){
return ""
+ "<div class='"+dotCls(cls.insertion)+"'>"
+ "<span style='font-weight:bold;'>"+lngAR.titleInsertion+"</span>"
+ '<p><table style="width:100%;"><tbody></tbody></table>'
+ "</div>";
}
function popupInsertionWord(){
return ""
+ "<div class='"+dotCls(cls.subpopup)+" "+dotCls(cls.insertion_popup)+"'>"
+ "<div class='"+dotCls(cls.subpopup_hed)+"'>"
+ "<span></span>"
+ "<i class='"+dotCls(cls.material_ico)+" "+dotCls(cls.ico)+"' "+atr.dataTitle+"='"+lngAR.cancel+"'>"+ico.close+"</i>"
+ "<i class='"+dotCls(cls.material_ico)+" "+dotCls(cls.ico)+"' "+atr.dataTitle+"='"+lngAR.ok+"'>"+ico.ok+"</i>"
+ "</div>"
+ "<div class='"+dotCls(cls.background_even)+"'>"
+ "<input "+atr.dataCode+"='' type='text' value='' placeholder='"+lngAR.WriteFormat+"'>"
+ "</div>"
+ "<div class='"+dotCls(cls.insertion_popup_sel)+"'>"
+ "<span "+atr.dataType+"='"+atr.dateHijri+"'>"+lngAR.hijri+"</span>"
+ "<span "+atr.dataType+"='"+atr.dateGregorian+"'>"+lngAR.gregorian+"</span>"
+ "</div>"
+ "<div class='"+dotCls(cls.insertion_popup_sel)+"'>"
+ "<span "+atr.dataLang+"='"+atr.langAR+"'>"+lngAR.arabic+"</span>"
+ "<span "+atr.dataLang+"='"+atr.langEN+"'>"+lngAR.einglish+"</span>"
+ "</div>"
+ "<div class='"+dotCls(cls.background_even)+"'>"
+ "<label><input type='checkbox' "+atr.dataAll+"='0'>"+lngAR.applyAll+"</label>"
+ "</div>"
+ "<div>"
+ "<label><input type='checkbox' "+atr.dataDefault+"='0'>"+lngAR.defaultFormat+"</label>"
+ "</div>"
+ "</div>";
}
//=======================================================================================================================
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(atr.processAjax, '0').clsAddDel(0, cls.dis_ico).css('pointer-events', 'auto');
}
function finshAjax(_ths, _b, _tit){
$(_ths).css('pointer-events', 'auto').attr(atr.processAjax, '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(atr.dataTitle, _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 htmlMsg(){
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)+"' "+atr.dataTitle+"='"+lngAR.cancel+"'><i class='"+dotCls(cls.material_ico)+"'>"+ico.close+"</i></span>"
+ "</div>";
}
function initEventMsg(){
$('body')
.on("mouseenter", cls.msg_ico, function(){
$(cls.tit).text($(this).attr(atr.dataTitle));
})
.on("mouseleave", cls.msg_ico, function(){
$(cls.tit).text("");
});
}
//=======================================================================================================================
function htmlZoom(){
return ""
+ "<div class='"+dotCls(cls.zoom)+"'>"
+ "<div>"
+ "<i class='"+dotCls(cls.material_ico)+" "+dotCls(cls.ico)+" "+dotCls(cls.zoom_up)+"' "+atr.dataTitle+"='"+lngAR.upFont+"'>"+ico.zoomIn+"</i>"
+ "<span></span>"
+ "<i class='"+dotCls(cls.material_ico)+" "+dotCls(cls.ico)+" "+dotCls(cls.zoom_down)+"' "+atr.dataTitle+"='"+lngAR.downFont+"'>"+ico.zoomOut+"</i>"
+ "<span></span>"
+ "<i class='"+dotCls(cls.material_ico)+" "+dotCls(cls.ico)+" "+dotCls(cls.zoom_rest)+"' "+atr.dataTitle+"='"+lngAR.restFont+"'>"+ico.rest+"</i>"
+ "</div>"
+ "</div>";
}
function initEventZoom(){
$('body')
.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("mouseover", cls.txt + ", " + cls.zoom, function(){
$(cls.zoom).show();
})
.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();
});
}
//=======================================================================================================================
function htmlSettings(){
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.background_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)+"' "+atr.dataTitle+"='"+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'>JQuery</a></div>"
+ "<div class='"+dotCls(cls.settings_link)+"'>- <a target='_blank' href='https://atomiks.github.io/tippyjs'>TippyJs</a></div>"
+ "<div class='"+dotCls(cls.settings_link)+"'>- <a target='_blank' href='https://google.github.io/material-design-icons'>Material design icons</a></div>"
+ "<div class='"+dotCls(cls.settings_link_last)+"'>- <a target='_blank' href='https://momentjs.com'>MomentJs</a></div>"
+ "<div class='"+dotCls(cls.background_even)+" "+dotCls(cls.settings_title)+"'>"+lngAR.spellcheck+"</div>"
+ "<div class='"+dotCls(cls.background_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.background_even)+" "+dotCls(cls.settings_title)+"'>"+lngAR.hijriSettings+"</div>"
+ "<div class='"+dotCls(cls.background_even)+" "+dotCls(cls.settings_link_last)+"'>- <a target='_blank' href='http://www.ummulqura.org.sa'>Umm Al-Qura</a></div>"
+ "<div class='"+dotCls(cls.settings_both)+"'>"
+ "<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+"' "+atr.dataTitle+"='"+lngAR.devAccount+"'>@RAKAN938</div>"
+ "</div>"
+ "</div>";
}
function restSettings(){
if (confirm(lngAR.msgRestSettings)){
(async () => {
await GM.deleteValue(key.copy);
await GM.deleteValue(key.paste);
await GM.deleteValue(key.insertion);
tippyMainInstances.forEach(instance => {instance.hide();});
})();
}
}
function initEventSettings(){
$('body')
.on("click", cls.settings_btn_rest, function(){
restSettings();
})
.on("click", cls.settings_btn_account, function(){
window.location.href = '/RAKAN938';
});
}
//=======================================================================================================================
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 openInput(_ths){
$(twit.modalHeader).find('[tabindex="0"]').attr('tabindex', '-1');
alert(lngAR.WriteFormat);
alertOpenInput = true;
$(twit.modalHeader).find(twit.clsElmTwit).attr('tabindex', '0');
setTimeout(function(){$(_ths).focus();},tim.run);
}
//=======================================================================================================================
})();