Widget:Character.Background

De Wiki Gla
Revisão de 19h03min de 17 de novembro de 2025 por Gurren1 (discussão | contribs) (Criou página com '<!-- =========================== BACKGROUND SYSTEM =========================== --> <script> (function () { function applyBg(el) { try {...')
(dif) ← Edição anterior | Revisão atual (dif) | Versão posterior → (dif)
Ir para navegação Ir para pesquisar

<script>

   (function () {
       function applyBg(el) {
           try {
               var url = el.getAttribute('data-bg-url');
               if (!url) {
                   var f = el.getAttribute('data-bg-file');
                   if (f) {
                       var base = (window.mw && mw.util && typeof mw.util.wikiScript === 'function')
                           ? mw.util.wikiScript()
                           : (window.mw && mw.config ? (mw.config.get('wgScript') || '/index.php') : '/index.php');
                       var path = 'Especial:FilePath/' + f.replace(/^Arquivo:|^File:/, );
                       if (window.mw && mw.util && typeof mw.util.wikiUrlencode === 'function') {
                           url = base + '?title=' + mw.util.wikiUrlencode(path);
                       } else {
                           url = base + '?title=' + encodeURIComponent(path).replace(/%2F/g, '/');
                       }
                       el.setAttribute('data-bg-url', url);
                   }
               }
               if (url) {
                   el.style.backgroundImage = 'url("' + url + '")';
               }
           } catch (e) { /* no-op */
           }
       }
       document.querySelectorAll('[data-bg-url], [data-bg-file]').forEach(applyBg);
       // Apply to future elements (AJAX)
       new MutationObserver((mutations) => {
           mutations.forEach((m) => {
               if (m.type === 'childList') {
                   m.addedNodes.forEach((n) => {
                       if (n.nodeType === 1) {
                           applyBg(n);
                       }
                   });
               } else if (m.type === 'attributes' && m.target) {
                   applyBg(m.target);
               }
           });
       }).observe(document.body, {
           attributes: true,
           childList: true,
           subtree: true,
       });
   })();

</script>