Jump to content

User:Vuccala/common.js

From Wiktionary, the free dictionary

Note: You may have to bypass your browser’s cache to see the changes. In addition, after saving a sitewide CSS file such as MediaWiki:Common.css, it will take 5-10 minutes before the changes take effect, even if you clear your cache.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

This JavaScript is executed for Vuccala on every page load.


//// Fades away bot edits on the Revision history page so it's easier to see human edits:
(function() {
    function containsBot(text) {
        return text.toLowerCase().includes('bot');
    }

    var contributionLists = document.querySelectorAll('ul.mw-contributions-list');

    contributionLists.forEach(function(contributionList) {
        var bdiElements = contributionList.querySelectorAll('bdi');

        bdiElements.forEach(function(bdiElement) {
            if (containsBot(bdiElement.textContent)) {
                contributionList.style.opacity = '0.5';
            }
        });
    });
})();

// Hide TOC links to #Anagrams
document.querySelectorAll(`#toc [href^="#Anagrams"], #vector-toc [href^="#Anagrams"]`).forEach(e => e.parentElement.style.display = "none");
// Hide #Anagrams section(s)
document.querySelectorAll(`.mw-heading > [id^="Anagrams"]`).forEach(e => {
    e.parentElement.style.display = "none";
    e = e.parentElement.nextElementSibling;
    while(e && !e.classList.contains("mw-heading")) {
        e.style.display = "none";
        e = e.nextElementSibling;
    }
});