MediaWiki:CodeEditorSwitch/code.js

/* ==CodeEditorSwitch== - A JavaScript script for switching from VisualEditor to Classic editor - on .js and .css pages - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Author: User:Blaster Niceshot - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! PERSONAL USE ONLY ! $(document).ready(function{   /* Languages other than English that use "VisualEditor" text    for the VisualEditor button do not need to be included here,    as the script uses that text by default. */    var i18n = {        af: 'Visueel',        ar: 'المحرر المرئي',        be: 'Візуальны рэдактар',        bn: 'ভিজ্যুয়ালএডিটর',        ca: 'Editor visual',        en: 'VisualEditor',        es: 'Editor Visual',        fa: 'ویرایشگر دیداری',        fi: 'Visuaalinen muokkain',        fr: 'ÉditeurVisuel',        gl: 'Editor visual',        ja: 'ビジュアルエディタ',        ko: '시각편집기',        li: 'Visuele tekstverwerker',        lv: 'Vizuālais redaktors',        nl: 'Visuele tekstverwerker',        pt: 'Editor Visual',        'pt-BR': 'Editor visual',        ro: 'EditorVizual',        ru: 'Визуальный редактор',        sr: 'Визуелни уређивач',        vi: 'Soạn thảo trực quan',        zh:'视效编辑器'    }; var setLanguage = ''; if (typeof i18n[mw.config.get('wgUserLanguage')] === 'string') { setLanguage = mw.config.get('wgUserLanguage'); } else { setLanguage = 'en'; }   var codeEditorSwitch = $.extend({        changeEditBtn: true,        redirectToClassic: true,        lang: setLanguage    }, window.codeEditorSwitch); var url = window.location.href.toString; function switchEditor { if ((url.endsWith(".js") || url.endsWith(".css")) === true) { var classicBtn = $('#ca-edit'); classicBtn.text(i18n[codeEditorSwitch.lang]); classicBtn.attr('href',url + '?veaction=edit&cesredirect=false'); classicBtn.off('click'); var visualBtn = $('#ca-ve-edit'); visualBtn.attr('href',url + '?action=edit'); visualBtn.off('click'); }   }    if (mw.config.get('wgVisualEditorPreferred') === true) { if (codeEditorSwitch.changeEditBtn === true) { $(document).on('hover', '#ca-ve-edit', function{               switchEditor;            }); $(document).on('hover', '.WikiaPageHeader .drop', function{               switchEditor;            }); }   }    if (codeEditorSwitch.redirectToClassic === true) { if ((url.includes('.css?') || url.includes('.js?')) === true && url.includes('veaction') === true && url.includes('cesredirect=false') === false) { location.replace(url.replace('veaction','action')); }   } });