User:Ohconfucius/script/Sources.js: Difference between revisions

Content deleted Content added
+ Ohc_unpipe2();
line spacing
 
(114 intermediate revisions by 4 users not shown)
Line 1:
// <nowiki>
// *********************************************************************************************
 
// USERS ARE REMINDED TO :
// PLEASE EXERCISE DUE CARE!!
// read and understand the script documentation at User:Ohconfucius/script/Sources (link above) prior to using.
// this script has been recently re-imagined and although it has been tested on a hundred (or more) articles, it may still contain bugs.
// leave any questions on my talk page. Note that there is a separate page for bug reports.
//
// You are advised to read and understand the script documentation at User:Ohconfucius/script/Sources (link above) prior to using.
// Please leave any questions on my talk page. Note that there is a separate page for bug reports.
 
// *********************************************************************************************
if (typeof importScriptURI !== 'undefined') { // not available on mobile.
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Pathoschild/Scripts/Regex_menu_framework.js&action=raw&ctype=text/javascript');
importScript("User:Ohconfucius/script/MOSNUM_utils.js"); //needed for "'Accessed' ->
 
importScript("User:Ohconfucius/test/Sources_subscript1.js"); //convert ___domain names into article names
/*************
importScript("User:Ohconfucius/test/Sources_subscript2.js"); //Correctly casing titles and apply or rem italicisation
*** Regex menu framework
importScript("User:Ohconfucius/test/Sources_subscript3.js"); //link-fixing, dabbing etc
*** by [[m:user:Pathoschild]] <http://meta.wikimedia.org/wiki/User:Pathoschild/Scripts/Regex_menu_framework>
// importScript("User:Ohconfucius/script/foreigndates.js"); //link-fixing, dabbing etc
*** - adds a sidebar menu of user-defined scripts.
}
*************/
importScriptURI('http://meta.wikimedia.org/w/index.php?title=User:Pathoschild/Scripts/Regex_menu_framework.js&action=raw&ctype=text/javascript');
importScript("User:Ohconfucius/script/MOSNUM_utils.js"); //needed for "'Accessed' -> 'Retrieved'"
 
function Ohc_add_ref_tags() {
importScript("User:Ohconfucius/test/Sources_subscript1.js");
importScript("User:Ohconfucius/test/Sources_subscript2.js");
importScript("User:Ohconfucius/test/Sources_subscript3.js");
function Ohc_linkspam() {
var txt=document.editform.wpTextbox1;
txt.value=txt.value.replaceregex(/([^>\*\s][ ]?)\s?(\[https?:\/\/[^\s\]]*[ ]([\w\d][^\]]*)\])(?![ ]*[\n<\-]+)/gi, '$1<ref>$2</ref>');
 
}
 
function Ohc_fill_pub_with_domain() {
var txt=document.editform.wpTextbox1;
//test
regex(/\s?(<ref>(?:[^<>]*\|\s*url\s*=|\[?)https?:\/\/((?:\w+\.)*\w+(?:\.(?:com?|org|net|gov|ac|)(?:\.[a-z]{2}|)))\/[^<>{}]+\|publisher=)(?=}}<\/ref>)/gi, "$1$2"); //capture ___domain name to add to publisher
regex(/(\|\s*(?:publisher|website)\s*\=\s*)w{3}\.(\w+\.(?:com?|org|net|gov|ac|)(?:\.[a-z]{2}|))(?=\s*[|}])/gi, '$1$2');
regex(/(\|\s*publisher=)\s?\|\s?via\s*\=\s*(\w+)(?=\s*[|}])/gi, '$1$2');
// regex(/\|\s?via\s*\=\s*/gi, '|work=');
regex(/\s?[-–]\s?(?:The |)(\w+\.(?:com?|org|net|gov|ac|)(?:\.[a-z]{2}|))\s?(\|\s*publisher\s*\=\s*)\1(?=}})/gi, '$2$1');
regex(/\s?[-–]\s?([^|]+)\s?(\|\s*publisher\s*\=\s*)(The )\1(?=}})/gi, '$2$3$1');
regex(/\|\s?first\s*\=[^|]*\|\s?last\s*\=(?:Editor|Group|Staff|Reporter|Writer)\s*(?=\|)/gi, '');
regex(/({{Navbox deaths}})(\n)/gi, '==References==$2{{Reflist}}$2$1$2');
regex(/(==References==\n{{Reflist}}\n)\n?\1/gi, '$1');
 
}
 
function Ohc_remove_urls() {
var txt=document.editform.wpTextbox1;
// warning-tagging template:Primary source inline
regex(/(<ref[^<>]*>[^<>]*\|[ ]*url ?= ?https?:\/\/(?:(?:www\.|mobile\.|)(?:blogger|blogspot|facebook|sites\.google|instagram|tiktok|twitter|wordpress|x)\.com|www\.formspring\.me)\/[^<>{]*<\/ref>)(?:\{\{Primary source inline\}\}|)/gi, '$1{{Primary source inline}}');
regex(/(<ref[^<>]*>[^<>]*\|[ ]*url ?= ?https?:\/\/(?:(?:www\.|)(?:myspace|findagrave)\.com)\/[^<>{]*<\/ref>)(?:\{\{Primary source inline\}\}|)/gi, '$1{{Primary source inline}}');
regex(/(<ref>\s*https?:\/\/(?:(?:www\.|)(?:blogger|blogspot|facebook|sites\.google|findagrave|instagram|myspace|tiktok|twitter|wordpress|x)\.com)\/[^\s\]<]*<\/ref>)(?:\{\{Primary source inline\}\}|)/gi, '$1{{Primary source inline}}');
regex(/(<ref>\s*\[https?:\/\/(?:(?:www\.|)(?:blogger|blogspot|facebook|sites\.google|findagrave|instagram|myspace|tiktok|twitter|wordpress|x)\.com)\/[^\s\]]*[ ]+[\w\d][^\]]*\]<\/ref>)(?:\{\{Primary source inline\}\}|)/gi, '$1{{Primary source inline}}');
 
// removing http links within publisher/journal/work fields
//
// regex(/(\|\s*(?:author|publisher|work) *= *)(?:https?:\/{2}|)(?:w{3}\.|)(\w+(?:\.(?:com?|net|org|gov|\w{2})|)(?:\.\w{2}|))(?:\/[^|}]*|)(?=\s*[\]|}])/gi, '$1$2'); //returns ___domain name
regex(/(\|\s*title\s*\=)\s*https?:\/{2}(?:w{3}\.|)\w+\.com(?=\s?(?:[=|{]|\}\}))/gi, '$1 ');
regex(/(\|\s*title\s*\=)\s*https?:\/{2}[^|\s]+(?=\s?(?:[=|{]|\}\}))/gi, '$1 ');
// regex(/(\|\s*title\s*\=)\s*Archived copy(?=\s?(?:[=|{]|\}\}))/gi, '$1 '); rem as creating CS1 errors
regex(/\s?<!--ACTUAL ARTICLE TITLE BELONGS HERE!(?: original text:|)[^>]*-->/gi, ' '); //rem error introduced by earlier version of this script; entirely strip title field
regex(/(\|\s*(?:author(?:link\d?|)|chapter|journal|magazine|newspaper|publisher|title|work|via)\s*\=\s*)https?:\/{2}(?:w{3}\.|)(?=\w)/gi, '$1'); //removes http:// and optionally www.
regex(/(\|\s*(?:author(?:link\d?|)|chapter|journal|magazine|newspaper|publisher|title|work|via)\s*\=\s*)(?:w{3}\.)(?=\w)/gi, '$1'); //removes www.
regex(/(\|\s*(?:author(?:link\d?|)|chapter|journal|magazine|newspaper|publisher|title|work|via)\s*\=\s*)(\w+(?:\.(?:com?|net|org|gov|\w{2}))(?:\.\w{2}|))(?:\/[^|}]*|)(?=\s*[\]|}])/gi, '$1$2'); //returns ___domain name
regex(/(>{{cit[^}]+\|\s?website\s*\=\s*)https?:\/{2}(?:w{3}\.|)(?=\w)/gi, '$1'); //leave only ___domain name
regex(/(>{{cit[^}]+\|\s?website\s*\=\s*)(?:w{3}\.)(?=\w)/gi, '$1'); //leave only ___domain name
 
// removing hyperlinks within publisher/journal/website/work fields
regex(/(\|\s*(?:chapter|journal|magazine|newspaper|publisher|title|work|via)\s*\=\s*)\[https?:\/\/[^\s\]]*\s([\w][^\]]*)\]/gi, '$1$2'); //leave only linked text
regex(/({{cit[^}]+\|\s?website\s*\=\s*)\[https?:\/\/[^\s\]]*\s([\w][^\]]*)\]/gi, '$1$2'); //citation templates: rem url whilst leaving only linked text within |website=
 
regex(/(\|\s*title\s*=\s*)(?:\w+(?:\.(?:com?|net|org|gov|\w{2}))(?:\.\w{2}|))(?:\/[^|}]+)(?:\/[^|}]+)(?:\/[^|}]+)(?:\/[^|}]+)\/([^|}]+)\/?(?=\s*[\]|}])/gi, '$1$2'); //returns terminal part of url
regex(/(\|\s*title\s*=\s*)(?:\w+(?:\.(?:com?|net|org|gov|\w{2}))(?:\.\w{2}|))(?:\/[^|}]+)(?:\/[^|}]+)(?:\/[^|}]+)\/([^|}]+)\/?(?=\s*[\]|}])/gi, '$1$2'); //returns terminal part of url
regex(/(\|\s*title\s*=\s*)(?:\w+(?:\.(?:com?|net|org|gov|\w{2}))(?:\.\w{2}|))(?:\/[^|}]+)(?:\/[^|}]+)\/([^|}]+)\/?(?=\s*[\]|}])/gi, '$1$2'); //returns terminal part of url
regex(/(\|\s*title\s*=\s*)(?:\w+(?:\.(?:com?|net|org|gov|\w{2}))(?:\.\w{2}|))(?:\/[^|}]+)\/([^|}]+)\/?(?=\s*[\]|}])/gi, '$1$2'); //returns terminal part of url
regex(/(\|\s*title\s*=\s*)(?:\w+(?:\.(?:com?|net|org|gov|\w{2}))(?:\.\w{2}|))\/([^|}]+)\/?(?=\s*[\]|}])/gi, '$1$2'); //returns terminal part of url
regex(/(\|\s*author(?:link\d?|)\s*\=\s*)\[https?:\/\/[^\s\]]*\s([\w][^\]]*)\]/gi, '$1$2');
regex(/(\|\s*author(?:link\d?|)\s*\=\s*)(?:https?:\/\/|)www\.[\w][^|}]*(?=[|}])/gi, '$1'); //rem outright (not a WL)
 
// removing references to other WP articles and 'external' WP links
regex(/<ref[^<>]*>[^<>]*\|[ ]*url ?= ?https?:\/\/\w{2}\.wikipedia\.org\/w[^<>]*<\/ref>/gi, '{{cn}}<!-- WP:RS needed; removed link to WP-->');
regex(/<ref>\s*https?:\/\/\w{2}\.wikipedia\.org\/wiki\/[^\s\]<]*<\/ref>/gi, '{{cn}}<!-- WP:RS needed; removed link to WP-->');
regex(/<ref>\s*\[https?:\/\/\w{2}\.wikipedia\.org\/w[^\s\]]*[ ]+[\w\d][^\]]*\]<\/ref>/gi, '{{cn}}<!-- WP:RS needed; removed link to WP-->');
regex(/<ref(?: name=[^<>]|)>[^<>]*\|\s*url[ ]*=[ ]*https?:\/\/\w{2}\.wikipedia\.org\/w[^\s\|\{\}<]*[^<>]*<\/ref>/gi, '{{cn}}<!-- WP:RS needed; removed link to WP-->');
regex(/\[https?:\/\/\w{2}\.wikipedia\.org\/w[^\s\]]*[ ]+([\w][^\]]*)\]/gi, ' [[$1]]');
 
