Jump to content

MediaWiki:Common.js: Difference between revisions

From Wikipedia
Created page with "Any JavaScript here will be loaded for all users on every page load.: $(document).ready(function () { $('#ca-viewsource').hide(); }); $(document).ready(function() { if (mw.config.get("wgAction") === "edit" || mw.config.get("wgAction") === "submit") { var userGroups = mw.config.get('wgUserGroups'); // Only tag regular 'user' edits, not sysop or approver if (userGroups.includes('user') && !userGroups.includes('approver') && !userGroups.includes('s..."
 
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 15: Line 15:
         $wpTextbox1.val("{{NeedsReview}}\n" + $wpTextbox1.val());
         $wpTextbox1.val("{{NeedsReview}}\n" + $wpTextbox1.val());
       }
       }
    }
  }
});
$(document).ready(function () {
  if (mw.config.get('skin') === 'vector-2022') {
    const logoContainer = document.querySelector('.vector-header-start #p-logo');
    if (logoContainer && !document.getElementById('site-name-custom')) {
      const siteName = mw.config.get('wgSiteName') || 'Wikipedia';
      const nameDiv = document.createElement('div');
      nameDiv.id = 'site-name-custom';
      nameDiv.textContent = siteName;
      const taglineDiv = document.createElement('div');
      taglineDiv.id = 'real-tagline';
      taglineDiv.textContent = 'The Free Encyclopedia';
      logoContainer.appendChild(nameDiv);
      logoContainer.appendChild(taglineDiv);
     }
     }
   }
   }
});
});

Latest revision as of 20:02, 18 June 2025

/* Any JavaScript here will be loaded for all users on every page load. */

$(document).ready(function () {
    $('#ca-viewsource').hide();
});

$(document).ready(function() {
  if (mw.config.get("wgAction") === "edit" || mw.config.get("wgAction") === "submit") {
    var userGroups = mw.config.get('wgUserGroups');

    // Only tag regular 'user' edits, not sysop or approver
    if (userGroups.includes('user') && !userGroups.includes('approver') && !userGroups.includes('sysop')) {
      var $wpTextbox1 = $('#wpTextbox1');
      if ($wpTextbox1.length && !$wpTextbox1.val().includes("{{NeedsReview}}")) {
        $wpTextbox1.val("{{NeedsReview}}\n" + $wpTextbox1.val());
      }
    }
  }
});

$(document).ready(function () {
  if (mw.config.get('skin') === 'vector-2022') {
    const logoContainer = document.querySelector('.vector-header-start #p-logo');
    if (logoContainer && !document.getElementById('site-name-custom')) {
      const siteName = mw.config.get('wgSiteName') || 'Wikipedia';

      const nameDiv = document.createElement('div');
      nameDiv.id = 'site-name-custom';
      nameDiv.textContent = siteName;

      const taglineDiv = document.createElement('div');
      taglineDiv.id = 'real-tagline';
      taglineDiv.textContent = 'The Free Encyclopedia';

      logoContainer.appendChild(nameDiv);
      logoContainer.appendChild(taglineDiv);
    }
  }
});