Jump to content
Wikipedia The Free Encyclopedia

Wikipedia:WikiProject User scripts/Scripts/Page exists

From Wikipedia, the free encyclopedia
 /*
  * Returns a boolean: whether or not the page with the specified title exists or not.
  *
  * Keywords for search: check page existence, page is missing.
  *
  * Reference documentation:
  * - for JS class Api: https://doc.wikimedia.org/mediawiki-core/REL1_41/js/#!/api/mw.Api
  * - for action=query requests:
  * - https://www.mediawiki.org/wiki/API:Query
  * - https://en.wikipedia.org/w/api.php?action=help&modules=query
  */
 asyncfunctionpageExists(title){
 constapi=newmw.Api();
 constresponse=awaitapi.get({
 "action":"query",
 "format":"json",
 "titles":title
 });
 constmissing="missing"inObject.values(response.query.pages)[0];
 return!missing;
 }

AltStyle によって変換されたページ (->オリジナル) /