//deprecated sources
regex(/<ref[^<>]*>[^<>]*\|[ ]*url ?= ?https?:\/\/(?:(?:\w+\.|)((?:the|)epochtimes|ntdtv)\.com)\/[^<>{]*<\/ref>/gi, '<!--rem deprecated source \($1\)-->');
regex(/<ref[^<>]*>[^<>]*\|[ ]*url ?= ?https?:\/\/(?:(?:\w+\.|)(thesun|dailymail)\.co\.uk)\/[^<>{]*<\/ref>/gi, '<!--rem deprecated source \($1\)-->');
 
regex(/(\|\s*url\s*\=\s*|\[)(https?:[^|{}#\s]+)(?:#[A-Za-z0-9\.]{12,13}|\?CMP=fb_gu)(?=[\s\[\]|{}<>])/gi, '$1$2'); //rem link tracking
regex(/(\|\s*url\s*\=\s*)(https?:[^|{}#\s]+\.html?)\?[^|}]{1,5}(?=[\s\[\]|{}<>])/gi, '$1$2'); //rem link tracking
regex(/(\|\s*url\s*\=\s*|\[)(https?:\/\/books\.google\.[^\/]+\/books\?id=\w{12}&pg=PA\d{1,3})&dq[^\s|}]+(?=\s?[|}])/gi, '$1$2'); //rem browser optimisation
 
}
 
function Ohc_sources_prep() {
var txt=document.editform.wpTextbox1;
 
// removing referencesartefacts towithin other WP articlesfields
regex(/(\|\s*author\s*\=\s*)(?:by |)(?:[^|]+staff|(?:staff |)(?:reporter|writer)s?|)[\s\n]*(?=[|}])/gi, '');
txt.value=txt.value.replace(/<ref>https?:\/\/en\.wikipedia\.org\/wiki\/[^\s\]<]*<\/ref>/gi, '');
regex(/(\|\s*author\s*\=\s*)([A-Z][a-z]*(?: [A-Z][a-z]*)*) (?:(?:wire |)staff|(?:staff |)(?:reporter|writer)s?)[\s\n]*(?=[|}])/gi, '$1$2');
txt.value=txt.value.replace(/<ref>\[https?:\/\/en\.wikipedia\.org\/wiki\/[^\s\]]*[ ][\w\d][^\]]*\]<\/ref>/gi, '');
regex(/\|[ ]*last=(Reporter|staff)[ ]*\|[ ]*first=[^|\{\}]*(?=[\|{}])/gi, '');
regex(/\|[ ]*(?:first|last)=(?:staff |)(?:reporter|writer)[ ]*(?=[\|{}])/gi, '');
regex(/\|[ ]*first= ?staff ?\|[ ]*last=(?:reporter|writer)[ ]*(?=[\|{}])/gi, '');
regex(/\|[ ]*first= ?The ?\|[ ]*last=[^\|{}]*(?=[\|{}])/gi, '');
regex(/(\|\s*access-?date\s*\=\s*)(?:accessed|retrieved)(?: by| on|):?[ ]*(\d)/gi, '$1$2');
regex(/(\|\s*access-?date\s*\=\s*\d{4}\s?)(?=[|}])/gi, '');
regex(/(\|\s*work\s*\=\s*)(?:article|interview|review) ?(?=[|}])/gi, '$1');
regex(/(\|\s*volume\s*\=\s*)vol(?:ume|\.?)[ ]*(\d)/gi, '$1$2');
regex(/(\|\s*pages?\s*\=\s*)(?:pages?|p[gp]?\.?)[ ]*(\d)/gi, '$1$2');
regex(/ [-–] (?:每日明報 daily news|東方日報)/gi, '');
regex(/(\.\.\. |)\{\{!\}\} 立場(報道|新聞)/gi, '');
regex(/(\|\s*title\s*\=\s*)Login ?(?=[|}])/gi, '$1'); //creating deliberate error (blank title) per Trappist
 
regex(/(\|\s*)(?:publisher|website|work)=(Newspapers\.com|Twitter|Vimeo|Youtube)(?:\.com|)(?=\s*[|}])/gi, '$1via=$2');
// removing external links within publisher/journal/work fields
txt.value=txt.value.replace regex(/(\|\s?*)(?:newspaperpublisher|website|work|journal|publisher)\s*\=(Amazon)(?:\s*.com|)\[https(?:\/.\/[^w{2}|)(?=\s\]]*\s([\w\d|}][^\]]*)\]/gi, '$11via=$2');
txt.value=txt.value.replace regex(/(\|\s?author*)(?:link\d?publisher|website|work)\s*\=\s*)(\[https?:\/\/[^Twitter\s|𝕏\]\])(?: *\s(Formerly (?:Twitter|\[\w[Twitter\d][^\]]\)) *|)(?=\s*[|}])/gi, '$11via=$2');
txt.value=txt.value.replace regex(/(\|\s?(?:newspaper|work|journal|*publisher|author=)\|\s?via\s*\=\s*)www\.([\w\d][^\|\}]*+)(?=\s*[\|\}])/gi, '$1$2');
txt.value=txt.value.replaceregex(/(\|\s?author:-[ ]*Google Books[ ]*(?:link\d?|[^}]*|)|)\|\s?publisher\s*\=\s*(Google Books)www\.(?=[\ws\d][^\|\}.]*)(?=[\|\}])/gig, '|via=$1$2');
 
//Remove COinS corrupting templates from CS1 citations
txt.value=txt.value.replace(/(\|\s?author\s*\=\s*)(?:wire staff|staff reporters?|)[ ]*(?=[\|\}])/gi, '');
txt.value=txt.value.replaceregex(/(\|\s*(?author:authors?|first\d?|last\d?|publisher|work)\s*\=\s*)([A-Z][a-z]*(?: [A-Z][a-z^{}|]*|)*) {{(?:wire staffSm|(?:staffAut|SC|Small[- ]caps|)reportersSm?caps)\|([ ^{}|]*)}}(?=(?:[^{}|]*|)[\|\}])/gi, '$1$2');
// txt.value=txt.value.replace(/\{\{[ ]*cite /g, '{{Cite ');
 
regex(/(\|\s*)\w+\=(url\s*\=\s*https?:\/\/)(?=[|}])/gi, '$1$2'); //common cs1 error
txt.value=txt.value.replace(/\{\{wikinews(|2|cat|has|portal|table|-inline)(\|[^\}]+|)\}\}\s*/gi, '');
regex(/(\|\s*url\s*\=)(www\.)(?=[|}])/gi, '$1http//$2'); //common cs1 error
txt.value=txt.value.replace(/\*[ ]*\{\{Find a Grave\|\d{4}(\|[^\}]+|)\}\}\s*/gi, '');
regex(/(\|\s*date\s*=\s*)(?:not? |non-|un)date[ds]?\s*(?=[|}])/gi, '$1n.d.'); //common cs1 error
regex(/(\|\s*dead-?url=no?)(?=\s*[|}])/gi, '|url-status=dead'); //common cs1 error (deprecated parameter)
 
regex(/(\*[ ]*|)\[\[n:[^\]\|]*\]\][\r\n]*/gi, '');
 
//citation template fixes
// regex(/(\|\s*)published\s?=/gi, '$1publisher='); //disabled 12/5/21 – false positive in book infobox
// rem copyright assertion
regex(/(\|\s?*publisher\s*\=\s*)(?:\[\[copyright(?:\|©|)\]\])\s?/gi, '$1');
regex(/(\|\s?*publisher\s*\=\s*)(?:©|copyright)\s?/gi, '$1');
regex(/(\|\s*title\s*\=\s*[^|}]+?)[-‒–—―]\s+([^|}]+?)(\|\s*(?:publisher|work)\s*\=\s*\2)/gi, '$1$3');
regex(/(\|\s*title\s*\=\s*([^|}]+?))[-‒–—―]\s+([^|}]+?\|\s?(?:publisher|work)\s*\=\s*\2)/gi, '$1$3');
// misused 'date' parameter
regex(/(\{\{\s?cit[ae][^}]+)\|\s?date(\s?=\s?[12]\d{3}\s?[\|\}])/gi, '$1|year$12');
 
// rem toggles and redundant quote marks
txt.value=txt.value.replaceregex(/(\|\s?*(?:agency|author|newspaper|work|journal|publisher|title)\s*\=\s*)\'\'([^\|\}]+)\'\'(?=\s*[\}\|])/gi, '$1$2'); //without link
txt.value=txt.value.replaceregex(/(\|\s?*(?:agency|author|newspaper|work|journal|publisher|title)\s*\=\s*)\'\'(\[\[(?:[^\|]+\||)[^\|\]]+\]\])\'\'(?=\s*[\}\|])/gi, '$1$2'); //with link
regex(/(\|\s*title\s*\=\s*)\'&#39;([^\|\{\}]+)\'&#39;/gi, '$1$2'); //rem &#39; in titles
regex(/(\|\s*publisher\s*\=\s*)\(([^\|\{\}]+)\)/gi, '$1$2'); //rem parenthetical publishers
regex(/(\|\s*publisher\s*\=\s*)\"([^\|\{\}]+)\"/gi, '$1$2'); //rem quote marks around publishers
 
// reordering 'work' and 'publisher' (first run - see second run in cleanup function)
regex(/(\|\s*publisher\s*\=\s*(?:\[\[[^<{}\]]*\]\]|[^{}\|\}<>]*))(\s?\|[^}<>]*|)(\|\s*(?: journal|newspaper|magazine|periodical|website|work)\s*\=\s*(?:\[\[[^<{}\]]*\]\]|[^{}\|\}<>]*))(?=[\s\.]*[|}])/g, '$3$1$2');
regex(/(\|\s*website\s*\=\s*(?:\[\[[^<{}\]]*\]\]|[^{}\|\}<>]*))(\s?\|[^}<>]*|)(\|\s*(?: journal|newspaper|magazine|periodical|work)\s*\=\s*(?:\[\[[^<{}\]]*\]\]|[^{}\|\}<>]*))(?=[\s\.]*[|}])/g, '$3$1$2');
 
/// removing identical/similar entries in 'work' and 'publisher', and in 'work' and 'website' (different default vs [post] cleanup rules)
regex(/\|\s?work\s*\=\s*([^=|}\[<>]*)(\|[^}<>]*|)\|\s?(?:publisher|website)\s*\=\s*(?:\1|\[\[\1\]\])\.?(?=\s*[|}])/g, '|publisher=$1$2'); //unlinked work
regex(/\|\s?work\s*\=\s*\[\[([^<|\]]*)\]\](\|[^}<>]*|)\|\s?(?:publisher|website)\s*\=\s*(?:\1|\[\[\1\]\])\.?(?=\s*[|}])/g, '|publisher=$1$2'); //unpiped work
regex(/\|\s?work\s*\=\s*(\[\[(?:[^<|\]]*)\|([^}<>]*)\]\])(\|[^}<>]*|)\|\s?(?:publisher|website)\s*\=\s*(\1|\2)\.?(?=\s*[|}])/g, '|publisher=$1$3'); //piped work
 
regex(/\|\s?publisher\s*\=\s*([^=|}\[<>]*)(\|[^}<>]*|)\|\s?publisher\s*\=\s*(?:\1|\[\[\1\]\])\.?(?=\s*[|}])/g, '|publisher=$1$2'); //unlinked work
regex(/\|\s?publisher\s*\=\s*\[\[([^<|\]]*)\]\](\|[^}<>]*|)\|\s?publisher\s*\=\s*(?:\1|\[\[\1\]\])\.?(?=\s*[|}])/g, '|publisher=$1$2'); //unpiped work
regex(/\|\s?publisher\s*\=\s*(\[\[(?:[^<|\]]*)\|([^}<>]*)\]\])(\|[^}<>]*|)\|\s?publisher\s*\=\s*(\1|\2)\.?(?=\s*[|}])/g, '|publisher=$1$2'); //piped work
 
// remove redundant parentheses and templates from dm and md dates (equivalents also exists in Mosnum script)
regex(/(=[ ]*)\(([^()|{}])\)/gi, '$1$2');
 
// rem corporate designation
txt.value=txt.value.replaceregex(/(\|\s*(?:author|publisher|work)\s*\=\s*[^\[\|\}]{1,40}),? (?:Inc|LL[CP]|Ltd|Limited|PLC|SA|(?:Snd\. |)Berhad)\.?(?=[ ]*\|\})/gi, '$1');
 
txt.value=txt.value.replace(/(\|\s?publisher\s*\=\s*[^\[\|\}]{1,40}) (?:Inc|LL[CP]|Ltd|PLC|SA)\.?(?=[ ]*\|\})/gi, '$1');
// correcting yahoo! corporate designation
regex(/(\|\s*(?:publisher|work)\s*\=\s*Yahoo)(?: |)(Finance|Green|Kids|Music|News|)(?=[ ]*\|\})/gi, '$1! $2');
 
// rem unnecessary quote marks
txt.value=txt.value.replaceregex(/(\|\s?*title\s*\=\s*)["“]([^\|]+)["”](?=\s?[\|\}])/gi, '$1$2');
txt.value=txt.value.replaceregex(/(\|\s?*title\s*\=\s*)['‘]([^\|'’]+)['’](?=\s?[\|\}])/gi, '$1$2');
// repl double 'in-title' quote marks with single quotes
txt.value=txt.value.replaceregex(/(\|\s?*title\s*\=\s*[\w ]* )["“]((?:\w[\w]* )+(?:\w[\w]*))["”]([^\|]+|)(?=\s?[\|\}])/gi, '$1\'$2\'$3');
 
