Widget:Character.Background
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>