MediaWiki:Gadget-PagePreviews.js
Jump to navigation
Jump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
// Page Previews for Wiktionary, by [[User:Ioaxxere]]
// <nowiki>
// Generated using: [[MediaWiki:Gadget-PagePreviews.js/ConstGeneration]]
const INTERWIKI_PREFIXES = new Map([["aa", "aa"],["ab", "ab"],["ace", "ace"],["acronym", 0],["advisory", 0],["ady", "ady"],["af", "af"],["ak", "ak"],["als", "als"],["alt", "alt"],["am", "am"],["ami", "ami"],["an", "an"],["ang", "ang"],["ann", "ann"],["anp", "anp"],["antwiki", 0],["appropedia", 0],["aquariumwiki", 0],["ar", "ar"],["arborwiki", 0],["arc", "arc"],["arxiv", 0],["ary", "ary"],["arz", "arz"],["as", "as"],["ast", "ast"],["atj", "atj"],["av", "av"],["avk", "avk"],["awa", "awa"],["ay", "ay"],["az", "az"],["azb", "azb"],["b", 0],["ba", "ba"],["ban", "ban"],["bar", "bar"],["bat-smg", "bat-smg"],["battlestarwiki", 0],["bbc", "bbc"],["bcl", "bcl"],["bcnbio", 0],["bdr", "bdr"],["be", "be"],["be-tarask", "be-tarask"],["be-x-old", "be-tarask"],["beacha", 0],["betawiki", 0],["betawikiversity", 0],["bew", "bew"],["bg", "bg"],["bh", "bh"],["bi", "bi"],["bibcode", 0],["bibliowiki", 0],["bjn", "bjn"],["blk", "blk"],["bm", "bm"],["bn", "bn"],["bo", "bo"],["botwiki", 0],["boxrec", 0],["bpy", "bpy"],["br", "br"],["bs", "bs"],["btm", "btm"],["bug", "bug"],["bugzilla", 0],["bulba", 0],["bxr", "bxr"],["c", 0],["c2", 0],["ca", "ca"],["cache", 0],["cbk-zam", "cbk-zam"],["ccorg", 0],["cdo", "cdo"],["ce", "ce"],["ceb", "ceb"],["centralwikia", 0],["ch", "ch"],["chapter", 0],["cho", "cho"],["choralwiki", 0],["chr", "chr"],["chy", "chy"],["citizendium", 0],["ckb", "ckb"],["cmn", "zh"],["co", "co"],["commons", 0],["communitywiki", 0],["comune", 0],["cr", "cr"],["creativecommons", 0],["creativecommonswiki", 0],["crh", "crh"],["cs", "cs"],["csb", "csb"],["cu", "cu"],["cv", "cv"],["cy", "cy"],["cz", "cs"],["d", 0],["da", "da"],["dag", "dag"],["dbdump", 0],["dcdatabase", 0],["dcw", 0],["de", "de"],["debian", 0],["devmo", 0],["dga", "dga"],["dico", 0],["dicoado", 0],["dict", 0],["dictionary", 0],["diffblog", 0],["din", "din"],["diq", "diq"],["discord", 0],["disinfopedia", 0],["dk", "da"],["dmoz", 0],["dmozs", 0],["doi", 0],["donate", 0],["doom_wiki", 0],["download", 0],["dpd", 0],["dpla", 0],["drae", 0],["dsb", "dsb"],["dtp", "dtp"],["dty", "dty"],["dv", "dv"],["dz", "dz"],["ee", "ee"],["egl", "eml"],["el", "el"],["elibre", 0],["emacswiki", 0],["eml", "eml"],["en", "en"],["en-simple", "simple"],["encyc", 0],["englyphwiki", 0],["enkol", 0],["eo", "eo"],["epo", "eo"],["es", "es"],["esolang", 0],["et", "et"],["etherpad", 0],["ethnologue", 0],["ethnologuefamily", 0],["eu", "eu"],["exkcd", 0],["exotica", 0],["ext", "ext"],["f", 0],["fa", "fa"],["fandom", 0],["fanimutationwiki", 0],["fat", "fat"],["fedora", 0],["ff", "ff"],["fi", "fi"],["finalfantasy", 0],["finnix", 0],["fiu-vro", "fiu-vro"],["fj", "fj"],["flickrphoto", 0],["flickruser", 0],["fo", "fo"],["foldoc", 0],["fon", "fon"],["foundation", 0],["foundationsite", 0],["fr", "fr"],["freebsdman", 0],["freedomdefined", 0],["freenode", 0],["freesoft", 0],["frp", "frp"],["frr", "frr"],["fur", "fur"],["fy", "fy"],["ga", "ga"],["gag", "gag"],["gan", "gan"],["gardenology", 0],["gcr", "gcr"],["gd", "gd"],["gentoo", 0],["genwiki", 0],["gerrit", 0],["git", 0],["gitlab", 0],["gl", "gl"],["glk", "glk"],["globalcontribs", 0],["glottolog", 0],["glottopedia", 0],["gn", "gn"],["gom", "gom"],["google", 0],["googledefine", 0],["googlegroups", 0],["gor", "gor"],["got", "got"],["gpe", "gpe"],["gsw", "als"],["gu", "gu"],["guc", "guc"],["gucprefix", 0],["guildwarswiki", 0],["gur", "gur"],["gutenberg", 0],["gutenbergwiki", 0],["guw", "guw"],["gv", "gv"],["ha", "ha"],["hackerspaces", 0],["hak", "hak"],["hammondwiki", 0],["haw", "haw"],["hdl", 0],["he", "he"],["heraldik", 0],["hi", "hi"],["hif", "hif"],["ho", "ho"],["horizonlabs", 0],["hr", "hr"],["hrfwiki", 0],["hrwiki", 0],["hsb", "hsb"],["ht", "ht"],["hu", "hu"],["hy", "hy"],["hyw", "hyw"],["hz", "hz"],["ia", "ia"],["iarchive", 0],["iba", "iba"],["id", "id"],["ie", "ie"],["ig", "ig"],["igl", "igl"],["ii", "ii"],["ik", "ik"],["ilo", "ilo"],["imdbcompany", 0],["imdbname", 0],["imdbtitle", 0],["incubator", 0],["infosphere", 0],["inh", "inh"],["io", "io"],["irc", 0],["ircrc", 0],["ircs", 0],["is", "is"],["isni", 0],["iso639-3", 0],["issn", 0],["it", "it"],["iu", "iu"],["iuridictum", 0],["ja", "ja"],["jaglyphwiki", 0],["jam", "jam"],["jbo", "jbo"],["jira", 0],["jp", "ja"],["jstor", 0],["jv", "jv"],["ka", "ka"],["kaa", "kaa"],["kab", "kab"],["kamelo", 0],["karlsruhe", 0],["kbd", "kbd"],["kbp", "kbp"],["kcg", "kcg"],["kg", "kg"],["kge", "kge"],["ki", "ki"],["kj", "kj"],["kk", "kk"],["kl", "kl"],["km", "km"],["kn", "kn"],["knc", "knc"],["ko", "ko"],["koi", "koi"],["komicawiki", 0],["kr", "kr"],["krc", "krc"],["ks", "ks"],["ksh", "ksh"],["ku", "ku"],["kus", "kus"],["kv", "kv"],["kw", "kw"],["ky", "ky"],["la", "la"],["labsconsole", 0],["lad", "lad"],["lb", "lb"],["lbe", "lbe"],["lexemes", 0],["lez", "lez"],["lfn", "lfn"],["lg", "lg"],["li", "li"],["liberachat", 0],["libreplanet", 0],["lij", "lij"],["lingualibre", 0],["linguistlist", 0],["listarchive", 0],["lld", "lld"],["lmo", "lmo"],["ln", "ln"],["lo", "lo"],["localwiki", 0],["lofc", 0],["lojban", 0],["lokalhistoriewiki", 0],["lostpedia", 0],["lrc", "lrc"],["lt", "lt"],["ltg", "ltg"],["luxo", 0],["lv", "lv"],["lzh", "zh-classical"],["m", 0],["mad", "mad"],["mai", "mai"],["mail", 0],["mailarchive", 0],["map-bms", "map-bms"],["mariowiki", 0],["marveldatabase", 0],["mdf", "mdf"],["mdwiki", 0],["meatball", 0],["mediawikiwiki", 0],["mediazilla", 0],["memoryalpha", 0],["meta", 0],["metawiki", 0],["metawikimedia", 0],["metawikipedia", 0],["mg", "mg"],["mh", "mh"],["mhr", "mhr"],["mi", "mi"],["min", "min"],["mineralienatlas", 0],["miraheze", 0],["mixnmatch", 0],["mk", "mk"],["ml", "ml"],["mn", "mn"],["mni", "mni"],["mnw", "mnw"],["mo", "mo"],["moinmoin", 0],["mos", "mos"],["mosapedia", 0],["mozillawiki", 0],["mozillazinekb", 0],["mr", "mr"],["mrj", "mrj"],["ms", "ms"],["mt", "mt"],["mus", "mus"],["mw", 0],["mwl", "mwl"],["mwod", 0],["mwot", 0],["my", "my"],["myv", "myv"],["mzn", "mzn"],["n", 0],["na", "na"],["nah", "nah"],["nan", "zh-min-nan"],["nap", "nap"],["nara", 0],["nb", "no"],["nds", "nds"],["nds-nl", "nds-nl"],["ne", "ne"],["new", "new"],["ng", "ng"],["nia", "nia"],["nl", "nl"],["nlab", 0],["nn", "nn"],["no", "no"],["nost", "nostalgia"],["nostalgia", "nostalgia"],["nov", "nov"],["nqo", "nqo"],["nr", "nr"],["nrm", "nrm"],["nso", "nso"],["nup", "nup"],["nv", "nv"],["ny", "ny"],["oc", "oc"],["oclc", 0],["oeis", 0],["oewiki", 0],["oldwikisource", 0],["olo", "olo"],["olpc", 0],["om", "om"],["openlibrary", 0],["openstreetmap", 0],["openwetware", 0],["or", "or"],["organicdesign", 0],["orthodoxwiki", 0],["os", "os"],["osmwiki", 0],["otrs", 0],["otrswiki", 0],["outreach", 0],["outreachwiki", 0],["owasp", 0],["pa", "pa"],["pag", "pag"],["pam", "pam"],["pap", "pap"],["paws", 0],["pcd", "pcd"],["pcm", "pcm"],["pdc", "pdc"],["petscan", 0],["pfl", "pfl"],["phab", 0],["phabricator", 0],["pi", "pi"],["pih", "pih"],["pl", "pl"],["planetmath", 0],["pmid", 0],["pms", "pms"],["pnb", "pnb"],["pnt", "pnt"],["pokewiki", 0],["pokéwiki", 0],["policy", 0],["proofwiki", 0],["ps", "ps"],["pt", "pt"],["pwn", "pwn"],["pyrev", 0],["pythoninfo", 0],["q", 0],["qu", "qu"],["quality", 0],["quarry", 0],["rcirc", 0],["regiowiki", 0],["rev", 0],["revo", 0],["rfc", 0],["rheinneckar", 0],["rki", "rki"],["rm", "rm"],["rmy", "rmy"],["rn", "rn"],["ro", "ro"],["roa-rup", "roa-rup"],["roa-tara", "roa-tara"],["rodovid", 0],["rsk", "rsk"],["rt", 0],["ru", "ru"],["rue", "rue"],["rup", "roa-rup"],["rw", "rw"],["s", 0],["sa", "sa"],["sah", "sah"],["sat", "sat"],["sc", "sc"],["scholar", 0],["schoolswp", 0],["scn", "scn"],["sco", "sco"],["scores", 0],["scoutwiki", 0],["sd", "sd"],["se", "se"],["securewikidc", 0],["semantic-mw", 0],["senseislibrary", 0],["sep11", 0],["sg", "sg"],["sgs", "bat-smg"],["sh", "sh"],["sharemap", 0],["shi", "shi"],["shn", "shn"],["shoutwiki", 0],["shy", "shy"],["si", "si"],["silcode", 0],["simple", "simple"],["sk", "sk"],["skr", "skr"],["sl", "sl"],["slashdot", 0],["sm", "sm"],["smn", "smn"],["sn", "sn"],["so", "so"],["sourceforge", 0],["spcom", 0],["species", 0],["sq", "sq"],["sr", "sr"],["srn", "srn"],["ss", "ss"],["st", "st"],["stats", 0],["stewardry", 0],["stq", "stq"],["strategy", 0],["strategywiki", 0],["su", "su"],["sulutil", 0],["sv", "sv"],["svn", 0],["sw", "sw"],["swtrain", 0],["syl", "syl"],["szl", "szl"],["szy", "szy"],["ta", "ta"],["tardis", 0],["tay", "tay"],["tclerswiki", 0],["tcy", "tcy"],["tdd", "tdd"],["te", "te"],["tenwiki", "ten"],["test2wiki", "test2"],["testcommons", 0],["testwiki", "test"],["testwikidata", 0],["tet", "tet"],["tfwiki", 0],["tg", "tg"],["th", "th"],["thelemapedia", 0],["theopedia", 0],["ti", "ti"],["ticket", 0],["tig", "tig"],["tk", "tk"],["tl", "tl"],["tly", "tly"],["tmbw", 0],["tn", "tn"],["to", "to"],["tolkiengateway", 0],["toolforge", 0],["toolhub", 0],["toollabs", 0],["tools", 0],["tpi", "tpi"],["tr", "tr"],["translatewiki", 0],["trv", "trv"],["ts", "ts"],["tswiki", 0],["tt", "tt"],["tum", "tum"],["tviv", 0],["tw", "tw"],["twiki", 0],["twl", 0],["ty", "ty"],["tyv", "tyv"],["tyvawiki", 0],["udm", "udm"],["ug", "ug"],["uk", "uk"],["umap", 0],["uncyclopedia", 0],["unihan", 0],["ur", "ur"],["urbandict", 0],["usability", 0],["usemod", 0],["utrs", 0],["uz", "uz"],["v", 0],["ve", "ve"],["vec", "vec"],["vep", "vep"],["vi", "vi"],["viaf", 0],["vikidia", 0],["vlos", 0],["vls", "vls"],["vo", "vo"],["votewiki", 0],["voy", 0],["vro", "fiu-vro"],["vrts", 0],["vrtwiki", 0],["w", "en"],["wa", "wa"],["war", "war"],["wcna", 0],["weirdgloop", 0],["werelate", 0],["wg", "wg-en"],["wikia", 0],["wikiapiary", 0],["wikiasite", 0],["wikibooks", 0],["wikicities", 0],["wikicity", 0],["wikiconference", 0],["wikidata", 0],["wikiedudashboard", 0],["wikifunctions", 0],["wikifur", 0],["wikihow", 0],["wikiindex", 0],["wikilivres", 0],["wikilivresru", 0],["wikimania", 0],["wikimedia", 0],["wikinews", 0],["wikinfo", 0],["wikinvest", 0],["wikipapers", 0],["wikipedia", 0],["wikipediawikipedia", 0],["wikiquote", 0],["wikiskripta", 0],["wikisophia", 0],["wikisource", 0],["wikisp", 0],["wikispecies", 0],["wikispore", 0],["wikispot", 0],["wikitech", 0],["wikiti", 0],["wikitrek", 0],["wikiversity", 0],["wikivoyage", 0],["wikiwikiweb", 0],["wikt", 0],["wiktionary", 0],["wm2005", 0],["wm2006", 0],["wm2007", 0],["wm2008", 0],["wm2009", 0],["wm2010", 0],["wm2011", 0],["wm2012", 0],["wm2013", 0],["wm2014", 0],["wm2015", 0],["wm2016", 0],["wm2017", 0],["wm2018", 0],["wmam", 0],["wmania", 0],["wmar", 0],["wmat", 0],["wmau", 0],["wmbd", 0],["wmbe", 0],["wmbr", 0],["wmca", 0],["wmch", 0],["wmcl", 0],["wmcn", 0],["wmco", 0],["wmcz", 0],["wmcz_docs", 0],["wmcz_old", 0],["wmdc", 0],["wmde", 0],["wmdeblog", 0],["wmdk", 0],["wmdoc", 0],["wmec", 0],["wmee", 0],["wmes", 0],["wmet", 0],["wmf", 0],["wmfblog", 0],["wmfdashboard", 0],["wmfi", 0],["wmfr", 0],["wmge", 0],["wmhi", 0],["wmhk", 0],["wmhu", 0],["wmid", 0],["wmil", 0],["wmin", 0],["wmit", 0],["wmke", 0],["wmmk", 0],["wmmx", 0],["wmnl", 0],["wmno", 0],["wmnyc", 0],["wmpa-us", 0],["wmph", 0],["wmpl", 0],["wmplsite", 0],["wmpt", 0],["wmpunjabi", 0],["wmromd", 0],["wmrs", 0],["wmru", 0],["wmse", 0],["wmsk", 0],["wmteam", 0],["wmtr", 0],["wmtw", 0],["wmua", 0],["wmuk", 0],["wmve", 0],["wmza", 0],["wo", "wo"],["wookieepedia", 0],["wowwiki", 0],["wplibrary", 0],["wurmpedia", 0],["wuu", "wuu"],["xal", "xal"],["xh", "xh"],["xkcd", 0],["xmf", "xmf"],["xtools", 0],["yi", "yi"],["yo", "yo"],["yue", "zh-yue"],["za", "za"],["zea", "zea"],["zgh", "zgh"],["zh", "zh"],["zh-classical", "zh-classical"],["zh-cn", "zh"],["zh-min-nan", "zh-min-nan"],["zh-tw", "zh"],["zh-yue", "zh-yue"],["zu", "zu"],["zum", 0]]);
// Generated using: [[MediaWiki:Gadget-PagePreviews.js/ConstGeneration]]
const WP_LANGUAGES = new Map([["ab", "Abkhazian"],["ace", "Acehnese"],["ady", "Adyghe"],["af", "Afrikaans"],["als", "Alemannic"],["alt", "Southern Altai"],["am", "Amharic"],["ami", "Amis"],["an", "Aragonese"],["ang", "Old English"],["ann", "Obolo"],["anp", "Angika"],["ar", "Arabic"],["arc", "Aramaic"],["ary", "Moroccan Arabic"],["arz", "Egyptian Arabic"],["as", "Assamese"],["ast", "Asturian"],["atj", "Atikamekw"],["av", "Avaric"],["avk", "Kotava"],["awa", "Awadhi"],["ay", "Aymara"],["az", "Azerbaijani"],["azb", "South Azerbaijani"],["ba", "Bashkir"],["ban", "Balinese"],["bar", "Bavarian"],["bat-smg", "Samogitian"],["bbc", "Batak Toba"],["bcl", "Central Bikol"],["bdr", "West Coast Bajau"],["be", "Belarusian"],["be-tarask", "Belarusian (Taraškievica orthography)"],["bew", "Betawi"],["bg", "Bulgarian"],["bh", "Bhojpuri"],["bi", "Bislama"],["bjn", "Banjar"],["blk", "Pa'O"],["bm", "Bambara"],["bn", "Bangla"],["bo", "Tibetan"],["bpy", "Bishnupriya"],["br", "Breton"],["bs", "Bosnian"],["btm", "Batak Mandailing"],["bug", "Buginese"],["bxr", "Russia Buriat"],["ca", "Catalan"],["cbk-zam", "Chavacano"],["cdo", "Mindong"],["ce", "Chechen"],["ceb", "Cebuano"],["ch", "Chamorro"],["chr", "Cherokee"],["chy", "Cheyenne"],["ckb", "Central Kurdish"],["co", "Corsican"],["cr", "Cree"],["crh", "Crimean Tatar"],["cs", "Czech"],["csb", "Kashubian"],["cu", "Church Slavic"],["cv", "Chuvash"],["cy", "Welsh"],["da", "Danish"],["dag", "Dagbani"],["de", "German"],["dga", "Southern Dagaare"],["din", "Dinka"],["diq", "Dimli"],["dsb", "Lower Sorbian"],["dtp", "Central Dusun"],["dty", "Doteli"],["dv", "Divehi"],["dz", "Dzongkha"],["ee", "Ewe"],["el", "Greek"],["eml", "Emiliano-Romagnolo"],["en", "English"],["eo", "Esperanto"],["es", "Spanish"],["et", "Estonian"],["eu", "Basque"],["ext", "Extremaduran"],["fa", "Persian"],["fat", "Fanti"],["ff", "Fula"],["fi", "Finnish"],["fiu-vro", "Võro"],["fj", "Fijian"],["fo", "Faroese"],["fon", "Fon"],["fr", "French"],["frp", "Arpitan"],["frr", "Northern Frisian"],["fur", "Friulian"],["fy", "Western Frisian"],["ga", "Irish"],["gag", "Gagauz"],["gan", "Gan"],["gcr", "Guianan Creole"],["gd", "Scottish Gaelic"],["gl", "Galician"],["glk", "Gilaki"],["gn", "Guarani"],["gom", "Goan Konkani"],["gor", "Gorontalo"],["got", "Gothic"],["gpe", "Ghanaian Pidgin"],["gu", "Gujarati"],["guc", "Wayuu"],["gur", "Frafra"],["guw", "Gun"],["gv", "Manx"],["ha", "Hausa"],["hak", "Hakka Chinese"],["haw", "Hawaiian"],["he", "Hebrew"],["hi", "Hindi"],["hif", "Fiji Hindi"],["hr", "Croatian"],["hsb", "Upper Sorbian"],["ht", "Haitian Creole"],["hu", "Hungarian"],["hy", "Armenian"],["hyw", "Western Armenian"],["ia", "Interlingua"],["iba", "Iban"],["id", "Indonesian"],["ie", "Interlingue"],["ig", "Igbo"],["igl", "Igala"],["ik", "Inupiaq"],["ilo", "Iloko"],["inh", "Ingush"],["io", "Ido"],["is", "Icelandic"],["it", "Italian"],["iu", "Inuktitut"],["ja", "Japanese"],["jam", "Jamaican Creole English"],["jbo", "Lojban"],["jv", "Javanese"],["ka", "Georgian"],["kaa", "Kara-Kalpak"],["kab", "Kabyle"],["kbd", "Kabardian"],["kbp", "Kabiye"],["kcg", "Tyap"],["kg", "Kongo"],["kge", "Komering"],["ki", "Kikuyu"],["kk", "Kazakh"],["kl", "Kalaallisut"],["km", "Khmer"],["kn", "Kannada"],["knc", "Central Kanuri"],["ko", "Korean"],["koi", "Komi-Permyak"],["krc", "Karachay-Balkar"],["ks", "Kashmiri"],["ksh", "Colognian"],["ku", "Kurdish"],["kus", "Kusaal"],["kv", "Komi"],["kw", "Cornish"],["ky", "Kyrgyz"],["la", "Latin"],["lad", "Ladino"],["lb", "Luxembourgish"],["lbe", "Lak"],["lez", "Lezghian"],["lfn", "Lingua Franca Nova"],["lg", "Ganda"],["li", "Limburgish"],["lij", "Ligurian"],["lld", "Ladin"],["lmo", "Lombard"],["ln", "Lingala"],["lo", "Lao"],["lt", "Lithuanian"],["ltg", "Latgalian"],["lv", "Latvian"],["mad", "Madurese"],["mai", "Maithili"],["map-bms", "Banyumasan"],["mdf", "Moksha"],["mg", "Malagasy"],["mhr", "Eastern Mari"],["mi", "Māori"],["min", "Minangkabau"],["mk", "Macedonian"],["ml", "Malayalam"],["mn", "Mongolian"],["mni", "Manipuri"],["mnw", "Mon"],["mos", "Mossi"],["mr", "Marathi"],["mrj", "Western Mari"],["ms", "Malay"],["mt", "Maltese"],["mwl", "Mirandese"],["my", "Burmese"],["myv", "Erzya"],["mzn", "Mazanderani"],["nah", "Nahuatl"],["nap", "Neapolitan"],["nds", "Low German"],["nds-nl", "Low Saxon"],["ne", "Nepali"],["new", "Newari"],["nia", "Nias"],["nl", "Dutch"],["nn", "Norwegian Nynorsk"],["no", "Norwegian"],["nov", "Novial"],["nqo", "N’Ko"],["nr", "South Ndebele"],["nrm", "Norman"],["nso", "Northern Sotho"],["nup", "Nupe"],["nv", "Navajo"],["ny", "Nyanja"],["oc", "Occitan"],["olo", "Livvi-Karelian"],["om", "Oromo"],["or", "Odia"],["os", "Ossetic"],["pa", "Punjabi"],["pag", "Pangasinan"],["pam", "Pampanga"],["pap", "Papiamento"],["pcd", "Picard"],["pcm", "Nigerian Pidgin"],["pdc", "Pennsylvania German"],["pfl", "Palatine German"],["pi", "Pali"],["pl", "Polish"],["pms", "Piedmontese"],["pnb", "Western Punjabi"],["pnt", "Pontic"],["ps", "Pashto"],["pt", "Portuguese"],["pwn", "Paiwan"],["qu", "Quechua"],["rki", "Arakanese"],["rm", "Romansh"],["rmy", "Vlax Romani"],["rn", "Rundi"],["ro", "Romanian"],["roa-rup", "Aromanian"],["roa-tara", "Tarantino"],["rsk", "Pannonian Rusyn"],["ru", "Russian"],["rue", "Rusyn"],["rw", "Kinyarwanda"],["sa", "Sanskrit"],["sah", "Yakut"],["sat", "Santali"],["sc", "Sardinian"],["scn", "Sicilian"],["sco", "Scots"],["sd", "Sindhi"],["se", "Northern Sami"],["sg", "Sango"],["sh", "Serbo-Croatian"],["shi", "Tachelhit"],["shn", "Shan"],["si", "Sinhala"],["simple", "Simple English"],["sk", "Slovak"],["skr", "Saraiki"],["sl", "Slovenian"],["sm", "Samoan"],["smn", "Inari Sami"],["sn", "Shona"],["so", "Somali"],["sq", "Albanian"],["sr", "Serbian"],["srn", "Sranan Tongo"],["ss", "Swati"],["st", "Southern Sotho"],["stq", "Saterland Frisian"],["su", "Sundanese"],["sv", "Swedish"],["sw", "Swahili"],["syl", "Sylheti"],["szl", "Silesian"],["szy", "Sakizaya"],["ta", "Tamil"],["tay", "Atayal"],["tcy", "Tulu"],["tdd", "Tai Nuea"],["te", "Telugu"],["tet", "Tetum"],["tg", "Tajik"],["th", "Thai"],["ti", "Tigrinya"],["tig", "Tigre"],["tk", "Turkmen"],["tl", "Tagalog"],["tly", "Talysh"],["tn", "Tswana"],["to", "Tongan"],["tpi", "Tok Pisin"],["tr", "Turkish"],["trv", "Taroko"],["ts", "Tsonga"],["tt", "Tatar"],["tum", "Tumbuka"],["tw", "Twi"],["ty", "Tahitian"],["tyv", "Tuvinian"],["udm", "Udmurt"],["ug", "Uyghur"],["uk", "Ukrainian"],["ur", "Urdu"],["uz", "Uzbek"],["ve", "Venda"],["vec", "Venetian"],["vep", "Veps"],["vi", "Vietnamese"],["vls", "West Flemish"],["vo", "Volapük"],["wa", "Walloon"],["war", "Waray"],["wo", "Wolof"],["wuu", "Wu"],["xal", "Kalmyk"],["xh", "Xhosa"],["xmf", "Mingrelian"],["yi", "Yiddish"],["yo", "Yoruba"],["za", "Zhuang"],["zea", "Zeelandic"],["zgh", "Standard Moroccan Tamazight"],["zh", "Chinese"],["zh-classical", "Literary Chinese"],["zh-min-nan", "Minnan"],["zh-yue", "Cantonese"],["zu", "Zulu"]]);
const animationSpeed = 0.2; // seconds
mw.util.addCSS(`
.page-preview ol {
margin: 0 0.5em 0 1.5em;
padding: 0;
}
.page-preview dl {
margin-bottom: 0;
}
.page-preview p {
margin: 0;
}
/* popupContainer has the opacity animation, while popup gets translated. */
.popup-fade-in-up, .popup-fade-in-down {
animation: popup-fade-in ${animationSpeed}s ease forwards;
}
.popup-fade-out-up, .popup-fade-out-down {
animation: popup-fade-out ${animationSpeed}s ease forwards;
}
.popup-fade-in-up > div {
animation: popup-move-in-up ${animationSpeed}s ease forwards;
}
.popup-fade-in-down > div {
animation: popup-move-in-down ${animationSpeed}s ease forwards;
}
.popup-fade-out-up > div {
animation: popup-move-out-up ${animationSpeed}s ease forwards;
}
.popup-fade-out-down > div {
animation: popup-move-out-down ${animationSpeed}s ease forwards;
}
@keyframes popup-move-in-up {
0% {
transform: translate(0, 20px);
}
}
@keyframes popup-move-in-down {
0% {
transform: translate(0, -20px);
}
}
@keyframes popup-move-out-up {
100% {
transform: translate(0, -20px);
}
}
@keyframes popup-move-out-down {
100% {
transform: translate(0, 20px);
}
}
@keyframes popup-fade-out {
100% {
opacity: 0;
}
}
@keyframes popup-fade-in {
0% {
opacity: 0;
}
}
.ring-loader {
margin: auto;
width: 24px;
height: 24px;
border-radius: 50%;
border-top: 5px solid var(--wikt-palette-black, #202122);
border-bottom: 5px solid var(--wikt-palette-black, #202122);
border-left: 5px solid transparent;
border-right: 5px solid transparent;
animation: spin 1.2s linear infinite;
}
@keyframes spin {
100% {
transform: rotate(360deg);
}
}
.preview-headerlink, .preview-headerlink:visited {
color: inherit;
font-weight: bold;
}
/* Hack: get the speaker icon on Wikipedia articles without having to load Phonos. */
.ext-phonos .oo-ui-buttonElement-button:after {
content: "🔊";
}
.ext-phonos * {
display: inline !important;
padding: 0 !important;
margin: 0 !important;
}
`);
const definitionIcon = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 20 20" aria-hidden="true" fill="currentColor"><g><path d="M15 2a7.65 7.65 0 00-5 2 7.65 7.65 0 00-5-2H1v15h4a7.65 7.65 0 015 2 7.65 7.65 0 015-2h4V2zm2.5 13.5H14a4.38 4.38 0 00-3 1V5s1-1.5 4-1.5h2.5z"></path></g></svg>`;
const glossaryIcon = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 20 20" aria-hidden="true" fill="currentColor"><g><path d="M12.43 14.34A5 5 0 0110 15a5 5 0 113.95-2L17 16.09V3a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h10a2 2 0 001.45-.63z"></path><circle cx="10" cy="10" r="3"></circle></g></svg>`;
const articleIcon = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 20 20" aria-hidden="true" fill="currentColor"><g><path d="M5 1a2 2 0 00-2 2v14a2 2 0 002 2h10a2 2 0 002-2V3a2 2 0 00-2-2zm0 3h5v1H5zm0 2h5v1H5zm0 2h5v1H5zm10 7H5v-1h10zm0-2H5v-1h10zm0-2H5v-1h10zm0-2h-4V4h4z"></path></g></svg>`;
const bibliographyIcon = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 20 20" aria-hidden="true" fill="currentColor"><g><path d="M3 2h12c.5 0 1 .5 1 1v1c0 .5-.5 1-1 1H3c0 0 .5-.5.5-1V3c0-.5-.5-1-.5-1zM4 6h12c.5 0 1 .5 1 1v1c0 .5-.5 1-1 1H4c0 0 .5-.5.5-1V7c0-.5-.5-1-.5-1zM3 10h12c.5 0 1 .5 1 1v1c0 .5-.5 1-1 1H3c0 0 .5-.5.5-1v-1c0-.5-.5-1-.5-1zM4 14h12c.5 0 1 .5 1 1v1c0 .5-.5 1-1 1H4c0 0 .5-.5.5-1v-1c0-.5-.5-1-.5-1z"/></g></svg>`;
const loader = document.createElement("div");
loader.className = "ring-loader";
const popupContainer = document.createElement("div");
const popup = document.createElement("div");
const popupContent = document.createElement("div");
popupContainer.style = `display: none; position: absolute; filter: drop-shadow(0px 30px 30px rgba(0, 0, 0, 0.15)) drop-shadow(0px 0px 0.75px var(--wikt-palette-dullblue, #49555f)); z-index: 801`;
popupContainer.className = "page-preview";
popup.style = "box-sizing: border-box; height: 100%; background: var(--wikt-palette-white, #ffffff)";
popupContent.style = "display: flex; flex-direction: column; border-radius: 2px; box-sizing: border-box; color: var(--wikt-palette-black, #202122); overflow: auto; height: 100%; overflow-wrap: break-word; scrollbar-width: thin";
document.body.append(popupContainer);
popupContainer.append(popup);
popup.append(popupContent);
let popupTimer;
let openLink;
let mouseX, mouseY;
let API_controller = new AbortController();
function closePopup() {
if (!openLink) return;
openLink = null;
API_controller.abort();
API_controller = new AbortController();
if (popupContainer.classList.contains("popup-fade-in-up")) {
popupContainer.classList.remove("popup-fade-in-up");
popupContainer.classList.add("popup-fade-out-down");
} else {
popupContainer.classList.remove("popup-fade-in-down");
popupContainer.classList.add("popup-fade-out-up");
}
// After the animation has completed, reset the popup to its initial state.
setTimeout(() => {
popupContainer.style.display = "none";
popupContainer.classList.remove("popup-fade-out-down", "popup-fade-out-up");
}, animationSpeed * 1000);
}
popup.addEventListener("pointerenter", () => {
clearTimeout(popupTimer);
});
popup.addEventListener("pointerleave", () => {
clearTimeout(popupTimer);
popupTimer = setTimeout(closePopup, 300);
});
function processLink(link) {
let linkTitle = decodeURIComponent(link.pathname.split("/wiki/")[1]);
let titlePrefix = linkTitle.includes(":") ? linkTitle.toLowerCase().split(":")[0] : "";
let resolvedTitle = linkTitle;
let API_domain = link.origin;
let linkAnchor = decodeURIComponent(link.hash.slice(1) || "");
let isWPlink = link.href.match(/^https:\/\/[^.]+.wikipedia.org\/wiki\//);
let isPreviewLink = Boolean(link.closest(".page-preview"));
// Start with various checks to determine whether a link should be processed.
if (link.matches(`nav a, .cancelLink a, .mw-widget-titleOptionWidget a, .new, .preview-headerlink, .external, [href$="#"]`)) {
return;
} else if (linkTitle === "Appendix:Glossary" || linkTitle.startsWith("Appendix:Bibliography/")) {
// Bibliography and glossary subpages *must* have an anchor.
if (!linkAnchor) return;
} else if (!isWPlink) {
// Other Wiktionary pages must not have a lowercase-starting anchor (filters out some unhelpful links).
if (/^[a-z]/.test(linkAnchor)) return;
}
if (link.href.startsWith("https://en.wiktionary.org/wiki/")) {
// Filter out all interwiki prefixes.
if (INTERWIKI_PREFIXES.has(titlePrefix))
return;
let {namespace, title} = new mw.Title(linkTitle);
if (namespace === 0) { // Mainspace
if (title.endsWith("/translations"))
return;
} else if (namespace === 100) { // Appendix space
let appendixWithSlash = ["Adûni", "Afrihili", "Arabic_roots", "Belter_Creole", "Bibliography", "Black_Speech", "Bolak", "Communicationssprache", "Dothraki", "Eloi", "Gestures", "Glosa", "Goa'uld", "High_Valyrian", "Interlingue", "Interslavic", "Klingon", "Kotava", "Láadan", "Lapine", "Lingua_Franca_Nova", "Lojban", "Mandalorian", "Medefaidrin", "Minecraft", "Mundolinco", "Na'vi", "Neo", "Novial", "Noxilo", "Protologisms/Long_words", "Quenya", "Romanova", "Sindarin", "Snowclones", "Talossan", "Toki_Pona", "Unas"];
let appendixNoSlash = ["Boldface", "Capital_letter", "Glossary", "Italics", "Lowercase_letter", "Possessive", "Repetition", "Small_caps", "Strikethrough", "Subscript", "Superscript", "Underline", "Uppercase_letter"];
if (!appendixWithSlash.some(lang => title.startsWith(lang + "/")) && !appendixNoSlash.includes(title))
return;
} else if (namespace !== 118) { // Reconstruction space
return;
}
} else if (isWPlink) {
// Filter out invalid interwiki prefixes.
if (INTERWIKI_PREFIXES.get(titlePrefix) === 0)
return;
// Get the resolved title if it's a language interwiki.
if (INTERWIKI_PREFIXES.has(titlePrefix)) {
API_domain = `https://${INTERWIKI_PREFIXES.get(titlePrefix)}.wikipedia.org`;
resolvedTitle = linkTitle.substring(linkTitle.indexOf(":") + 1);
// If the resolved title contains another interwiki, return.
let resolvedTitlePrefix = resolvedTitle.includes(":") ? resolvedTitle.toLowerCase().split(":")[0] : ""; // same as linkPrefix
if (INTERWIKI_PREFIXES.has(resolvedTitlePrefix))
return;
}
} else {
return;
}
link.addEventListener("pointerover", event => {
[mouseX, mouseY] = [event.clientX, event.clientY];
clearTimeout(popupTimer);
// Ignore links which are already open.
if (link === openLink)
return;
if (!isPreviewLink)
closePopup();
// Fetch popup text immediately on hover to reduce delay.
let responsePromise = fetch(`${API_domain}/api/rest_v1/page/html/${encodeURIComponent(resolvedTitle)}`, {
headers: {"Api-User-Agent": "Gadget developed by [[User:Ioaxxere]]"},
signal: API_controller.signal
}).then(r => r.text()).catch(() => { /* fetch was aborted */ });
popupTimer = setTimeout(() => {
popupContainer.style.display = "";
popupContent.innerHTML = "";
popupContent.append(loader);
popupContent.style.padding = "14px 16px 8px";
// Disable link hovering until animation has completed.
popupContent.style.pointerEvents = "none";
setTimeout(() => popupContent.style.pointerEvents = "", animationSpeed * 1000);
// Adapt the popup for large, standard, and small size preference in Vector 2022.
let sizeSetting = 0;
if (document.documentElement.matches(".vector-feature-custom-font-size-clientpref-1"))
sizeSetting = 1;
else if (document.documentElement.matches(".vector-feature-custom-font-size-clientpref-2"))
sizeSetting = 2;
let width = [320, 340, 360][sizeSetting];
let height = [210, 225, 240][sizeSetting];
let triangleSize = [9, 10, 11][sizeSetting];
popupContainer.style.fontSize = ["14px", "15px", "17px"][sizeSetting];
popupContainer.style.lineHeight = ["21px", "22px", "24px"][sizeSetting];
popupContainer.style.width = width + "px";
popupContainer.style.height = height + "px";
if (isPreviewLink) {
// Trigger fade-in-down animation.
popupContainer.classList.remove("popup-fade-in-up", "popup-fade-in-down");
void popupContainer.offsetLeft; // force reflow
popupContainer.classList.add("popup-fade-in-down");
} else {
openLink = link;
// Get list of rects (lines) of the target element, then find the one whose midpoint is closest to mouseY.
// This ensures that the code can correctly handle multi-line links.
let linkBlock = [...event.target.getClientRects()].reduce((prev, next) => Math.abs((next.top + next.bottom) / 2 - mouseY) < Math.abs((prev.top + prev.bottom) / 2 - mouseY) ? next : prev);
// Horizontal position. Choose left or right depending on the side of the screen the mouse is in.
let leftPosition = mouseX - 30;
if (mouseX > document.documentElement.clientWidth / 2)
leftPosition = mouseX - width + 30;
// Ensure that the popup is at least 5px away from the side of the screen.
leftPosition = Math.max(5, Math.min(leftPosition, document.documentElement.clientWidth - width - 5));
popupContainer.style.left = leftPosition + document.documentElement.scrollLeft + "px";
// Vertical position. Prioritize fade-in-down unless there would be less than 10px of room above.
if (linkBlock.top > height + 10 || linkBlock.top > document.documentElement.clientHeight - linkBlock.bottom) {
popupContainer.style.top = linkBlock.top + document.documentElement.scrollTop - height + "px";
popupContainer.classList.add("popup-fade-in-down");
popup.style.padding = `0 0 ${triangleSize}px`;
// Create a triangle on the bottom.
popup.style.clipPath = `polygon(0 0, 100% 0, 100% calc(100% - ${triangleSize}px), ${mouseX - leftPosition + triangleSize}px calc(100% - ${triangleSize}px), ${mouseX - leftPosition}px 100%, ${mouseX - leftPosition - triangleSize}px calc(100% - ${triangleSize}px), 0 calc(100% - ${triangleSize}px))`;
} else {
popupContainer.style.top = linkBlock.bottom + document.documentElement.scrollTop + "px";
popupContainer.classList.add("popup-fade-in-up");
popup.style.padding = `${triangleSize}px 0 0`;
// Create a triangle on top.
popup.style.clipPath = `polygon(0 ${triangleSize}px, ${mouseX - leftPosition - triangleSize}px ${triangleSize}px, ${mouseX - leftPosition}px 0, ${mouseX - leftPosition + triangleSize}px ${triangleSize}px, 100% ${triangleSize}px, 100% 100%, 0 100%)`;
}
}
responsePromise.then(response => {
if (!response) return; // if the fetch was aborted
popupContent.innerHTML = "";
let responseDocument = new DOMParser().parseFromString(response, "text/html");
// Convert to absolute URLs.
responseDocument.querySelectorAll("a[href]").forEach(link => link.setAttribute("href", link.href));
let anchoredElement = responseDocument.getElementById(linkAnchor);
let popupHeader = document.createElement("div");
popupHeader.style = "font-size: 90%; color: var(--wikt-palette-deepblue, #2f445c)";
popupContent.append(popupHeader);
let iconContainer = document.createElement("span");
iconContainer.style = "float: right; margin-left: 10px; height: 20px; color: var(--wikt-palette-black, #202122)";
popupHeader.append(iconContainer);
let titleLink = document.createElement("a");
titleLink.href = link.href;
titleLink.title = link.title;
titleLink.className = "skin-invert-image preview-headerlink";
// Scrape entry content.
if (isWPlink) {
iconContainer.innerHTML = articleIcon;
titleLink.textContent = linkTitle.replaceAll("_", " ");
if (responseDocument.title)
titleLink.innerHTML = responseDocument.title; // sometimes gives HTML text
let WikipediaName = WP_LANGUAGES.get(API_domain.substr(8).split(".")[0]);
popupHeader.append(WikipediaName + " Wikipedia article for ", titleLink);
let articleContent = document.createElement("div");
articleContent.style.margin = "5px 0 0 10px";
let firstSection = responseDocument.querySelector("section");
if (firstSection && responseDocument.querySelector(`meta[property="mw:pageNamespace"][content="0"]`)) {
firstSection.querySelectorAll("b").forEach(boldElem => boldElem.outerHTML = boldElem.innerHTML);
firstSection.querySelectorAll(":scope > p, :scope > ul, :scope > ol").forEach(elem => articleContent.append(elem));
}
if (articleContent.childElementCount)
popupContent.append(articleContent);
} else if (linkTitle === "Appendix:Glossary") {
iconContainer.innerHTML = glossaryIcon;
titleLink.textContent = linkAnchor.replaceAll("_", " ");
popupHeader.append("Glossary definition of ", titleLink);
if (anchoredElement && anchoredElement.matches(".template-anchor")) {
let glossaryDefinition = anchoredElement.parentElement.nextElementSibling;
if (glossaryDefinition && glossaryDefinition.matches("dd")) {
glossaryDefinition.style = "margin: 5px 0 0 15px";
popupContent.append(glossaryDefinition);
}
}
} else if (linkTitle.startsWith("Appendix:Bibliography/")) {
iconContainer.innerHTML = bibliographyIcon;
let language = linkTitle.slice(22).replaceAll("_", " "); // trim "Appendix:Bibliography/" prefix
popupHeader.append(`${language} bibliography`);
if (anchoredElement && anchoredElement.matches(".senseid")) {
let bibliographyCitation = document.createElement("div");
bibliographyCitation.style = "margin: 5px 0 0 15px";
bibliographyCitation.innerHTML = anchoredElement.innerHTML;
popupContent.append(bibliographyCitation);
}
} else {
const hasDefinitions = elem => Boolean(elem.querySelector("ol:not(.references), .ja-see, .zh-see"));
iconContainer.innerHTML = definitionIcon;
// Try to resolve the anchor element to #Chinese.
if (!anchoredElement && ["Cantonese", "Gan", "Hakka", "Hokkien", "Literary_Chinese", "Mandarin", "Middle_Chinese", "Old_Chinese", "Wu", "Xiang"].includes(linkAnchor))
anchoredElement = responseDocument.querySelector("#Chinese");
// Try to guess the anchor target in the following order: English, Chinese, Translingual, [first h2 on page]
// Always prioritize an L2 section which contains definitions.
if (!linkAnchor) {
let pageH2s = [...responseDocument.querySelectorAll("h2")];
if (pageH2s.some(h2 => hasDefinitions(h2.parentElement)))
pageH2s = pageH2s.filter(h2 => hasDefinitions(h2.parentElement));
anchoredElement = pageH2s.find(h2 => h2.id === "English");
if (!anchoredElement) anchoredElement = pageH2s.find(h2 => h2.id === "Chinese");
if (!anchoredElement) anchoredElement = pageH2s.find(h2 => h2.id === "Translingual");
if (!anchoredElement) anchoredElement = pageH2s[0];
}
let displayTitle = document.createElement("strong");
displayTitle.textContent = linkTitle.split("/").pop().replaceAll("_", " ");
if (linkTitle.startsWith("Reconstruction:"))
displayTitle.textContent = "*" + displayTitle.textContent;
// Find localest section containing an h2.
let languageSection = anchoredElement;
while (languageSection && !languageSection.querySelector(":scope > h2"))
languageSection = languageSection.parentElement.closest("section");
// Make sure that the entry is well-formed.
if (languageSection) {
let language = languageSection.querySelector(":scope > h2").textContent;
let scrapeSection = anchoredElement.closest("section");
// Find localest section which contains any definitions.
while (scrapeSection && !hasDefinitions(scrapeSection))
scrapeSection = scrapeSection.parentElement.closest("section");
if (scrapeSection) {
let headwords = [...scrapeSection.querySelectorAll(".headword-line > strong")];
if (new Set(headwords.map(h => h.textContent)).size === 1) {
// If there is a single unique headword, replace the display title with that.
if (headwords[0].querySelector("a > img"))
displayTitle = headwords[0].querySelector("a > img").cloneNode();
else
displayTitle = headwords[0];
} else if (new Set(headwords.map(h => h.cloneNode().outerHTML)).size === 1) {
// If there is a single unique set of element attributes, use that with the display title.
let temp = displayTitle.innerHTML;
displayTitle = headwords[0].cloneNode(); // this clears out the inner HTML
displayTitle.innerHTML = temp;
}
// Remove existing links in the headword.
displayTitle.querySelectorAll("a").forEach(elem => elem.replaceWith(elem.textContent));
let ols = scrapeSection.querySelectorAll(":scope > ol:not(.references), section > ol:not(.references)");
if (anchoredElement.matches(".senseid")) {
[...anchoredElement.parentElement.childNodes].forEach(child => {
if (child !== anchoredElement) child.remove();
});
ols = [anchoredElement.closest("ol")];
}
for (let ol of ols) {
let POS_container = document.createElement("div");
POS_container.style.margin = "8px 0 5px 0";
let POS = document.createElement("span");
POS.style = "font-size: 110%; font-weight: bold";
POS.textContent = ol.closest("section").firstChild.textContent;
POS_container.append(POS);
let tlb = ol.closest("section").querySelector(".headword-line ~ .usage-label-term");
if (tlb)
POS_container.append(document.createElement("br"), tlb);
popupContent.append(POS_container, ol);
}
// {{ja-see}} and {{zh-see}} don't follow the normal format...
for (let seeTemplate of scrapeSection.querySelectorAll(".ja-see, .zh-see"))
popupContent.append(seeTemplate);
}
titleLink.append(displayTitle);
popupHeader.append("Preview definitions of " + language + " ", titleLink);
} else {
titleLink.append(displayTitle);
popupHeader.append("Preview definitions of ", titleLink);
}
}
// Post-fetch error handling.
if (popupContent.childElementCount > 1) {
// Clean up HTML.
popupContent.querySelectorAll("link, .previewonly, .maintenance-line, .mw-empty-elt, .reference, .Inline-Template, .vsHide").forEach(elem => elem.remove());
if (!isWPlink)
popupContent.querySelectorAll("li > ul").forEach(elem => elem.remove()); // remove quotations
for (let elem of popupContent.querySelectorAll("*"))
elem.removeAttribute("id"); // avoid inadvertently repeating IDs within a page
} else if (isWPlink) {
// Display a message if the Wikipedia article was invalid or not in mainspace.
let noArticle = document.createElement("div");
noArticle.style = "margin: 5px 0 0 15px; font-size: 90%";
noArticle.textContent = "(article content could not be previewed)";
popupContent.append(noArticle);
} else if (linkAnchor && !anchoredElement) {
// Display a message if the anchor is invalid.
let noSectionFound = document.createElement("div");
noSectionFound.style = "margin: 10px 0 0 7.5px; font-size: 90%";
let strong = document.createElement("strong");
strong.textContent = linkAnchor.replaceAll("_", " ");
noSectionFound.append("The ", strong, " section was not found on this page.");
popupContent.append(noSectionFound);
} else {
// Display a message if no definitions were found in the section.
let noDefinitionsFound = document.createElement("div");
noDefinitionsFound.style = "margin: 5px 0 0 15px; font-size: 90%";
noDefinitionsFound.textContent = "(no definitions found)";
popupContent.append(noDefinitionsFound);
}
// Reduce the padding if a scrollbar is present. The intended padding is 16px on each side.
if (width - popupHeader.clientWidth > 32)
popupContent.style.paddingRight = Math.max(4, 48 + popupHeader.clientWidth - width) + "px";
});
// (Hack?) make sure that `link pointerleave` doesn't cause the popup to immediately close.
setTimeout(() => clearTimeout(popupTimer), 0);
}, isPreviewLink ? 1200 : 400);
});
link.addEventListener("pointerout", () => {
clearTimeout(popupTimer);
if (link === openLink) {
popupTimer = setTimeout(closePopup, 300);
} else {
API_controller.abort();
API_controller = new AbortController();
}
});
link.addEventListener("pointermove", event => [mouseX, mouseY] = [event.clientX, event.clientY]);
link.addEventListener("click", () => clearTimeout(popupTimer));
}
// Process all links.
document.querySelectorAll("a").forEach(processLink);
// Process links which are added to the DOM after the gadget has run.
(new MutationObserver(events => events.flatMap(event => [...event.addedNodes]).forEach(node => {
if (node instanceof HTMLAnchorElement)
processLink(node);
if (node instanceof HTMLElement)
node.querySelectorAll("a").forEach(processLink);
}))).observe(document.body, {childList: true, subtree: true});
// Dispatch hover events to support [[w:MediaWiki:Gadget-ReferenceTooltips.js]].
const linkEvent = ev => openLink && openLink.dispatchEvent(new Event(ev, {bubbles: true, cancelable: true}));
// Note: for some reason an event listener on `popup` doesn't catch everything...
popupContainer.addEventListener("pointerenter", () => setTimeout(() => linkEvent("mouseover")));
popupContainer.addEventListener("pointerleave", () => linkEvent("mouseout"));
// Custom events
popupContainer.addEventListener("pointerenter", () => linkEvent("linkPopupHover"));
popupContainer.addEventListener("pointerleave", () => linkEvent("linkPopupUnhover"));
// </nowiki>