// adjust for possibly incorrectly input title
regex(/(\|\s*title\s*\=\s*)([^\|\}<>]*)(\s?\|[^}<>]*|)\|\s?(publisher|work)\s*\=\s*(?:\1|\[\[\1\]\])(?=\s*[|}])/g, '$1 |$4=$2$3'); //creating deliberate error (blank title) per Trappist
// rem misplaced punctuation
txt.value=txt.value.replace regex(/(<ref[^>]*>[^<]+?[\]\.\},;–]\s*\'\'[\w-]*(?: [\w-]*){0,3})(\.com|)([;,\.])(\'\')(?=[^<]*?<\/ref>)/gi, '$1$2$4$3$5');
regex(/([\w]+)\.(['"]\])[ ]/gi, '$1$2. '); //LQ for titles
// removing blank parameters
 
regex(/(?:\|[ ]*(?:accessdate|agency|archive(?:date|url)|arxiv|asin|at|author(-link|-mask|-name-separator|-separator|\d|\d-link|link\d?|)|bibcode|chapter|chapter-url|coauthors|contribution(?:-url|)|date|deadurl|display-authors|doi|doi-inactive|doibroken|edition|editor(?:-first|-last|-link|\d|\d-first|\d-last|\d-link|)|(?:first|last)\d?|format|id|is[bs]n|issue|jfm|journal|jstor|language|lay(?:date|source|summary)|lccn|___location|magazine|month|mr|newspaper|nopp|oclc|ol|origyear|osti|others|pages?|periodical|place|pm[cd]|pmid|postscript|publication(?:-date|-place)|publisher|quote|ref|rfc|separator|series|ssrn|trans_title|type|url|volume|work|year|zbl)[ ]*=[\s]*)(?=[\}\|])/gi, '');
// removing blank or redundant parameters
regex(/(?:\|[ ]*(?:agency|arxiv|asin|at|author(-?link|-mask|-name-separator|-separator|\d|\d-link|link\d?|)|bibcode|chapter|chapter-url|coauthors?|contribution(?:-url|)|date|deadurl|display-authors|doi|doi-inactive|doibroken|edition|(?:editor|translator)(?:-first|-last|-link|\d|\d-first|\d-last|\d-link)|(?:first|last)\d?|format|id|is[bs]n|issue|jfm|journal|jstor|language|lay(?:date|source|summary)|lccn|___location|magazine|day|month|mr|newspaper|nopp|oclc|ol|origyear|osti|others|pages?|periodical|place|pm[cd]|pmid|postscript|publisher|quote|ref|rfc|separator|series|ssrn|trans_title|type|url|volume|via|work|year|zbl)[ ]*=[\s]*)(?=[}|])/gi, '');
// regex(/(?:\|[ ]*(began|ended)[ ]*=[^}|]*)(?=[}|])/gi, ''); //disabled 18/06/20: false positive removal of associated (Start date) templates
regex(/(\|\s*work\s?\=\s?)\[\[iTunes\]\] Archive\s/gi, '|publisher=[[iTunes]]');
 
//rem underlining within certain fields
txt.value=txt.value.replaceregex(/(\|\s?*(?:journal|newspaper|periodical|publisher|work)\s*\=\s*)<u>([^\|\}]*+)<\/u>/gi, '$1$2');
 
//rem redundant top-level domains (.com, .net, .org), strip "www"
//rem linking within locations field
regex(/(\|[ ]\s*(?___location:journal|newspaper|periodical|publisher|work)\s*\=[ ]\s*?)(\[\[([^\|[\]\}]+?)*\]\])\.(?:(,? )biz|com|net|org|co\[\[.uk|([^\|\]]+?):com\]\].|)([ a-z]{0,12})(?=\s*[|}])/gi, '$1$2$3$4$5');
regex(/(\|[ ]*?___location=[ ]*?)\[\[(?:[^\|\]]+?\|)([\w\s\,]+?)\]\](?:(,? )\[\[([^\|\]]+?)\]\]|)([ ]{0,1})/gi, '$1$2$3$4$5');
regex(/\[\[(New York)\]\]/gi, '$1');
 
//rem duplicated publishers in separate fields (pre)
// eliminating time of day
ohc_regex regex(/(\|?:[ ‒–—―]+|&#124;)\s*author[(?:The ]*=|)([ ^\|\}&]*{3,})(?:posted\.com|published)\s*(\|\s*(?: byagency| onpublisher|work)[\s:]*\=\s*)\1(?=\ws*[|}])/gi, "'$2$1"');
regex(/(\|?:[ ‒–—―]*(?:date+|archivedate|accessdate|author&#124;)[ ]\s*=([ ^\|\}&]*{3,})[0-2](?\d:[0-5]\d(?:[ ].com|&nbsp;)\s*(\|\s*(?:[ap]m ?agency|[ap]publisher|work)\.ms*\.=\s*)(The |[A-Z]{1,2}T|UTC)[\.,]1(?=\s*[ |}]?)/gi, "'$2$3$1"');
 
//'work' and its alias (pre)
regex(/(\|[ ]*?newspaper[ ]*=[^\|}]*(?:\|[^\{\}]*|))(?:\|[ ]*?work[ ]*=[^|}]*)(?=[|}])+/gi, '$1');
 
//rem linking within '___location' field
regex(/(\|[ ]*?(?:___location|place)=[ ]*?)\[\[ ?(Abkhazia|Afghanistan|Albania|Algeria|Andorra|Angola|Antigua and Barbuda|Argentina|Armenia|Australia|Austria|Azerbaijan|(?:The |)Bahamas|Bahrain|Bangladesh|Barbados|Belarus|Belgium|Belize|Benin|Bhutan|Bolivia|Bosnia and Herzegovina|Botswana|Brazil|Brunei|Bulgaria|Burkina Faso|Burma|Burundi|Cambodia|Cameroon|Canada|Cape Verde|Central African Republic|Chad|Chile|(?:(?:People's |)Republic of |)China|Colombia|Comoros|(?:Democratic |)Republic of (?:the |)Congo|Costa Rica|Côte d'Ivoire|Croatia|Cuba|Cyprus|Czech Republic|(?:Kingdom of |)Denmark|Djibouti|Dominica|Dominican Republic|East Timor|Ecuador|Egypt|El Salvador|Equatorial Guinea|Eritrea|Estonia|Ethiopia|Fiji|Finland|France|Gabon|Georgia \(country\)|Germany|Ghana|Greece|Greenland|Grenada|Guatemala|Guinea|Guinea-Bissau|Guyana|Haiti|Honduras|Hungary|Iceland|India|Indonesia|Iran|Iraq|(?:Republic of |)Ireland|Israel|Italy|Jamaica|Japan|Jordan|Kazakhstan|Kenya|Kiribati|North Korea|South Korea|Kosovo|Kuwait|Kyrgyzstan|Laos|Latvia|Lebanon|Lesotho|Liberia|Libya|Liechtenstein|Lithuania|Luxembourg|(?:Republic of |)Macedonia|Madagascar|Malawi|Malaysia|Maldives|Mali|Malta|Marshall Islands|Mauritania|Mauritius|Myanmar|M[ée]xico|(?:Federated States of |)Micronesia|Moldova|Monaco|Mongolia|Montenegro|Morocco|Mozambique|Nagorno-Karabakh|Namibia|Nauru|Nepal|(?:Kingdom of the |)Netherlands|Holland|New Zealand|Nicaragua|Niger|Nigeria|Northern Cyprus|Norway|Oman|Pakistan|Palau|Palestine|Panama|Papua New Guinea|Paraguay|Peru|Philippines|Poland|Portugal|Qatar|Romania|Russia|Rwanda|SADR|Saint Kitts and Nevis|Saint Lucia|Saint Vincent and the Grenadines|Samoa|San Marino|São Tomé and Príncipe|Saudi Arabia|Senegal|Serbia|Seychelles|Sierra Leone|Singapore|Slovakia|Slovenia|Solomon Islands|Somalia|Somaliland|South Africa|South Ossetia|Spain|Sri Lanka|Sudan|Suriname|Swaziland|Sweden|Switzerland|Syria|Taiwan|Tajikistan|Tanzania|Thailand|Timor Leste|(?:The |)Gambia|Togo|Tonga|Transnistria|Trinidad and Tobago|Tunisia|Turkey|Turkmenistan|Tuvalu|Uganda|Ukraine|United Arab Emirates|United Kingdom|United States|Uruguay|Uzbekistan|Vanuatu|Vatican City|Venezuela|Vietnam|Yemen|Zambia|Zimbabwe)[ ]?\|[ ]?(?:\w{2,3})\]\]/gi, '$1$2');
regex(/(\|[ ]*?(?:___location|place)=[ ]*?)\[\[(?:[^\|\]]+?\||)([\w\s\,]+?)\]\](?:(,? )\[\[(?:[^\|\]]+?\||)([\w\s\,]+?)\]\])(?:(,? )\[\[(?:[^\|\]]+?\||)([\w\s\,]+?)\]\]|)(?=[ ]?[|}])/gi, '$1$2$3$4$5$6');
regex(/(\|[ ]*?(?:___location|place)=[ ]*?)\[\[(?:[^\|\]]+?\||)([\w\s\,]+?)\]\](?:(,? )\[\[(?:[^\|\]]+?\||)([\w\s\,]+?)\]\]|)(?=[ ]?[|}])/gi, '$1$2$3$4');
 
// removing english language parameters
regex(/[ ]?\{\{en[- ]icon\}\}/gi, "");
// regex(/\|[ ]*?language[ ]*?=[ ]*?en(?:-\w{2}|glish|)(?=\s*[}|])/gi, "");
// regex(/(\|[ ]*?language[ ]*?=[ ]*?)\{\{(\w{2})(?:[- ](?:icon|UK|GB|US)|)\}\}/gi, ""); // removing icon template from within "|language=" parameter
 
// eliminating time of day
regex(/(\|[ ]*author[ ]*=[ ]*)(?:posted|published)(?: by| on|)[\s:](?=\s*\w)/gi, "$1");
regex(/(\|[ ]*(?:date|archive-?date|access-?date|author|first|last)[ ]*=[ ]*)[0-2]?\d:[0-5]\d(?:[ ]|&nbsp;)(?:[ap]m ?|[ap]\.m\. |[A-Z]{1,2}T|UTC)[\.,]?[ ]?/gi, "$1");
 
// eliminating days of the week
regex(/(\|[ ]*(?:date|archivedatearchive-?date|accessdateaccess-?date|author)[ ]*=[ ]*)(?:(?:Mon|Tues?|WednesWed|ThursThur?|Fri|SaturSat|Sun)day(?:[\.,]|day)?)\s/gi, "$1");
regex(/(\|[ ]*(?:date|archivedate|accessdate|author)[ ]*=[ ]*)(?:(?:Mon|Tues?|Wed|Thur?|Fri|Sat|Sun)[\.,]?)\s/gi, "$1");
 
//'Accessed'/'Obtained' -> 'Retrieved'
ohc_regex(/(?:[\.,;][ ]*(?:url |link |last |)(?:Retrieved|Accessed|Obtained))(?: on(?:line|)|):? (@month|@dd|@yyyy)(?=\D)/gi, '. Retrieved $1');
ohc_regex(/(\w|\])(?:[ ]*(?:url |link |last |)(?:Retrieved|Accessed|Obtained))(?: on(?:line|)|):? (@month|@dd|@yyyy)(?=\D)/gi, '$1. Retrieved $2');
 
// (disabling for persistent errors) ohc_regex(/(?:Retrieved|Accessed)(?: on(?:line|)|):? (@Month\s@DD,?\s@YYYY|@DD\s@Month\s@YYYY|@yyyy-@mm-@dd)(?=\D)/gi, 'Retrieved $1');
ohc_regex(/(\w|\])[\.,;]?[ ]\((Retrieved (?:@Month\s@DD,\s@YYYY|@DD\s@Month\s@YYYY|@yyyy-@mm-@dd))\)/gi, '$1. $2');
// ohc_regex(/\((Retrieved (?:@Month\s@DD,\s@YYYY|@DD\s@Month\s@YYYY|@yyyy-@mm-@dd))\)/gi, '$1');
 
}
Line 108 ⟶ 229:
// regex(/(\[\[)(?:foo|bar)(\|)/gi, '$1foo bar \(dab\)$2');
 
