User:Habst/wikidata Qnum.js

// credit to User:Danski454/wikidata Qnum.js

$(document).ready(function{ const waid = document.querySelector("a[href^='https://worldathletics.org/athletes/']")?.href.split(/[-/]/).at(-1);  const qid = $("#t-wikibase").length === 1 ? $("#t-wikibase a").attr("href").split("/").at(-1) : mw.config.get("wgWikibaseItemId");  const url = `https://www.wikidata.org/wiki/${qid}#sitelinks-wikipedia`;  window.addEventListener('keydown', e => { if (e.key === 'w' && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA') window.location.href = url; }); if (qid) $("#firstHeading").append(` (${qid})${waid ? ` (${waid})` : ''} `); });