Jump to content

MediaWiki:Common.js: Difference between revisions

From Verified Wikipedia
No edit summary
Tag: Reverted
No edit summary
Tag: Manual revert
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
// Remove stats box on CreateAccount page (strong force)
/* Any JavaScript here will be loaded for all users on every page load. */
 
 
// Scroll to top on page load or refresh
window.addEventListener('load', function() {
    window.scrollTo({ top: 0, behavior: 'smooth' });
});
 
 
 
/* --- VERIFIED BADGE SCRIPT (Twitter-style, inline with title) --- */
mw.loader.using('mediawiki.util').then(function () {
mw.loader.using('mediawiki.util').then(function () {
     if (mw.config.get('wgCanonicalSpecialPageName') === 'CreateAccount') {
  $(function () {
 
     /* Badge + Popup HTML (matches your CSS exactly) */
    const badgeHTML = `
      <span class="verified-badge" aria-label="Verified">
        <img class="badge-icon"
            src="https://upload.wikimedia.org/wikipedia/commons/e/e4/Twitter_Verified_Badge.svg"
            width="20" height="20"
            alt="Verified">
 
        <div class="verified-popup" role="dialog" aria-hidden="true">
          <div class="popup-title">Verified</div>
 
          <div class="popup-description">
            <img class="inline-verified-icon"
                src="https://upload.wikimedia.org/wikipedia/commons/e/e4/Twitter_Verified_Badge.svg"
                width="16" height="16"
                alt="Verified icon">
           
            <div class="popup-text">
              Articles or profiles with a verified badge have been authenticated
              and may represent verified subscribers, notable individuals,
              government entities, or official organizations.
              <a href="#">Learn more</a>
            </div>
          </div>
        </div>
      </span>
    `;


        function removeStatsBox() {
    /* Add badge inline with page title */
            var statsSelectors = [
    const heading = $(".firstHeading");
                '.mw-ge-homepage-stats',
    heading.css({
                '.mw-ge-homepage-impact',
      "display": "inline-flex",
                '.growth-homepage-module--impact',
      "align-items": "center",
                '.growth-homepage-module-type-impact'
      "gap": "6px"
            ];
    });


            statsSelectors.forEach(function(selector) {
    heading.append(badgeHTML);
                document.querySelectorAll(selector).forEach(function(el) {
                    el.remove();
                });
            });
        }


        // Run immediately + run again after GrowthExperiments loads
  });
        removeStatsBox();
        setTimeout(removeStatsBox, 500);
        setTimeout(removeStatsBox, 1500);
        setTimeout(removeStatsBox, 3000);
    }
});
});

Latest revision as of 00:48, 4 December 2025

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


// Scroll to top on page load or refresh
window.addEventListener('load', function() {
    window.scrollTo({ top: 0, behavior: 'smooth' });
});



/* --- VERIFIED BADGE SCRIPT (Twitter-style, inline with title) --- */
mw.loader.using('mediawiki.util').then(function () {
  $(function () {

    /* Badge + Popup HTML (matches your CSS exactly) */
    const badgeHTML = `
      <span class="verified-badge" aria-label="Verified">
        <img class="badge-icon" 
             src="https://upload.wikimedia.org/wikipedia/commons/e/e4/Twitter_Verified_Badge.svg" 
             width="20" height="20" 
             alt="Verified">

        <div class="verified-popup" role="dialog" aria-hidden="true">
          <div class="popup-title">Verified</div>

          <div class="popup-description">
            <img class="inline-verified-icon"
                 src="https://upload.wikimedia.org/wikipedia/commons/e/e4/Twitter_Verified_Badge.svg"
                 width="16" height="16"
                 alt="Verified icon">
            
            <div class="popup-text">
              Articles or profiles with a verified badge have been authenticated 
              and may represent verified subscribers, notable individuals, 
              government entities, or official organizations.
              <a href="#">Learn more</a>
            </div>
          </div>
        </div>
      </span>
    `;

    /* Add badge inline with page title */
    const heading = $(".firstHeading");
    heading.css({
      "display": "inline-flex",
      "align-items": "center",
      "gap": "6px"
    });

    heading.append(badgeHTML);

  });
});