regex(/(\[\[)(?:(?:British|English|London) Sun|Sun on Sunday|The Scottish Sun|(?:The |)Sun (?:\((?:British |)newspaper\)|\(tabloid\)|\(UK newspaper\)|\(UK\)|Newspaper|on Sunday|Online)|Thesun\.co\.uk)(?=\|)/gi, '$1The Sun \(United Kingdom\)$2');
regex(/(\[\[)Daily Star \((?:British|UK)\)(?=\|)/gi, '$1Daily Star \(United Kingdom\)$2');
regex(/(\[\[Metro)(?:Calcutta Telegraph|The\(Associated TelegraphMetro Limited\((?:kolkatt?a|India)| \(Associated Newspapers\)| \(?:TheLondon newspaper\)| \(free London newspaper\)Telegraph| IndiaUK|Telegraphindia\.com newspaper London| newspaper UK)(?=\|)/gi, '$1The1 Telegraph \(Calcutta\British newspaper)$2');
regex(/(\[\[)Dawn(?:,Calcutta KarachiTelegraph|The newspaper|\.com|Telegraph \((?:NewspaperCalcutta|PakistanIndia)\)|(?:The |)Telegraph India|Telegraphindia\.com)(?=\|)/gi, '$1Dawn1The Telegraph \(newspaper\Kolkata)$2');
regex(/(\[\[The Pioneer)Dawn(?:, Karachi| newspaper|\.com| \((?:indian newspaperNewspaper|Pakistan)\))(?=\|)/gi, '$11Dawn \(Indian newspaper\)$2');
regex(/(\[\[The Pioneer)dailypioneer.com(?:, Karachi| newspaper| \((?:indian newspaper)\))(?=\|)/gi, '$1The1 Pioneer \(Indian newspaper\)$2');
regex(/(\[\[)dailypioneer.com(?=\|)/gi, '$1The Pioneer (Indian newspaper)');
regex(/(=[ ]*\[\[)(?:[BE]SPN ?(?:USA|HD|Network|the ocho|\(United States\))|E.S.P.N.|(?:The |)Entertainment (?:and |)Sports Programming Network)(?:\|[\w, ]*)(\]\])/gi, '$1ESPN$2');
regex(/(\|)(Sport \()(newspaper\))(?=\||\]\])/g, '$1$2Spanish $3'); //dab moved December 2012
regex(/(=[ ]*\[\[)(?:[BE]SPN ?(?:USA|HD|Network|the ocho|\(United States\))|E.S.P.N.|(?:The |)Entertainment (?:and |)Sports Programming Network)(?:\|[\w, ]*)(?=\]\])/gi, '$1ESPN');
regex(/(\[\[)Sky ?(?:\((?:British|UK)\)|UK|United Kingdom)(?=\|)/gi, '$1Sky (United Kingdom)');
 
regex(/(?:agency|journal|newspaper|periodical|publisher|website|work)(\s?=\s?\[\[)(?:MTV (?:[A-Z]\w*|\([^\)\]]*\)))\|[^\)\]]*(?=\]\])/gi, 'publisher$1MTV$2');
 
//unwinding of unnecessary pipes
regex(/(\[\[)Public Broadcasting Service\|(PBS\]\])/gi, '[[$1$2');
 
//unlinking of piped sources to source and ___location
// regex(/(?:author|agency|publisher)(\s?=\s?\[\[(Evening Standard))\|[\w,]*(\]\])/gi, 'work$1$2$3|___location=London');
 
// regex(/((?:journal|newspaper|periodical|work)\s?=\s?\[\[(Daily News) \(New York\)\|)(?:[\w, ]*)(\]\])/gi, '$1$2$3 |___location=New York');
// regex(/(?:author|agency|publisher)(\s?=\s?\[\[(Daily News) \(New York\)\|)(?:[\w, ]*)(\]\])/gi, 'work$1$2$3 |___location=New York');
// regex(/((?:journal|newspaper|periodical|work)\s?=\s?\[\[(The Sun|Daily Star) \((United Kingdom)\)\|)(?:[\w, ]*)(\]\])/gi, '$1$2$4 |___location=$3');
// regex(/(?:author|agency|publisher)(\s?=\s?\[\[(The Sun|Daily Star) \((United Kingdom)\)\|)(?:[\w, ]*)(\]\])/gi, 'work$1$2$4 |___location=$3');
// regex(/((?:journal|newspaper|periodical|work)\s?=\s?\[\[(The Telegraph) \(Calcutta\)\|)(?:[\w, ]*)(\]\])/gi, '$1$2$4 |___location=$3');
// regex(/((?:author|agency|publisher)\s*\=\s*\[\[(The Telegraph) \(Calcutta\)\|)(?:[\w, ]*)(\]\])/gi, 'work$1$2$4 |___location=$3');
 
}
Line 138 ⟶ 253:
//linked publishing houses
// removing publishers less well-known than their titles
regex(/(\|\s?work*publisher\s*?\=MTV\s*(?:Time|People)\s*(?:\|[^}<>]*|))\|\s?publisher\s*\=\s*Time(?:MTV Warner,Networks(?|,|): Inc.?\(?=[\s\.]*[Viacom\)|\}])|Viacom)/ggi, '$1=');
regex(/(\|\s?work\s*\=\s*(?:\[\[|)The New York Times(?:\]\]|)\s*)(\|[^}<>]*|)\|\s?publisher\s*\=\s*The New York Times Company(?=[\s\.]*[\|\}])/g, '$1');
regex(/(\|\s?work\s*\=\s*(?:\[\[|)The (?:Daily Telegraph|Guardian)(?:\]\]|)\s*(?:\|[^}<>]*|))\|\s?publisher\s*\=\s*(?:\[\[|)(?:Telegraph|Guardian) Media Group(?:\]\]|)(?=[\s\.]*[\|\}])/g, '$1');
regex(/(\|\s?publisher\s?\=MTV\|\s?)publisher\s*\=\s*(?:MTV Networks|Viacom)/gi, '$1=');
 
regex(/(?:\|publisher=Turner Sports Interactive, Inc)\.? ?\|publisher=(NBA)(?= ?\|)/gi, '$1');
regex(/(\|publisher=NBA) ?\|publisher=(?:Turner Sports Interactive, Inc)\.?(?= ?\|)/gi, '$1');
regex(/\[\[Jann? Wenner\|Wenner Media\]\](?= ?\|)/gi, '');
 
// removing publishers for periodicals
// txt.value=txt.value.replace regex(/(?:\|\s?(newspaper|work|publisher)\s*\=\s*\[?\[(?Hachette:PMC Filipacchi Médias\(company\)\||)(Hachette?:PMC|Penske Filipacchi)Media \(UK\Corporation) Ltd\]?\]?)(?=[\s\.]*[\|\}])/gi, '');
txt.value=txt.value.replace regex(/(?:\|\s?(newspaper|work|publisher)\s*\=\s*\[?\[?(John Fairfax (and?:Hachette SonsFilipacchi LtdMédias\.?|Holdings|)|FairfaxHachette Filipacchi(?: Media\( LimitedUK\)| DigitalLtd.?| newspapers)UK|)\]?\]?)(?=[\s\.]*[\|\}])/gi, '');
txt.value=txt.value.replace regex(/(?:\|\s?(newspaper|work|publisher)\s*\=\s*\[\[(ACP Magazines|The Herald and Weekly Times|John Fairfax (and Sons Ltd\.?|Holdings)|Fairfax(?: Media(?: Limited|)| Digital| newspapers|))\]\])(?=[\s\.]*[\|\}])/gi, '');
regex(/(?:\|\s?(newspaper|work|publisher)\s*\=\s*\[\[(ACP Magazines|The Herald and Weekly Times|John Fairfax (and Sons Ltd\.?|Holdings)|Fairfax(?: Media(?: Limited|)| Digital| newspapers))\]\])(?=[\s\.]*[|}])/gi, '');
txt.value=txt.value.replace(/(?:\|\s?publisher\s*\=\s*(Associated Newspapers|Cond[eé] Nast Publications|Daily Mail and General Trust|Gannett(?: Company|)|(Guardian|Telegraph) Media Group|(?:Guardian|Independent) News (?:and|&) Media|Hearst (?:Corporation|Magazines)|Imdb Inc\.?|IDG|IPC Media|MTV Networks|(The |)(?:Washington Post|(?:New York|Seattle) Times) Company|News (?:Corporation|International|Limited)|Prometheus Global Media|Rovi Corporation|Tribune Company|Trinity Mirror|Times Newspapers (?:Limited|Ltd.?)|Nielsen (?: Media Research|Business Media)|Viacom|Time (?:Warner ?|)))(,? Inc\.?| Ltd.?|)(?=[\s\.]*[\|\}])/gi, '');
regex(/\| ?publisher ?= ?(?:Fandango Media|\[\[Fandango Media\]\]) ?/gi, '');
txt.value=txt.value.replace(/(?:\|\s?publisher\s*\=\s*\[\[(Associated Newspapers|Cond[eé] Nast Publications|Daily Mail and General Trust|Gannett(?: Company|)|(Guardian|Telegraph) Media Group|(?:Guardian|Independent) News (?:and|&) Media|Hearst (?:Corporation|Magazines)|Imdb Inc\.?|IDG|IPC Media|MTV Networks|(The |)(?:Washington Post|(?:New York|Seattle) Times) Company|News (?:Corporation|International|Limited)|Prometheus Global Media|Rovi Corporation|Tribune Company|Trinity Mirror|Times Newspapers (?:Limited|Ltd.?)|Nielsen (?: Media Research|Business Media)|Viacom|Time (?:Warner ?|)))(,? Inc\.?| Ltd.?|)(?:\|[^\]\}]*|)\]\](?=[\s\.]*[\|\}])/gi, '');
regex(/(?:\|\s?publisher\s*\=\s*(Alexander Lebedev|American Media|Associated Newspapers|Bauer (?:Consumer Media|Media Group)|Cond[eé] Nast(?: Publications|)|Daily Mail and General Trust|Devin Laz[ae]rine|Dow Jones & Company|Future plc|(Guardian|Telegraph) Media Group|(?:Guardian|Independent) News (?:and|&) Media(?: Limited| Ltd\.|)|Hachette Filipacchi Médias|Hearst (?:Corporation|Magazines(?: UK|))|Herald Media|IGN Entertainment|Imdb Inc\.?|InterMedia Partners|IDG|IPC Media|Lee Enterprises|Media ?News Group|Mediacorp|Mortimer Zuckerman|MTV Networks|News (?:Corporation|International|Limited)|Postmedia Network Inc\.?|Prometheus Global Media|Reed Business Information|Rovi Corporation|Trinity Mirror|Times Newspapers|Nielsen (?: Media Research|Business Media)|Viacom|Time(?: Warner ?|)))(,? Inc| LL[CP]| Ltd|Limited|)[\s\.]*(?=[|}])/gi, '');
regex(/\|\s?publisher\s*\=\s*(?:The |)(?:Deseret News Publishing|Dispatch Printing|E\. W\. Scripps|Evening Post Publishing|Forbes(?: Publishing|, Inc\.)|Gannett?|Independent News & Media|Irish Times Trust|(?:Jann Wenner|Wenner Media)|Johnson Publishing|Journal Communications|Mac Publishing|Media24|McClatchy|Nash holdings LLC|New York Times|Seattle Times|Star Tribune|Thomp?son(?:[- ]?Reuters)?(?: Corporation| Plc.?|)|Singapore Press Holdings|Torstar|Time Inc\.|Times (?:Group|Publishing)|Tribune|Vox Media|Washington Post|World Publishing|Ziff Davis Media)(?: Co(?:mpany|\.)?)?(?=[\s\.]*[|}])/g, '');
regex(/\|\s?publisher\s*\=\s*(?:Cox|Halifax|North Jersey|Sun-Times|Tampa|Herald|Stephens|WEHCO) Media(?: Group(?:,? Inc\.)?| Berhad)?(?=[\s\.]*[|}])/g, '');
// regex(/\|\s?publisher\s*\=\s*(?:\w+ )+(?:Media|Publishing|Publications)(?: Group(?:,? Inc\.)?| Berhad)(?=[\s\.]*[|}])/g, ''); //rem "Communications" - false positive for "Ministry of Economic Affairs and Communications" reported 28 May 2014
//duplicate above with links //("Corporation" excluded - false positive with Australian Broadcasting Corporation)
regex(/(?:\|\s?publisher\s*\=\s*\[\[(Alexander Lebedev|American Media|Associated Newspapers|Bauer (?:Consumer Media|Media Group)|Cond[eé] Nast(?: Publications|)|Daily Mail and General Trust|Devin Laz[ae]rine|Dow Jones & Company|Future plc|(Guardian|Telegraph) Media Group|(?:Guardian|Independent) News (?:and|&) Media(?: Limited| Ltd\.|)|Hachette Filipacchi Médias|Hearst (?:Corporation|Magazines(?: UK|))|Herald Media|IGN Entertainment|Imdb Inc\.?|InterMedia Partners|IDG|IPC Media|Lee Enterprises|Media ?News Group|Mediacorp|Mortimer Zuckerman|MTV Networks|News (?:Corporation|International|Limited)|Postmedia Network Inc\.?|Prometheus Global Media|Reed Business Information|Rovi Corporation|Trinity Mirror|Times Newspapers|Nielsen (?: Media Research|Business Media)|Viacom|Time(?: Warner ?|)))(,? Inc| LL[CP]| Ltd|Limited|)(?:\|[^\]\}]*|)\]\][\s\.]*(?=[|}])/gi, '');
regex(/\|\s?publisher\s*\=\s*\[\[(?:The |)(?:Deseret News Publishing|Dispatch Printing|E\. W\. Scripps|Evening Post Publishing|Forbes(?: Publishing|, Inc\.)|Gannett?|Independent News & Media|Irish Times Trust|(?:Jann Wenner|Wenner Media)|Johnson Publishing|Journal Communications|Mac Publishing|McClatchy|Nash holdings LLC|New York Times|Seattle Times|Star Tribune|Thomp?son(?:[- ]?Reuters)?(?: Corporation| Plc.?|)|Singapore Press Holdings|Torstar|Time Inc\.|Times Publishing|Tribune|Vox Media|Washington Post|World Publishing|Ziff Davis Media)(?: Co(?:mpany|\.)?)?\]\](?=[\s\.]*[|}])/g, '');
regex(/\|\s?publisher\s*\=\s*\[\[(?:Cox|Halifax|North Jersey|Sun-Times|Tampa|Herald|Stephens|WEHCO) Media(?: Group(?:,? Inc\.)?| Berhad)?\]\](?=[\s\.]*[|}])/g, '');
// regex(/\|\s?publisher\s*\=\s*\[\[(?:\w+ )+(?:Media|Publishing|Publications)(?: Group(?:,? Inc\.)?| Berhad)\]\](?=[\s\.]*[|}])/g, '');
 
regex(/\| ?publisher ?= ?Star Publications \(Malaysia\)|\[\[Star Publications \(Malaysia\)\]\] ?/gi, '');
regex(/\| ?publisher ?= ?(?:New Straits Times Press|\[\[New Straits Times Press\]\]) ?/gi, '');
regex(/(\|\s*publisher\s?\=\s?MTV\s?)\|\s*\=\s*\(\w+\)/gi, '$1='); //palliative - correction for unsuppoeted parameters
 
}
Line 158 ⟶ 283:
var txt=document.editform.wpTextbox1;
 
