User:Pere prlpz/common.js

// Ajoute un lien Wikidata si il n'y en a pas // From https://fr.wikipedia.org/w/index.php?title=MediaWiki:Common.js&oldid=92077150 if(mw.config.get('wgAction')=="view" || mw.config.get('wgAction')=="submit" || mw.config.get('wgAction')=="purge") addOnloadHook(CreateEmptyWikidataLink); function CreateEmptyWikidataLink{ var WikidataEmptyLi = document.querySelectorAll("li.wbc-nolanglinks")[0]; var pLang= document.getElementById("p-lang"); if(!WikidataEmptyLi && !pLang){ var TB = document.getElementById('p-tb'); if(!TB) return; pLang = TB.cloneNode(true); pLang.id = "p-lang"; pLangH3 = pLang.getElementsByTagName("h3")[0]; if(pLangH3) pLangH3.innerHTML = "Languages"; var pLangUL = pLang.getElementsByTagName("ul")[0]; pLangUL.innerHTML = ""; TB.parentNode.insertBefore(pLang, TB.nextSibling); WikidataEmptyLi = document.createElement('li'); WikidataEmptyLi.className = "wbc-editpage wbc-nolanglinks"; pLangUL.appendChild(WikidataEmptyLi); }    pLang.style.display = "block"; };