মিডিয়াউইকি:Gadget-VisualEditorEverywhere.js

লক্ষ্য করুন: প্রকাশ করার পর, পরিবর্তনগুলো দেখতে আপনাকে আপনার ব্রাউজারের ক্যাশে পরিষ্কার করার প্রয়োজন হতে পারে।

  • ফায়ারফক্স / সাফারি: পুনরায় লোড-এ ক্লিক করার সময় শিফট টিপে ধরে রাখুন, অথবা হয় Ctrl-F5 বা Ctrl-R টিপুন (ম্যাকে ⌘-R টিপুন)
  • গুগল ক্রোম: Ctrl-Shift-R (ম্যাকে ⌘-Shift-R) টিপুন
  • ইন্টারনেট এক্সপ্লোরার / এজ: Ctrl ধরে রাখা অবস্থায় Refresh-এ ক্লিক করুন, অথবা Ctrl-F5 টিপুন
  • অপেরা: Ctrl-F5 টিপুন।
// মূল ডেভেলপার [[w:en:User:Novem_Linguae]]
// জেকুয়েরি ডাউনগ্রেড, স্কিন ডেফিনিশন ও স্টাইলশিট মডিফিকেশন এবং স্থানীয়করণ - ঐশিক রেহমান [[user:Aishik_Rehman]]
if (jQuery !== undefined && mediaWiki !== undefined) {
    (function () {
        var insertVETab = function insertVETab() {
            // Insert Edit tab at top of page
            var htmlClass = mw.config.get('skin') === 'vector' ? 'mw-list-item' : 'vector-tab-noicon mw-list-item collapsible';
            var htmlToInsert = '<li id="ca-ve-edit" class="' + htmlClass + '" style="display: list-item; float: left; margin: 0 8px;"><a href="/w/index.php?title=' + articleName + '&amp;veaction=edit" title="Edit this page [alt-shift-v]" accesskey="v">সম্পাদনা</a></li>';
            $('#ca-edit').before(htmlToInsert);
            $('#ca-ve-edit').show();
        };

        var insertVESectionLink = function insertVESectionLink() {
            // Insert [ edit ] by each section
            // Foreach edit button
            $('.mw-editsection').each(function () {
                // Generate visual editor section link for this element
                // Credit to Bartosz Dziewoński (WMF) for this fix
                var veEditHref = $(this).find('a').attr('href').replace('&action=edit', '&veaction=edit');

                // Generate HTML to insert
                htmlToInsert = '<a href="" class="mw-editsection-visualeditor">দৃ.সম্পাদনা</a>    <span class="mw-editsection-divider"> | </span>';

                // Insert the HTML right after the bracket (the first span contained in .mw-editsection is <span class="mw-editsection-bracket">s
                // Inline tags such as <span> do not work with :nth-child, .before(), etc. Must use :first-of-type.
                $(this).children('span:first-of-type').after(htmlToInsert);

                // Inject our generated URL for the edit button
                $(this).find('.mw-editsection-visualeditor').attr('href', veEditHref);
            });

            showVEEditLink();

            // Below is a possible, untested fix for the race condition. I need a test case though.
            /*
            new MutationObserver(() => {
                showVEEditLink();
            }).observe($('.mw-editsection-visualeditor, .mw-editsection-divider')[0], {childList: true});
            */
        };

        var showVEEditLink = function showVEEditLink() {
            $('.mw-editsection-visualeditor, .mw-editsection-divider').show();
        };

        var articleName = mw.config.get('wgPageName');
        articleName = encodeURIComponent(articleName); // fix bug involving & not getting converted to &amp;
        var buttonIsPresent = $('#ca-ve-edit').length;
        var pageIsUserScript = articleName.match(/(?:\.js|\.css)$/);

        if (!buttonIsPresent && !pageIsUserScript) {
            insertVETab();
            insertVESectionLink();
        }
    })();
}