// The following regexes for dab-links are in sets of four. If changing, please ensure all sets are changed )note (unique regex line for Empire film magazineadded 20/6/2021)
// relocating '___location' parameter outside citation templates
regex(/(=[ ]*(?:The ?|)[A-Z]\w*(?: [A-Z]\w*|)) \((South Africa)(?:n newspaper|)\)([ ]*[|}])/g, '$1|___location=$2$3');
//sources without dab but with inserted locator
regex(/(''Evening Standard) \|___location=(London)('')/gi, '$1$3 \($2\)');
regex(/(''\[\[Evening Standard\]\]) \|___location=(London) ?('')/gi, '$1$3 \($2\)');
regex(/(=\s*\[\[|\|)(Evening Standard)( \|___location=London)(\]\])/gi, '$1$2$4$3');
regex(/(\[\[|\|)(Evening Standard)( \|___location=London)(\]\])/gi, '$1$2$4 $3');
 
// displacing ___location-dab (in parentheses)
regex(/( \|___location=(?:New York|UK))(\]\])/gi, '$2$1');
 
// The following regexes for dab-links are in sets of four. If changing, please ensure all sets are changed
regex(/(=[ ]*(?:The ?|)[A-Z]\w*(?: [A-Z]\w*|)) \((South Africa)(?:n newspaper|)\)([ ]*[\|\}])/g, '$1|___location=$2$3');
regex(/(''(?:The ?|)[A-Z]\w*(?: [A-Z]\w*|)) \((South Africa)(?:n newspaper|)\)(''[\.,;])/g, '$1$3$2');
regex(/(\[\[((?:The ?|)[A-Z]\w*(?: [A-Z]\w*|)))( \(South Africa(?:n newspaper|)\))(\]\][\.,;]?)/g, '$1$3|$2$4');
regex(/(\|)((?:The ?|)[A-Z]\w*(?: [A-Z]\w*|))(?: \((?:South Africa)(?:n newspaper|)\))(\]\])/g, '$1$2$3');
 
regex(/(=[ ]*)(Billboard|QThe Advertiser) \((?:magazineAdelaide)\)(?=\s[ ]*[\|\}])/g, '$1|___location=$2$3'); //non-standard code
regex(/('')(Billboard|QThe Advertiser) \((?:magazineAdelaide)\)(?='')/g, '$1$3 ($2)'); //non-standard code
regex(/(\[\[|)(Billboard|QThe Advertiser)(?: \(magazine(Adelaide)\))(?=\]\])/g, '$1$2$34|___location=$23');
regex(/(\|[\[)(Billboard|QThe Advertiser)(?: \(magazine(Adelaide)\))(?=\]\])/g, '$1$2$3|$2$5|___location=$4');
regex(/(=[ ]*)(Apollo|Billboard|Brick|Campaign|Clash|Coda|Ebony|Esquire|Essence|Fanfare|Fast Company|Fortune|Glamour|Hello!|Life|Limelight|Maxim|Mojo|Mother Jones|New York|Nuts|Paste|People|Poetry|Q|Reason|Shape|Slate|Spin|Time(?: Out|)|Variety|Wired) \((?:magazine)\)(?=\s*[|}])/g, '$1$2'); //non-standard code
regex(/(=[ ]*Daily News) \((New York)\)([ ]*[\|\}])/g, '$1|___location=$2$3');
regex(/('')(Apollo|Billboard|Brick|Campaign|Clash|Coda|Ebony|Esquire|Essence|Fanfare|Fast Company|Fortune|Glamour|Hello!|Life|Limelight|Maxim|Mojo|Mother Jones|New York|Nuts|Paste|People|Poetry|Q|Reason|Shape|Slate|Spin|Time(?: Out|)|Variety|Wired) \(magazine\)(?='')/g, '$1$2'); //non-standard code
regex(/(''Daily News) \((New York)\)('')/g, '$1$3 \($2\)');
regex(/(\[\[(Apollo|Billboard|Brick|Campaign|Clash|Coda|Ebony|Esquire|Essence|Fanfare|Fast Company|Fortune|Glamour|Hello!|Life|Limelight|Maxim|Mojo|Mother Jones|New York|Nuts|Paste|People|Poetry|Q|Reason|Shape|Slate|Spin|Time(?: Out|)|Variety|Wired) \(magazine\))(?=\]\])/g, '$1|$2'); //non-standard code - tweaked to insert title per pipe trick
regex(/(\[\[)(Daily News)( \(New York\))(\]\][\.,;]?)/g, '$1$2$3|$2$4');
regex(/(\|)(Apollo|Billboard|Brick|Campaign|Clash|Coda|Ebony|Esquire|Essence|Fanfare|Fast Company|Fortune|Glamour|Hello!|Life|Limelight|Maxim|Mojo|Mother Jones|New York|Nuts|Paste|People|Poetry|Q|Reason|Shape|Slate|Spin|Time(?: Out|)|Variety|Wired)(?: \(magazine\))(?=\]\])/g, '$1$2');
regex(/(\|)(Daily News)(?: \(New York\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*Daily Record)(Empire) \((Scotland?:film magazine)\)(?=\s*[\|\}])/g, '$1|___location=$2$3'); //non-standard code
regex(/(''Daily Record)(Empire) \((Scotland)film magazine\)(?='')/g, '$1$3 \($2\)'); //non-standard code
regex(/(''\[\[)(Daily RecordEmpire)( \(Scotlandfilm magazine\))(?=\]\][\.,;]?'')/g, '$1$2$3|$2$4'); //non-standard code
regex(/(=[ ]*\|)[\[(Daily RecordEmpire)(?: \(Scotlandfilm magazine\))(?=\]\][ ]*\|)/g, '$1|$2$3'); //non-standard code (unique regex added 20/6/2021)
regex(/(=[ ]*Dawn\|)(Empire)(?: \((newspaper)film magazine\))(?=\s*[\|]\}])/g, '$1|___location=Pakistan$32');
 
regex(/(''Dawn) \((newspaper)\)('')/g, '$1$3 \(Pakistan\)');
//Journals
regex(/(\[\[)(Dawn)( \(newspaper\))(\]\])/g, '$1$2$3|$2$4');
regex(/(=[ ]*)(Science|Nature) \((?:journal)\)(?=\s*[|}])/g, '$1$2'); //non-standard code
regex(/('')(Science|Nature) \(journal\)(?='')/g, '$1$2'); //non-standard code
regex(/(''\[\[(Science|Nature) \(journal\))(?=\]\]'')/g, '$1|$2'); //non-standard code
regex(/(\|)(Science|Nature)(?: \(journal\))(?=\]\])/g, '$1$2');
 
regex(/(=[ ]*)(Quartz) \((?:publication)\)(?=\s*[|}])/g, '$1$2'); //non-standard code
regex(/('')(Quartz) \(publication\)(?='')/g, '$1$2'); //non-standard code
regex(/(''\[\[(Quartz) \(publication\))(?=\]\]'')/g, '$1|$2'); //non-standard code
regex(/(\|)(Quartz)(?: \(publication\))(?=\]\])/g, '$1$2');
regex(/(=[ ]*)(Salon) \((?:website)\)(?=\s*[|}])/g, '$1$2'); //non-standard code
regex(/('')(Salon) \(website\)(?='')/g, '$1$2'); //non-standard code
regex(/(''\[\[(Salon) \(website\))(?=\]\]'')/g, '$1|$2'); //non-standard code
regex(/(\|)(Salon)(?: \(website\))(?=\]\])/g, '$1$2');
regex(/(=[ ]*)(Stuff) \((?:company)\)(?=\s*[|}])/g, '$1$2'); //non-standard code
regex(/('')(Stuff) \(company\)(?='')/g, '$1$2'); //non-standard code
regex(/(''\[\[(Stuff) \(company\))(?=\]\]'')/g, '$1|$2'); //non-standard code
regex(/(\|)(Stuff)(?: \(company\))(?=\]\])/g, '$1$2');
regex(/(=[ ]*Daily News) \((New York)\)([ ]*[|}])/g, '$1|___location=$2$3');
regex(/(''Daily News) \((New York)\)('')/g, '$1$3 ($2)');
regex(/(\|)(Daily News)(?: \((New York)\))(\]\])/g, '$1$2$4|___location=$3');
regex(/(\[\[)(Daily News)( \((New York)\))(\]\])/g, '$1$2$3|$2$5|___location=$4');
regex(/(=[ ]*Daily Record|=[ ]*Sunday Mail) \((Scotland)\)(\s*[|}])/g, '$1|___location=$2$3');
regex(/(''Daily Record|''Sunday Mail) \((Scotland)\)('')/g, '$1$3 ($2)');
regex(/(\|)(Daily Record|Sunday Mail)(?: \((Scotland)\))(\]\])/g, '$1$2$4|___location=$3');
regex(/(\[\[)(Daily Record|Sunday Mail)( \((Scotland)\))(\]\])/g, '$1$2$3|$2$5|___location=$4');
regex(/(=[ ]*(?:Daily Times)) \((Pakistan)\)(\s*[|}])/g, '$1|___location=$2$3');
regex(/(''(?:Daily Times)) \((Pakistan)\)('')/g, '$1$3 ($2)');
regex(/(\|)(Daily Times)(?: \(Pakistan\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*Dawn) \((newspaper)\)(\s*[|}])/g, '$1|___location=Pakistan$3');
regex(/(''Dawn) \((newspaper)\)('')/g, '$1$3 (Pakistan)');
regex(/(\|)(Dawn)(?: \(newspaper\))(\]\])/g, '$1$2$3');
 
