|
|
| Line 1: |
Line 1: |
| /* 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);
| |
|
| |
| });
| |
| });
| |
|
| |
| /*-----------------------end----------------*/
| |
|
| |
| // Remove the "Verified Wikipedia is made by people like you" benefits block
| |
| ( function () {
| |
| // run after DOM ready
| |
| function removeBenefits() {
| |
| // look for any element whose text contains the exact heading text, then remove the nearest panel/container
| |
| var nodes = document.querySelectorAll('div, section, aside, article');
| |
| nodes.forEach(function (n) {
| |
| try {
| |
| if (n.textContent && n.textContent.trim().includes('Verified Wikipedia is made by people like you')) {
| |
| // try some sensible parent candidates to remove whole block
| |
| var toRemove = n.closest('.mw-createacct-benefits, .mw-createaccount-benefits, .mw-ui-one-third, .vector-sidebar, .mw-createacct-benefits-wrapper') || n.closest('aside') || n;
| |
| if (toRemove) {
| |
| toRemove.remove();
| |
| // once removed, stop scanning
| |
| throw 'done';
| |
| }
| |
| }
| |
| } catch (e) {
| |
| if (e === 'done') return;
| |
| // ignore other errors
| |
| }
| |
| });
| |
| }
| |
|
| |
| if (document.readyState === 'complete' || document.readyState === 'interactive') {
| |
| setTimeout(removeBenefits, 100); // small delay in case Vue inserts it later
| |
| } else {
| |
| document.addEventListener('DOMContentLoaded', function () {
| |
| setTimeout(removeBenefits, 100);
| |
| });
| |
| }
| |
|
| |
| // Also run again later (for modules injected after load)
| |
| setTimeout(removeBenefits, 1000);
| |
| setTimeout(removeBenefits, 3000);
| |
| }() );
| |