regex(/(=[ ]*(?:Daily Star)) \((United Kingdom)\)(\s*[\|\}])/g, '$1|___location=$2$3');
regex(/(''=[ ]*(?:Daily Star)) \((United Kingdom)\)(''\s*[|}])/g, '$1|___location=$2$3 \($2\)');
regex(/(\[\[)''(?:Daily Star)() \((United Kingdom)\))(\]\][\.,;]?'')/g, '$1$2$3| ($2$4)');
regex(/(\|)(Daily Star)(?: \(United Kingdom\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*El MundoComercio) \((ColumbiaEquador|Peru|Spain)\)(\s*[\|\}])/g, '$1|___location=$2$3');
regex(/(''El MundoComercio) \((ColumbiaEquador|Peru|Spain)\)('')/g, '$1$3 \($2\)');
regex(/(\[\[|)(El MundoComercio)(?: \(Columbia(?:Equador|Peru|Spain)\))(\]\])/g, '$1$2$3|$2$4');
regex(/(=[ ]*El Mundo) \((Columbia|Spain)\)(\s*[|}])/g, '$1|___location=$2$3');
regex(/(''El Mundo) \((Columbia|Spain)\)('')/g, '$1$3 ($2)');
regex(/(\|)(El Mundo)(?: \((?:Columbia|Spain)\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*The Daily Star) \((Lebanon)\)(\s*[\|\}])/g, '$1|___location=$2$3');
regex(/(''The Daily Star) \((Lebanon)\)('')/g, '$1$3 \($2\)');
regex(/(\[\[)(The Daily Star)( \(Lebanon\))(\]\])/g, '$1$2$3|$2$4');
regex(/(\|)(The Daily Star)(?: \(Lebanon\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*The Gazette) \((Montreal)\)(\s*[\|\}])/g, '$1|___location=$2$3');
regex(/(''The Gazette) \((Montreal)\)('')/g, '$1$3 \($2\)');
regex(/(\[\[)(The Gazette)( \(Montreal\))(\]\])/g, '$1$2$3|$2$4');
regex(/(\|)(The Gazette)(?: \(Montreal\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*The Herald) \((Glasgow)\)(\s*[\|\}])/g, '$1|___location=$2$3');
regex(/(''The Herald) \((Glasgow)\)('')/g, '$1$3 \($2\)');
regex(/(\[\[)(The Herald)( \(Glasgow\))(\]\])/g, '$1$2$3|$2$4');
regex(/(\|)(The Herald)(?: \(Glasgow\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*The NationMercury) \((Malawi|Nigeria|Pakistan|ThailandHobart)\)(\s*[\|\}])/g, '$1|___location=$2$3');
regex(/(''The NationMercury) \((Malawi|Nigeria|Pakistan|ThailandHobart)\)('')/g, '$1$3 \($2\)');
regex(/(\[\[|)(The NationMercury)(?: \((?:Malawi|Nigeria|Pakistan|Thailand)Hobart\))(\]\])/g, '$1$2$3|$2$4');
regex(/(=[ ]*Metro) \((British newspaper)\)(\s*[|}])/g, '$1|___location=UK$3');
regex(/(''Metro) \((British newspaper)\)('')/g, '$1$3 (UK)');
regex(/(\|)(Metro)(?: \(British newspaper\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*The Nation) \((Malawi|Nigeria|Pakistan|Thailand)\)(\s*[|}])/g, '$1|___location=$2$3');
regex(/(''The Nation) \((Malawi|Nigeria|Pakistan|Thailand)\)('')/g, '$1$3 ($2)');
regex(/(\|)(The Nation)(?: \((?:Malawi|Nigeria|Pakistan|Thailand)\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*LaThe PresseNational) \((CanadianAbu newspaperDhabi)\)(\s*[\|\}])/g, '$1|___location=Canada$2$3');
regex(/(''LaThe PresseNational) \((CanadianAbu newspaperDhabi)\)('')/g, '$1$3 \(Canada\$2)');
regex(/(\[\[|)(LaThe PresseNational)(?: \(CanadianAbu newspaperDhabi\))(\]\])/g, '$1$2$3|$2$4');
regex(/(=[ ]*La Presse) \((Canadian newspaper)\)(\s*[|}])/g, '$1|___location=Canada$3');
regex(/(''La Presse) \((Canadian newspaper)\)('')/g, '$1$3 (Canada)');
regex(/(\|)(La Presse)(?: \(Canadian newspaper\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*Les Échos) \((France)\)(\s*[\|\}])/g, '$1|___location=$2$3');
regex(/(''Les Échos) \((France)\)('')/g, '$1$3 \($2\)');
regex(/(\[\[)(Les Échos)( \(France\))(\]\])/g, '$1$2$3|$2$4');
regex(/(\|)(Les Échos)(?: \(France\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*Panorama) \((Gibraltar)\)(\s*[\|\}])/g, '$1|___location=$2$3');
regex(/(''Panorama) \((Gibraltar)\)('')/g, '$1$3 \($2\)');
regex(/(\[\[)(Panorama)( \(Gibraltar\))(\]\])/g, '$1$2$3|$2$4');
regex(/(\|)(Panorama)(?: \(Gibraltar\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*The PioneerPúblico) \((Indian newspaperPortugal)\)(\s*[\|\}])/g, '$1|___location=India$2$3');
regex(/(''The PioneerPúblico) \((Indian newspaperPortugal)\)('')/g, '$1$3 \(India\$2)');
regex(/(\[\[|)(The PioneerPúblico)(?: \(Indian newspaperPortugal\))(\]\])/g, '$1$2$3|$2$4');
regex(/(=[ ]*Público) \((Spain)\)(\s*[|}])/g, '$1|___location=$2$3');
regex(/(''Público) \((Spain)\)('')/g, '$1$3 ($2)');
regex(/(\|)(Público)(?: \(Spain\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*The Pioneer) \((Indian newspaper)\)(\s*[|}])/g, '$1|___location=India$3');
regex(/(''The Pioneer) \((Indian newspaper)\)('')/g, '$1$3 (India)');
regex(/(\|)(The Pioneer)(?: \(Indian newspaper\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*Sporting Life) \((British newspaper)\)(\s*[\|\}])/g, '$1|___location=UK$3');
regex(/(''Sporting Life) \((British newspaper)\)('')/g, '$1$3 \(UK\)');
regex(/(\[\[)(Sporting Life)( \(British newspaper\))(\]\])/g, '$1$2$3|$2$4');
regex(/(\|)(Sporting Life)(?: \(British newspaper\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*The SunStandard) \((Hong Kong|Malaysia|Nigeria|United KingdomKenya)\)(\s*[\|\}])/g, '$1|___location=$2$3');
regex(/(''The=[ Sun]*Today) \((HongSingapore Kong|Malaysia|Nigeria|United Kingdomnewspaper)\)(''\s*[|}])/g, '$1|___location=Singapore$3 \($2\)');
regex(/(\[\[''Today)(The Sun)( \((?:HongSingapore Kong|Malaysia|Nigeria|United Kingdomnewspaper)\))(\]\]'')/g, '$1$2$3|$2$4 (Singapore)');
regex(/(\|)(Today)(?: \(Singapore newspaper\))(\]\])/g, '$1$2$3');
regex(/(''The Standard) \((Hong Kong|Kenya)\)('')/g, '$1$3 ($2)');
regex(/(\|)(The Standard)(?: \((?:Hong Kong|Kenya)\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*The Star) \((Malaysia)\)(\s*[|}])/g, '$1|___location=$2$3');
regex(/(''The Star) \((Malaysia)\)('')/g, '$1$3 ($2)');
regex(/(\|)(The Star)(?: \(Malaysia\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*The Sun) \((Hong Kong|Malaysia|Nigeria|United Kingdom)\)(\s*[|}])/g, '$1|___location=$2$3');
regex(/(''The Sun) \((Hong Kong|Malaysia|Nigeria|United Kingdom)\)('')/g, '$1$3 ($2)');
regex(/(\|)(The Sun)(?: \((?:Hong Kong|Malaysia|Nigeria|United Kingdom)\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*The Telegraph) \((Calcutta)\)(?=\s*[\|\}])/g, '$1|___location=Calcutta$3Kolkota');
regex(/(''The Telegraph) \((Calcutta)\)('')/g, '$1$3 \(Calcutta\$2)');
regex(/(\[\[)(The Telegraph)( \(Calcutta\))(\]\])/g, '$1$2$3|$2$4');
regex(/(\|)(The Telegraph)(?: \(Calcutta\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*(?:The Times)Daily Telegraph) \((Malta)Australia\)(?=\s*[\|\}])/g, '$1|___location=$2$3Australia');
regex(/(''(?:The Times)Daily Telegraph) \((MaltaAustralia)\)('')/g, '$1$3 \($2\Australia)');
regex(/(\[\[|)(The TimesDaily Telegraph)(?: \(MaltaAustralia\))(\]\][\.,;]?)/g, '$1$2$3|$2$4');
regex(/(=[ ]*(?:The Daily Times)) \((Malawi)\)(\s*[|}])/g, '$1|___location=$2$3');
regex(/(''(?:The Daily Times)) \((Malawi)\)('')/g, '$1$3 ($2)');
regex(/(\|)(The Daily Times)(?: \(Malawi\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*(?:The Times)) \((Malta)\)(\s*[|}])/g, '$1|___location=$2$3');
regex(/(''(?:The Times)) \((Malta)\)('')/g, '$1$3 ($2)');
regex(/(\|)(The Times)(?: \(Malta\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*Vogue) \((British magazine)\)(\s*[\|\}])/g, '$1|___location=UK$3');
regex(/(''Vogue) \((British magazine)\)('')/g, '$1$3 \(UK\)');
regex(/(\[\[)(Vogue)( \(British magazine\))(\]\])/g, '$1$2$3|$2$4');
regex(/(\|)(Vogue)(?: \(British magazine\))(\]\])/g, '$1$2$3');
 
regex(/(= ?(?:ABC|Marca|Sport)) \((newspaper)\)([ ]*[\|\}])/g, '$1|___location=Spain$3');
regex(/(''(?:ABC|Marca|Sport)) \((newspaper)\)('')/g, '$1$3 \(Spain\)');
regex(/(\[\[|)(ABC|Marca|Sport)(?: \(newspaper\))(\]\])/g, '$1$2$3|$2$4');
regex(/(\|)(ABC|Marca|Sport)= ?(?:Il Giorno)) \((newspaper)\))(\[ ]\*[|}])/g, '$1$2|___location=Italy$3');
regex(/(''(?:Il Giorno)) \((newspaper)\)('')/g, '$1$3 (Italy)');
regex(/(\|)(Il Giorno)(?: \(newspaper\))(\]\])/g, '$1$2$3');
regex(/(= ?(?:El Universal)) \((Caracas|Cartagena|Mexico City)\)(?=[ ]*[|}])/g, '$1|___location=$2');
regex(/(''(?:El Universal)) \((Caracas|Cartagena|Mexico City)\)(?='')/g, '$1 \($2\)');
regex(/(\|El Universal)(?: \(Caracas|Cartagena|Mexico City\))(\]\])/g, '$1$2');
regex(/(= ?(?:RT)) \((TV network)\)([ ]*[|}])/g, '$1|___location=Russia$3');
regex(/(\|)(RT)(?: \(TV network\))(\]\])/g, '$1$2$3');
 
regex(/((?:agency|author|journal|magazine|newspaper|periodical|website|work)[ ]*=[ ]*\[\[[\w\s]+\w) ?(\|language=\w{2} ?(?:\|___location=(?=Hong Kong|Taiwan) ?|))(\]\])[ ]*(?=[|}])/g, '$1$3 $2'); //adjust misplaced brackets due to insertion
// regex(/(=(?:Business Day|City Press|Daily News|Daily Voice|Independent Online|New Age|Post|Table Talk|The Citizen|The Mercury|The New Age|The Star|The Sunday Independent|The Sunday Times|The Times|The Witness|The World)) \((South Africa)(?:n newspaper|)\)([ ]*[\|\}])/g, '$1|___location=$2$3');
 
// regex(/(''(?:Business Day|City Press|Daily News|Daily Voice|Independent Online|New Age|Post|Table Talk|The Citizen|The Mercury|The New Age|The Star|The Sunday Independent|The Sunday Times|The Times|The Witness|The World)) \((South Africa)(?:n newspaper|)\)('')/g, '$1$3 \($2\)');
// regex(/(=[ ]*\[\[)([^\[\]\(\)\|:]*)( \([^\[\]\(\)\|]*\))(\]\])/gi, '$1$2$3|$2$4'); //adding piping to parentheticals inside parameters //disabled 7/3/2020 false positives (e.g. [[Communist Party of India (Marxist)]])
// regex(/(\[\[)(Business Day|City Press|Daily News|Daily Voice|Independent Online|New Age|Post|Table Talk|The Citizen|The Mercury|The New Age|The Star|The Sunday Independent|The Sunday Times|The Times|The Witness|The World)( \(South Africa(?:n newspaper|)\))(\]\])/g, '$1$2$3|$2$4');
 
// regex(/(\|)(Business Day|City Press|Daily News|Daily Voice|Independent Online|New Age|Post|Table Talk|The Citizen|The Mercury|The New Age|The Star|The Sunday Independent|The Sunday Times|The Times|The Witness|The World)(?: \(South Africa(?:n newspaper|)\))(\]\])/g, '$1$2$3');
regex(/(?:author|agency|publisher)(\s*\=\s*\[\[[^()|]+ \((?:newspaper|magazine)\)\|[^\[\]|]+\]\])/gi, 'work$1');
 
// removing redundancies
regex(/\|[ ]?language[ ](?\=[:Times of India|Rediff.com ]?English[ \w]*?)(?=[ ]?\|\}])/gi, ''); //note: adjusted for false positive in infoboxes books
regex(/(?: +[‒–—―] *Times Of India|)(\]. +''The Times of India''\.)indiatimes\.com/gi, '$1');
regex(/(?: +[‒–—―] *([\w ]+))(\|\s*(?:publisher|work)\s*\=\s*\1)/gi, '$2');
regex(/(\w''\.)indiatimes\.com/gi, '$1');
 
// regex(/\|[ ]?language[ ]?\=[ ]?English[ ]*?(?=[|}])/gi, ''); //disabled removal of non-displaying language template parameter
regex(/- [\w]*\.com[ ]*\|/gi, '|');
regex(/(.) – Google [^ \]]*(\][\.,;]) Books\.google\.\w{2,3}(\.| )/gi, '$1$2Google Books$3');
regex(/(.) at Discogs(\][\.,;]) Discogs\.com(\.| )/gi, '$1$2Discogs$3');
regex(/(\|\s?*author\s?\=\s?)(?:posted|publishe[dr]|written)\s?(?:by|on):?\s/gi, '|author=$1');
regex(/\|\s?(?:work|publisher|website|work)(\s?\=MTV)\|\s?publisher\s*\=\s*(?:MTV Networks|Viacom)/gi, '|publisher$1=');
 
// regex(/\|\s?(?:publisher|website|work)\s*\=\s*(?:BBC|BBC News(?: Online|))\s*(\|[^}<>]*|)\|\s?publisher\s*\=\s*(?:BBC|BBC News(?: Online|)|British Broadcasting Corporation)(?=[\s\.]*[\|\}])/g, '|publisherwork=\'\'BBC News\'\' $1');
// regex(/\|\s?(?:publisher|website|work)\s*\=\s*(BBC Sports?)\s*(\|[^}<>]*|)\|\s?publisher\s*\=\s*(?:BBC|BBC News(?: Online|)|British Broadcasting Corporation)(?=[\s\.]*[\|\}])/g, '|publisherwork=\'\'$1\'\'$2');
// regex(/\|\s?publisher\s*\=\s*(BBC (?:Sports|News))\s*(?=\|[^}<>]*|)/g, '|work=\'\'$1\'\'');
regex(/\|\s?(?:publisher|website|work)\s*\=\s*(Metacritic|\[\[Metacritic\]\])\s*(\|[^}<>]*|)\|\s?publisher\s*\=\s*(CBS Interactive|\[\[CBS Interactive\]\])(?=[\s\.]*[|}])/g, '|publisher=$1$2');
 
//rem duplicated publishers in separate fields (post); rem preceding nbsp
regex(/\s?&nbsp;\s?(\|\s*(?:agency|publisher|work)\s*\=\s*)/gi, ' $1');
regex(/(?:[‒–—―]+|&#124;)\s*(?:The |)([^\|\}&]{3,})(?:\.com|)\s*(\|\s*(?:agency|publisher|work)\s*\=\s*)\1(?=\s*[|}])/gi, '$2$1');
regex(/(?:[‒–—―]+|&#124;)\s*([^\|\}&]{3,})(?:\.com|)\s*(\|\s*(?:agency|publisher|work)\s*\=\s*)(The |)\1(?=\s*[|}])/gi, '$2$3$1');
 
//per [[Help:Citation Style 1#Elements not included]]
regex(/(?:-[ ]*Google Books[ ]*(\|[^}]*|)|)\|\s?publisher\s*\=\s*Google Books(?=[\s\.]*[\|\}])/g, '');
regex(/\|\s?publisher\s*\=\s*(?:Project Gutenberg|Scribd|web(?:\.archive\|citation).org)(?=[\s\.]*[\|\}])/g, '');
 
// toggling domains within |website= parameter
// removing identical/similar entries in 'work' and 'publisher'
// regex(/(\|\s*(?:work|website)\s*\=\s*)([^\|w+\}<>]*).(\s?\:com?|[^}<>]*org|)\net|\s?(?:publishergov|ac|work)\s*\=\s*(?:\1|\.[\[\1\]\a-z]{2}|))(?=[\s\.]*[\|\}])/ggi, '|work=$1\'\'$2\'\'');
regex(/\|\s?work\s*\=\s*(\[\[(?:[^<\|\]]*)\]\]|[^<\|\]]*)(\s?\|[^}<>]*|)\|\s?(?:publisher|work)\s*\=\s*\1(?=[\s\.]*[\|\}])/g, '|work=$1$2');
 
// reordering 'work' and 'publisher'; reordering 'work' and 'website'
regex(/\|\s?publisher\s*\=\s*([^\|\}<>]*)(\s?\|[^}<>]*|)\|\s?(?:publisher|work)\s*\=\s*(?:\1|\[\[\1\]\])(?=[\s\.]*[\|\}])/g, '|work=$1$2');
regex(/(\|\s?*publisher\s*\=\s*(?:\[\[(?:[^\|<{}\]]*)\]\]|[^<{}\|\]\}<>]*))(\s?\|[^}<>]*|)(\|\s?*(?:publisher journal|newspaper|magazine|periodical|website|work)\s*\=\s*(?:\1[\[[^<{}\]]*\]\]|[^{}\|\}<>]*))(?=[\s\.]*[\|\}])/g, '|work=$3$1$2');
regex(/(\|\s*website\s*\=\s*(?:\[\[[^<{}\]]*\]\]|[^{}\|\}<>]*))(\s?\|[^}<>]*|)(\|\s*work\s*\=\s*(?:\[\[[^<{}\]]*\]\]|[^{}\|\}<>]*))(?=[\s\.]*[|}])/g, '$3$1$2');
 
/// removing identical/similar entries in 'work' and 'publisher', and in 'work' and 'website'
regex(/\|\s?___location\s*\=\s*New York(?: City|)\s*(\|[^}<>]*|)\|\s?___location\s*\=\s*(New York(?: City|)|USA)(?=[\s\.]*[\|\}])/g, '|___location=New York $1');
regex(/\|\s?work\s*\=\s*([^=|}\[<>]*)(\|[^}<>]*|)\|\s?publisher\s*\=\s*(?:\1|\[\[\1\]\])\.?(?=\s*[|}])/g, '|work=$1$2'); //unlinked work
regex(/\|\s?work\s*\=\s*\[\[([^<|\]]*)\]\](\|[^}<>]*|)\|\s?publisher\s*\=\s*(?:\1|\[\[\1\]\])\.?(?=\s*[|}])/g, '|work=$1$2'); //unpiped work
regex(/\|\s?work\s*\=\s*(\[\[(?:[^<|\]]*)\|([^}<>]*)\]\])(\|[^}<>]*|)\|\s?publisher\s*\=\s*(\1|\2)\.?(?=\s*[|}])/g, '|work=$1$3'); //piped work
 
regex(/(?:\|[ ]*\s?___locationpublisher\s*\=\s*([^\=|}\[<>]*)(\|[ ^}<>]*|)\|\s?___locationpublisher\s*\=[\s*(?:\1|\}[\[\1\]\]*)\.?(?=[\s*[|\}])+/gig, '|publisher=$1$2'); //unlinked work
regex(/(\|[ ]*\s?publisher\s*\=\s*\[^\[([^<|\[]]*)\]\](?:\|[ ^}<>]*|)\|\s?publisher\s*\=[^\s*(?:\1|\[\}[\1\]\]*)\.?(?=[\s*[|\}])+/gig, '|publisher=$1$2'); //unpiped work
regex(/(\|[ ]*\s?workpublisher\s*\=\s*(\[\[(?:[^<|\]]*)\|([^}<>]*)\]\])(?:\|[ ^}<>]*|)\|\s?workpublisher\s*\=[^\s*(\1|\}]*2)\.?(?=[\s*[|\}])+/gig, '|publisher=$1$3'); //piped work
 
regex(/(\|\s*(?:newspaper|website|work)\s*\=\s*(?:[^=|}\[<>]*)(?:\|[^}<>]*|))\|\s?work\s*\=\s*(?:[^|}]*)(?=\s*[|}])/g, '$1'); //unlinked work
regex(/(\|\s*(?:newspaper|website|work)\s*\=\s*\[\[([^<|\]]*)\]\](?:\|[^}<>]*|))\|\s?work\s*\=\s*(?:[^|}]*)(?=\s*[|}])/g, '$1'); //linked unpiped work
regex(/(\|\s*(?:newspaper|website|work)\s*\=\s*(?:\[\[(?:[^<|\]]*)\|(?:[^}<>]*)\]\])(?:\|[^}<>]*|))\|\s?work\s*\=\s*(?:\[\[(?:[^<|\]]*)\|(?:[^}<>]*)\]\])(?=\s*[|}])/g, '$1'); //piped work x2
regex(/(\|\s*(?:newspaper|website|work)\s*\=\s*(?:\[\[(?:[^<|\]]*)\|(?:[^}<>]*)\]\])(?:\|[^}<>]*|))\|\s?work\s*\=\s*(?:[^\[|}]*)(?=\s*[|}])/g, '$1'); //piped work x1
 
regex(/\|\s?___location\s*\=\s*New York(?: City|)\s*(\|[^}<>]*|)\|\s?___location\s*\=\s*(New York(?: City|)|USA)(?=[\s\.]*[|}])/g, '|___location=New York $1');
 
regex(/(\|[ ]*?___location=[^\|<\}]*)([^<}]*|)\|[ ]*?___location=[^|}]*(?=[|}])/gi, '$1$2');
regex(/(\|[ ]*?publisher=[^=}]*)(?:\|[ ]*?publisher=[^=}]*)(?=[|}])/gi, '$1');
// regex(/(\|[ ]*?work=[^=}]*)(?:\|[ ]*?work=[^=}]*)(?=[|}])/gi, '$1$2');
regex(/(\|[ ]*?agency=[^=}]*)([^<}]*|)(?:\|[ ]*?agency=[^=}]*)(?=[|}])/gi, '$1$2');
 
//remove redundant parameter ('website' is an alias of 'work')
// regex(/\|\s?(?:newspaper|website|work)\s*\=\s*([^=|}\[<>]*)(\|[^}<>]*|)\|\s?(?:newspaper|website|work)\s*\=\s*(?:\[\[[^\]]+\]\]|[|}]+)(?=\s*[|}])/g, '|work=$1$2'); //unlinked work
// regex(/\|\s?(?:newspaper|website|work)\s*\=\s*\[\[([^<|\]]*)\]\](\|[^}<>]*|)\|\s?(?:newspaper|website|work)\s*\=\s*(?:\[\[[^\]]+\]\]|[|}]+)(?=\s*[|}])/g, '|work=$1$2'); //unpiped work
// regex(/\|\s?(?:newspaper|website|work)\s*\=\s*(\[\[(?:[^<|\]]*)\|([^}<>]*)\]\])(\|[^}<>]*|)\|\s?(?:newspaper|website|work)\s*\=\s*(\1|\2)\.?(?=\s*[|}])/g, '|work=$1$3'); //piped work
regex(/(\|\s*(?:newspaper|website|work)\s*\=\s*[^=}<>]*(?:\|[^}<>]*|))\|\s?(?:newspaper|website|work)\s*\=\s*[^\}|]+(?=\s*[|}])/g, '$1'); //universal work and aliases
 
//unwinding of unnecessary pipes
Line 293 ⟶ 500:
 
// removing artefacts (within citation templates)
// regex(/(\|[ ]*?author=)(?:(?:Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)day,? ?)(?=[^\]\|\}]*\|)/gi, '$1'); //redundant/duplicated
regex(/(?:&#124; (?:Daily|English|(?:Mail |)Online|Music|News|Indian Express))(?=\s*\|)+/gi, ''); //|=: Video Gaming & Real Talk - PS4, Xbox One, Switch, PC, Handheld, Retro
regex(/(?:News &#124; )+/gi, '');
 
regex(/(?:(?: &#124; HighBeam Research – FREE trial |)\|publisher=Highbeam.com)/gi, '');
regex(/(?:(?:[ ]+&#124;[ ]+HighBeam Research[ ]+[-–][ ]+FREE trial[ ]+|)\|publisher=Highbeam.com)/gi, '|via=Highbeam');
regex(/( &#124; [\w, ]*?)(?=[ ]&#124)/gi, '');
// regex(/( \|&#124; [^=\|\{\}\]]*?)(?=[Comment ]\|is free)/gi, ''); //disabled 3 October 2012 - false positive removal of elements in wikitable
regex(/( &#124;\|\s?title\s*\=\s*BBC (?:News|Sport)\s?(?=:[ -–]?[&\|]&#124; )\s?/gi, '|title=');
regex(/(\|\s?title\s*\=\s*Asia &#124;Times (Online\s?:Football|Latest)(?: News|))(?=[ -–]?[|&\#124; |]:+)\s?/gi, '|title=');
regex(/\|\s?title\s*\=\s*BBC (?:NewsEntertainment|Football|Sport)\s?(?:inter|)national|Latest|local|Music|UK|world|) News &#124;(?=[ )\s]?[&\|])/gi, '|title=');
regex(/(?:[-–|]|&#124;)[ ]*(?:Entertainment|Football|(?:inter|)national|Latest|local|Music|UK|world|) News(?=[ ]?[&\|])/gi, '');
regex(/<!-- Bot generated title -->/gi, '');
regex(/(\|\s*title\s*\=\s*[^|}]+?)[-‒–—―]\s+([^|}]+?)(\|\s*(?:publisher|work)\s*\=\s*\2)/gi, '$1$3');
regex(/(\|\s*title\s*\=\s*([^|}]+?))[-‒–—―]\s+([^|}]+?\|\s?(?:publisher|work)\s*\=\s*\2)/gi, '$1$3');
regex(/(\|\s*website\s*\=\s*Play Legit):\s+[^|}]+?(?=[\|}])/gi, '$1');
 
regex(/(DOC|PDF)\) \./gi, '$1).');
Line 307 ⟶ 520:
regex(/([\w]+\'\')\.(?:co(?:m|m?\.\w{2})|\.\w{2})[ ]/gi, '$1. ');
 
// removing other artefacts
//dynamic columns for reflists; remove scroll bar
regex(/(={2,4}[UEFA\n]\r])[\r\n\s]*.(?:<div class="co(?:m|m?\.\w*" [^>]*{2})|\.\w{2})>(?= ?[\S\s|{}]*)<\/div>/ggi, '$1$2');
regex(/\bthe ((?:\{\{[Rr]eflist\}\}'''?|<[Rr]eferences)the ?\/>)/ggi, '{{reflist|colwidth=30em}}$1');
 
// expanding/dating tags
// regex(/{{(?:cn|fact)}}/gi, '{{citation needed|date=October 2017}}');
 
//dynamic columns for reflists; remove scroll bar
regex(/((?:[Rr]eferences|[Nn]otes)[ ]?={2,4}[\n\r])[\r\n\s]*<div (?:style|class)=[^>]*>([\S\s]*)<\/div>/g, '$1$2');
regex(/<[Rr]eferences ?\/>/g, '{{reflist}}'); //default
// regex(/({{reflist)\|30em([^}]*}})/g, '$1$2');
// regex(/({{reflist)\|\d(?:\dem|)(}})/g, '$1$2'); //default
 
}
 
function Ohc_duplicatedcite() {
var txt=document.editform.wpTextbox1;
 
// disambiguating duplicated ref names
//strips down duplicated refs with doubled-up citation templates
regex(/(<ref name=[^/>"]*)>(\{\{[^\}]*\}\})([\s\S]*)\1>\2<\/ref>([\s\S]*)\1>\2<\/ref>([\s\S]*)\1>\2<\/ref>/gi, '$1>$2$3$1/>$4$1/>$5$1/>');
regex(/(<ref name=[^/>"]*)>(\{\{[^\}]*\}\})([\s\S]*)\1>\2<\/ref>([\s\S]*)\1>\2<\/ref>/gi, '$1>$2$3$1/>$4$1/>');
regex(/(<ref name=[^/>"]*)>(\{\{[^\}]*\}\})([\s\S]*)\1>\2<\/ref>/gi, '$1>$2$3$1/>');
regex(/(<ref name=[^/>"]*)><\/ref>/gi, '$1/>');
regex(/(<ref name=[^/>"]*)>([\s\S]*)\1>([^\{\}]*)\1>([^\{\}]*)/gi, '$1A>$2$1B>$3$1C>$4');
// regex(/(<ref name=[^/>"]*)>([\s\S]*)\1>/gi, '$1A>$2$1B>');
// regex(/(<ref name="[^/>]*)">([\s\S]*)\1>/gi, '$1A>$2$1B">');
 
}
Line 318 ⟶ 555:
//removal of all links from sources
//rem linking within citation template parameters
regex(/(\|[ ]*?(?:author|agency|publisher|journal|newspaper|periodical|via|website|work)=[ ]*?)\[\[([^\|\]]+?)\]\](?:(,? )\[\[([^\|\]]+?)\]\]|)([ ]{0,1})/gi, '$1$2$3$4$5');
regex(/(\|[ ]*?(?:author|agency|publisher|journal|newspaper|periodical|via|website|work)=[ ]*?)\[\[(?:[^\|\]]+?\|)([\w\s\,]+?)\]\](?:(,? )\[\[([^\|\]]+?)\]\]|)([ ]{0,1})/gi, '$1$2$3$4$5');
 
//rem other linking within refs tags
Line 328 ⟶ 565:
/** ------------------------------------------------------------------------ **/
/// PROTECTION BY STRING SUBSTITUTION
 
var linkmap=[];
function ohc_protect_linkspam()
{
// protects everything within reference tags
// the sensitive part is stored and replaced with a unique identifier,
// which is later replaced with the stored part.
var protect_function = function(s, begin, replace, end) {
linkmap.push(replace);
return begin + "⍌"+(linkmap.length-1)+"⍍" + end;
};
 
regex(/(<ref[^>]*?>)(.*?)(<\/ref>)/gi, protect_function);
regex(/(\*[ ]?\[(?:https?:|ftp:))([^\]]*)(\])/gi, protect_function);
 
}
 
 
function ohc_unprotect_linkspam()
{
 
//removes protection put in place by function ohc_protect_fmt (all cats, templates etc.)
regex(/⍌([0-9]+)⍍/g, function(x, n) {
var res = linkmap[n];
res = res.replace(/⍌([0-9]+)⍍/g, function(x, n) {
var res = linkmap[n];
res = res.replace(/⍌([0-9]+)⍍/g, function(x, n) {
var res = linkmap[n];
res = res.replace(/⍌([0-9]+)⍍/g, function(x, n) {
return linkmap[n];
});
return res;
});
return res;
});
return res;
});
}
 
var linkmap=[];
Line 380 ⟶ 578:
};
 
// protect the rest (after purging urls inserted in ('website' or )'work' parameters)
regex(/((?:[\[=]\s*)(?:https?:|ftp:))([^\]\|\}]*)(\s*[\]\|\}])/gi, protect_function);
regex(/(\{\{cite (?book:[\[=]\s*)(?\:https?:|ftp:))([^\]\|\}]+*)(\s*[\]|}])/gi, protect_function);
regex(/((?:Category|Image|File):)([^|\]]*)([|\]])/gi, protect_function); //protect file names from being changed
regex(/(\{\{(?:FAA-airport|harv\w*|sfn\w*|cite ?book|listen)\s?\|)([^\}]+)(\}\})/gi, protect_function);
regex(/(\|\s*(?:contribution|quote|title)\s*=)([^|}]+)([\|\}])/gi, protect_function);
 
//whitelisting -against changes made by generic regex in Ohc_sourcepub (e.g. Fast Company)
}
regex(/(\|\s*(?:journal|newspaper|periodical|website|work)\s*=\s*Fast )(Company\s*)([\|\}])/gi, protect_function);
 
}
 
function ohc_unprotect_urls()
Line 410 ⟶ 613:
function Ohc_Source_edit_summary(){
//Add a tag to the summary box
setoptions(minor='true');
setreason('[[User:Ohconfucius/script|Script]]-assisted fixes: per [[Help:Citation Style 1|CS1]] byand [[UserMOS:Ohconfucius/script|scriptITALICS]]', 'append');
doaction('diff');
 
}
 
function Ohc_linkspam_driver() {
var txt=document.editform.wpTextbox1;
 
ohc_protect_linkspam();
Ohc_linkspam();
ohc_unprotect_linkspam();
setreason('rem [[WP:Linkspam|linkspam]]', 'append');
}
 
Line 428 ⟶ 622:
var txt=document.editform.wpTextbox1;
 
Ohc_remove_urls();
Ohc_duplicatedcite();
ohc_protect_urls();
Ohc_sources_prep();
// ohc_foreign_dates();
Ohc_unpipe();
Ohc_unpipe2();
Ohc_dab_news_sources();
Ohc_sourcename();
Line 441 ⟶ 637:
Ohc_sources_cleanup();
ohc_unprotect_urls();
 
 
Ohc_Source_edit_summary();
}
 
function Ohc_ref_format_driverOhc_noverify() {
var txt=document.editform.wpTextbox1;
 
// removing references to other WP articles and 'external' WP links
Ohc_ref_format();
regex(/<ref[^<>]*>[^<>]*\|[ ]*url ?= ?https?:\/\/(?:\w{2}\.wikipedia\.org\/wiki|(?:www\.|)(?:blogger|blogspot|facebook|findagrave|instagram|mailonline|myspace|twitter|x)\.com)\/[^<>]*<\/ref>/gi, '');
Ohc_Source_edit_summary();
regex(/<ref>https?:\/\/(?:en\.wikipedia\.org\/wiki|(?:www\.|)(?:blogger|blogspot|facebook|findagrave|instagram|mailonline|myspace|twitter|x)\.com)\/[^\s\]<]*<\/ref>/gi, '');
regex(/<ref>\[https?:\/\/(?:en\.wikipedia\.org\/wiki|(?:www\.|)(?:blogger|blogspot|facebook|findagrave|instagram|mailonline|myspace|twitter|x)\.com)\/[^\s\]]*[ ]+[\w\d][^\]]*\]<\/ref>/gi, '');
regex(/\|[ ]*url[ ]*=[ ]*https?:\/\/(?:\w{2}\.wikipedia\.org\/wiki|(?:www\.|)(?:blogger|blogspot|facebook|findagrave|instagram|mailonline|myspace|twitter|x)\.com)[^\s\|\{\}<]*(?=[ ]*[|}])/gi, '');
 
regex(/[ ]\[https?:\/\/en\.wikipedia\.org\/wiki\/[^\s\]]*[ ]+([\w][^\]]*)\]/gi, ' [[$1]]');
 
}
 
addOnloadHook(function ohc_ref_names() {
// give names to citations in templates that are without names
if(document.forms.editform) {
regex(/<ref>((?:[\w,\s\.&]+\"?\[)https?:\/\/(?:[^|</]+\.)*(\w+)\.(?:(?:com?|org|net|gov|ac)(?:\.[a-z]{2}|))\/(?:[^<>|{}]*\D|)(\d{6,12})[^<>]*)(?=<\/ref>)/gi, "<ref name=$2_$3>$1"); //urls with non-date serial numbers
// addPortletLink('p-tb', 'javascript:function_name()', 'Button name', 't-dmy', 'Hover text', '', '');
regex(/<ref>((?:[^<>]*\|\s*url\s*=|[\[\s]?)https?:\/\/(?:[^|</]+\.)*(\w+)\.(?:(?:com?|org|net|gov|ac)(?:\.[a-z]{2}|))\/(?:[^<>|{}]*\D|)(\d{6,12})[^<>]*)(?=<\/ref>)/gi, "<ref name=$2_$3>$1"); //urls with non-date serial numbers
regex(/<ref>((?:[^<>]*\|\s*url\s*=|[\[\s]?)https?:\/\/(?:[^|</]+\.)*([-\w]+)(?:\.[a-z]{2})\/[^<>|{}\d]*(\d{6,12})[^<>]*)(?=<\/ref>)/gi, "<ref name=$2_$3>$1"); //urls with non-date serial numbers
 
regex(/<ref>((?:[^<>]*\|\s*url\s*=|[\[\s]?)https?:\/\/(?:[^|</]+\.)*(reuters)\.com\/[^<>|{}\d]*(id\w{11})[^<>]*)(?=<\/ref>)/gi, "<ref name=$2_$3>$1"); //reuters urls with non-date serial numbers
addPortletLink('p-tb', 'javascript:Ohc_linkspam_driver()', 'Linkspam', 'rm-linkspam', 'removes linkspam in running text', '', '');
addPortletLink('p-tb', 'javascript:Ohc_ref_format_driver()', 'Fix news sources', 't-citefix', 'format citations', '', '');
ohc_regex(/<ref>((?:[^<>]*\|\s*url\s*=|[\[\s]?)https?:\/\/(?:[^|</]+\.)*([-\w]+)(?:\.[a-z]{2,3})\/[^<>|{}\d]*@YYYY[-\/]@MM[-\/]@DD\/(\w+)[^<>]*)(?=<\/ref>)/gi, "<ref name=$2_@Year@ZM@ZD_$3>$1"); //urls with non-date serial numbers
addPortletLink('p-tb', 'javascript:Ohc_publishers()', 'Rem publishers', 't-citefix', 'Removing certain publishers fields', '', '');
ohc_regex(/<ref>((?:[^<>]*\|\s*url\s*=|[\[\s]?)https?:\/\/(?:[^|</]+\.)*([-\w]+)(?:\.[a-z]{2,3})\/[^<>|{}\d]*@YYYY[-\/]@Mon[-\/]@DD\/(\w+)[^<>]*)(?=<\/ref>)/gi, "<ref name=$2_@Year@ZM@ZD_$3>$1"); //urls with non-date serial numbers
// addPortletLink('p-tb', 'javascript:Ohc_sourcename()', 'Align source name', 't-citefix', 'Corrects source name – subscript1', '', '');
 
// addPortletLink('p-tb', 'javascript:Ohc_sourcework()', 'Cleanup WORK', 't-citefix', 'Cleanup and reclassifies as WORK – subscript2', '', '');
ohc_regex(/<ref>([^<>]*\|\s*url\s*=https?:\/\/(?:[^|</]+\.)*(\w+)\.(?:(?:com?|org|net|gov|ac|)(?:\.[a-z]{2}|))\/[^<>]*\|\s*date\s*=\s*@Day @Month @YYYY\s*[|}][^<>]*)(?=<\/ref>)/gi, "<ref name=$2_@Year@ZM@ZD>$1");
// addPortletLink('p-tb', 'javascript:Ohc_sourcepub()', 'Cleanup publisher', 't-citefix', 'Cleanup and reclassifies as PUBLISHER – subscript2', '', '');
ohc_regex(/<ref>([^<>]*\|\s*url\s*=https?:\/\/(?:[^|</]+\.)*(\w+)\.(?:(?:com?|org|net|gov|ac|)(?:\.[a-z]{2}|))\/[^<>]*\|\s*date\s*=\s*@Month @Day, @YYYY\s*[|}][^<>]*)(?=<\/ref>)/gi, "<ref name=$2_@Year@ZM@ZD>$1"); //this line may cause unwarranted substitution of "$5" by a comma (e.g. in 2019–20 Hong Kong protests)
// addPortletLink('p-tb', 'javascript:Ohc_sources_cleanup()', 'Final cleanup', 't-citefix', 'Cleanup after script actions', '', '');
ohc_regex(/<ref>([^<>]*\|\s*url\s*=https?:\/\/(?:[^|</]+\.)*(\w+)\.(?:(?:com?|org|net|gov|ac|)(?:\.[a-z]{2}|))\/[^<>]*\|\s*date\s*=\s*=\s*@YYYY-@MM-@DD\s*[|}][^<>]*)(?=<\/ref>)/gi, "<ref name=$2_@Year@ZM@ZD>$1");
addPortletLink('p-tb', 'javascript:Ohc_sourceunlink()', 'Unlink source name', 't-citefix', 'Unlinks source', '', '');
ohc_regex(/<ref>((?:[^<>]*\|\s*url\s*=|\[?)https?:\/\/(?:[^|<]+\.)*(\w+)\.(?:(?:com?|org|net|gov|ac|[a-z]{2})(?:\.[a-z]{2}|))\/[^<>|{}]+@YYYY[\/-]?@Month[\/-]?@Day[^<>]*)(?=<\/ref>)/gi, "<ref name=$2_@Year@ZM@ZD>$1"); //urls with embedded dates
addPortletLink('p-tb', 'javascript:Ohc_ref_format_new()', 'Fix sources', 't-citefix', 'Run entire new module', '', '');
 
}
});
 
function prevDef ( e ) {
e.preventDefault();
}
 
function addLinks() {
 
var add = function() {
return mw.util.addPortletLink.apply(mw.util, arguments);
};
$( add('p-tb', '#', 'Add REFTAGS', 's-reftags', 'Insert missing ref tags', '', '') ).click(prevDef).click(Ohc_add_ref_tags);
$( add('p-tb', '#', 'CITE name', 's-citename', 'gives names to all citations', '', '') ).click(prevDef).click(ohc_ref_names);
$( add('p-tb', '#', 'Fill DOMAIN_NAME', 's-domainname', 'imports ___domain names to publisher field', '', '') ).click(prevDef).click(Ohc_fill_pub_with_domain);
$( add('p-tb', '#', 'Unlink source name', 's-unlink', 'Unlinks source', '', '') ).click(prevDef).click(Ohc_sourceunlink);
$( add('p-tb', '#', 'Fix SOURCES', 's-citefix', 'Run entire new module', '', '') ).click(prevDef).click(Ohc_ref_format_new);
 
}
 
if( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ){
$.when(
$.ready,
mw.loader.using( 'mediawiki.util' ),
/*************
*** Regex menu framework
*** by [[m:user:Pathoschild]] <http://meta.wikimedia.org/wiki/User:Pathoschild/Scripts/Regex_menu_framework>
*** - adds a sidebar menu of user-defined scripts.
*************/
$.ajax(
'//meta.wikimedia.org/w/index.php?title=User:Pathoschild/Scripts/Regex_menu_framework.js&action=raw&ctype=text/javascript',
{ dataType:'script', cache:true }
)
)
.then( addLinks );
}
// </nowiki>