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

Content deleted Content added
tweak
activate test buttons
 
Line 1:
// <nowiki>
// *********************************************************************************************
 
//This is a test (non-production) script, and may have untested errors. Please exercise due care should you decide to use it.
 
// *********************************************************************************************
/**
* TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor.
* @see https://meta.wikimedia.org/wiki/TemplateScript
* @update-token [[File:pathoschild/templatescript.js]]
*/
mw.loader.load('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js');
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
importScript("User:Ohconfucius/test/Sources_subscript3.js"); //link-fixing, dabbing etc
 
function Ohc_add_ref_tags() {
var txt=document.editform.wpTextbox1;
regex(/([^>\*\s])\s?(\[https?:\/\/[^\s\[\]]*\])(?![ ]*[<\-]+)/gi, '$1<ref>$2</ref>');
/*************
 
*** 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.
function Ohc_fill_pub_with_domain() {
*************/
importScriptURI('http://meta.wikimedia.org/w/index.php?title=User:Pathoschild/Scripts/Regex_menu_framework.js&action=raw&ctype=text/javascript');
function Ohc_linkspam() {
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?[-–]\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');
 
txt.value=txt.value.replace(/([^>\*][ ]*)\[https?:\/\/[^\s\]]*[ ]([\w\d][^\]]*)\]/gi, '$1$2');
}
 
function Ohc_news_sourcesOhc_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
// txt.value=txt.value.replace(/(\n)<(\/references|references\/)>/g, '$1{{reflist}}'); - disabled per false positive at Paul Simenon
//
// txt.value=txt.value.replace(/\{\{[ ]*cite /g, '{{Cite ');
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?<!--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
txt.value=txt.value.replace(/\{\{[i-z]{5}ews(|2|cat|has|portal|table|-inline)(\|[^\}]+|)\}\}\s*/gi, '');
regex(/(\|\s*(?:chapter|journal|magazine|newspaper|publisher|title|work|via)\s*\=\s*)\[https?:\/\/[^\s\]]*\s([\w][^\]]*)\]/gi, '$1$2'); //leave only linked text
txt.value=txt.value.replace(/\*[ ]*\{\{Find a Grave\|\d{4}\|(\|[^\}]+)\}\}\s*/gi, '');
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
//reflinks fixes
regex(/(\|\s*title\s*=\s*)(?:\w+(?:\.(?:com?|net|org|gov|\w{2}))(?:\.\w{2}|))(?:\/[^|}]+)(?:\/[^|}]+)(?:\/[^|}]+)\/([^|}]+)\/?(?=\s*[\]|}])/gi, '$1$2'); //returns terminal part of url
// txt.value=txt.value.replace(/&#\d{2,3}\;/g, ',');
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
//citation template fixes
regex(/<ref[^<>]*>[^<>]*\|[ ]*url ?= ?https?:\/\/\w{2}\.wikipedia\.org\/w[^<>]*<\/ref>/gi, '{{cn}}<!-- WP:RS needed; removed link to WP-->');
txt.value=txt.value.replace(/(?:\|[ ]*(?:first|agency|(?:co|)authors?|archive(?:url|date)|journal|publisher|newspaper|work|(?:access|)date|doi|month|year|___location|format|first|language|last|publisher|authorlink|volume|issue|pages?))[ ]*=[\s]*(\}|\|)/gi, '$1');
regex(/<ref>\s*https?:\/\/\w{2}\.wikipedia\.org\/wiki\/[^\s\]<]*<\/ref>/gi, '{{cn}}<!-- WP:RS needed; removed link to WP-->');
txt.value=txt.value.replace(/(?:\|[ ]*(?:first|agency|(?:co|)authors?|archive(?:url|date)|journal|publisher|newspaper|work|(?:access|)date|doi|month|year|___location|format|first|language|last|publisher|authorlink|volume|issue|pages?))[ ]*=[\s]*(\}|\|)/gi, '$1'); //repeat to catch neighbouring blank adjacent params
regex(/<ref>\s*\[https?:\/\/\w{2}\.wikipedia\.org\/w[^\s\]]*[ ]+[\w\d][^\]]*\]<\/ref>/gi, '{{cn}}<!-- WP:RS needed; removed link to WP-->');
txt.value=txt.value.replace(/(\|[ ]*(?:agency|author|journal|publisher|newspaper|work))[ ]*=[ ]*/gi, '$1=');
regex(/<ref(?: name=[^<>]|)>[^<>]*\|\s*url[ ]*=[ ]*https?:\/\/\w{2}\.wikipedia\.org\/w[^\s\|\{\}<]*[^<>]*<\/ref>/gi, '{{cn}}<!-- WP:RS needed; removed link to WP-->');
txt.value=txt.value.replace(/(?:\|\s?publisher\s?\=\s?\'\'\[\[([^\]]{1,40})\]\]\'\')/gi, '|work=[[$1]]');
txt.value=txt.value.replace regex(/(\[https?:\|/\s?publisher/\s?w{2}\=.wikipedia\s?.org\'/w[^\'s\]]*[ ]+([\w][^\]]{1,40}*)\'\')]/gi, '|work= [[$1]]');
 
//deprecated sources
txt.value=txt.value.replace(/\[\[Time\s\(magazine\)\|(Time|Time Magazine)\]\]/g, 'Time');
regex(/<ref[^<>]*>[^<>]*\|[ ]*url ?= ?https?:\/\/(?:(?:\w+\.|)((?:the|)epochtimes|ntdtv)\.com)\/[^<>{]*<\/ref>/gi, '<!--rem deprecated source \($1\)-->');
txt.value=txt.value.replace(/\[\[Billboard\s\(magazine\)\|(Billboard|Billboard Magazine)\]\]/g, '$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
//returns 'work=' for traditional media with websites
txt.value=txt.value.replace regex(/(?:\|\s?(work|publisher)*url\s?*\=\s*)(https?\:[?^|{}#\[?(wireds]+\.comhtml?)\]?\[^|}]?){1,5}(?=[\s]*\[\]|\{}<>])/gi, '|work=Wired $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
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?(flightglobal\.com|Flight Global)\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Flight International ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?playbill.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Playbill ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?(variety.com|Variety \(magazine\)\|Variety)\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Variety ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?(vogue.com|Vogue \(magazine\)\|Vogue)\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Variety ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?(vanityfair.com|Vanity Fair \(magazine\)\|Vanity Fair)\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Vanity Fair ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?empireonline.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Empire ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?nme\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=NME |___location=UK ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?qthemusic\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Q |___location=UK ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?billboard\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Billboard ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?rollingstone.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Rolling Stone ');
 
}
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?abc\.(com\.au|net(?:\.au|))\]?\]?)(?=[\s]*[\|\}])/gi, '|publisher=Australian Broadcasting Corporation ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?abc\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|publisher=American Broadcasting Company ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?cbc\.ca\]?\]?)(?=[\s]*[\|\}])/gi, '|publisher=Canadian Broadcasting Corporation ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?boston.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Boston Globe ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?businessweek\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Bloomberg BusinessWeek ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?chicagotribune\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work= Chicago Tribune ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?chinadaily\.com\.cn\]?\]?)(?=[\s]*[\|\}])/gi, '|work=China Daily ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?chinatimes\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=China Times |___location=Taiwan (ROC) ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?libertytimes\.com\.tw\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Liberty Times |___location=Taiwan (ROC) ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?taipeitimes\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Taipei Times |___location=Taiwan (ROC) ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?udn\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=United Daily News |___location=Taiwan (ROC) ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?people(?:daily|)\.com\.cn\]?\]?)(?=[\s]*[\|\}])/gi, '|work=People\'s Daily ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?straitstimes\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Straits Times |___location=Singapore ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?chron\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Houston Chronicle ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?(dailymail.co\.uk|Mail Online)\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Daily Mail |___location=UK');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?(mirror.co\.uk)\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Daily Mirror |___location=UK');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?denverpost\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Denver Post');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?((?:der|)spiegel\.de|spiegel online)\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Der Spiegel ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?((?:die|)welt\.de|welt online)\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Die Welt ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?economist\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Economist ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?[^\[\|]{0,10}\.ew.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Entertainment Weekly ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?[^\[\|]{0,10}forbes\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Forbes');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?radiotimes\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Radio Times ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?ft.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Financial Times ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?Guardian(\.co\.uk|\sUnlimited)\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Guardian |___location=UK');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?(Hello|OK)magazine\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=$2! ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?iht\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=International Herald Tribune');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?[^\[]{0,7}independent\.co\.uk\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Independent |___location=UK');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?independent\.ie\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Irish Independent ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?irishtimes\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Irish Times ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?[^\[]{0,7}latimes\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Los Angeles Times ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?lefigaro\.fr\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Le Figaro |___location=France');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?lemonde\.fr\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Le Monde |___location=France');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?liberation.fr\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Libération |___location=France');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?La-Croix\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=La Croix |___location=France');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?LeParisien\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Le Parisien |___location=France');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?LaTribune\.fr\]?\]?)(?=[\s]*[\|\}])/gi, '|work=La Tribune |___location=France');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?Lesechos\.fr\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Les Échos |___location=France');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?FranceSoir\.fr\]?\]?)(?=[\s]*[\|\}])/gi, '|work=France Soir |___location=France');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?20Minutes\.fr\]?\]?)(?=[\s]*[\|\}])/gi, '|work=20 Minutes |___location=France');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?Lequipe\.fr\]?\]?)(?=[\s]*[\|\}])/gi, '|work=L\'Équipe |___location=France');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?Canardenchaîne\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Le Canard Enchaîné |___location=France');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?NouvelObs\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Le Nouvel Observateur |___location=France');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?Lexpress\.fr\]?\]?)(?=[\s]*[\|\}])/gi, '|work=L\'Express |___location=France');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?LePoint\.fr\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Le Point |___location=France');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?marianne-en-ligne\.fr\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Marianne |___location=France');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?parismatch\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Paris-Match |___location=France');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?Telerama\.fr\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Télérama |___location=France');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?Courrierinternational\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Courrier International |___location=France');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?minute-hebdo\.fr\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Minute |___location=France');
 
function Ohc_sources_prep() {
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?asahi\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Asahi Shimbun |___location=Japan');
var txt=document.editform.wpTextbox1;
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?yomiuri\.co\.jp\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Yomiuri Shimbun |___location=Japan');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?[^\[\|]{0,10}japantimes\.co\.jp\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Japan Times ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?haaretz\.?(?:com|co\.il)\]?\]?)/gi, '|work=Haaretz |___location=Israel');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?thejakartapost\.(?:com|)\]?\]?)/gi, '|work=The Jakarta Post ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?thejakartaglobe\.(?:com|)\]?\]?)/gi, '|work=Jakarta Globe ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?jpost\.(com|co\.il)\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Jerusalem Post ');
 
// removing artefacts within fields
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?Telegraphindia.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Telegraph |___location=Kolkota, India');
txt.value=txt.value.replace regex(/(?:\|\s?(work|publisher)*author\s?*\=\s*)(?\[:by |)(?\:[^|]+staff|(?Times:staff |)(?of :reporter|writer)s?india(\.com|)[\]?s\n]?)*(?=[\s]*[\|\}])/gi, '|work=The Times of India');
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(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?Hindustan ?times(\.com|)\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Hindustan Times |___location=India');
regex(/\|[ ]*last=(Reporter|staff)[ ]*\|[ ]*first=[^|\{\}]*(?=[\|{}])/gi, '');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?express(?:india\.com| online)\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Indian Express ');
regex(/\|[ ]*(?:first|last)=(?:staff |)(?:reporter|writer)[ ]*(?=[\|{}])/gi, '');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?financialexpress(?:\.com|)\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Financial Express ');
regex(/\|[ ]*first= ?staff ?\|[ ]*last=(?:reporter|writer)[ ]*(?=[\|{}])/gi, '');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?(?:the)?hindu.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Hindu |___location=India');
regex(/\|[ ]*first= ?The ?\|[ ]*last=[^\|{}]*(?=[\|{}])/gi, '');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?deccanchronicle.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Deccan Chronicle |___location=India');
regex(/(\|\s*access-?date\s*\=\s*)(?:accessed|retrieved)(?: by| on|):?[ ]*(\d)/gi, '$1$2');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?Thestatesman.net\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Statesman |___location=India');
txt.value=txt.value.replace regex(/(?:\|\s*access-?(work|publisher)date\s?*\=\s?*\[?d{4}\[?dailypioneer.com\]?\]s?)(?=[\s]*[\|\}])/gi, '|work=The Pioneer |___location=India');
regex(/(\|\s*work\s*\=\s*)(?:article|interview|review) ?(?=[|}])/gi, '$1');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?EconomicTimes.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Economic Times |___location=India');
txt.value=txt.value.replace regex(/(?:\|\s?(work|publisher)*volume\s?*\=\s*)vol(?:ume|\[?\[?tribuneindia.com\]?\]?)(?=[\s ]*[(\|\}]d)/gi, '|work=The Tribune |___location=India$1$2');
txt.value=txt.value.replace regex(/(?:\|\s*pages?(work|publisher)\s?*\=\s*)(?\[:pages?\|p[?IndianExpress.com\gp]?\].?)(?=[\s ]*[(\|\}]d)/gi, '|work=The Indian Express |___location=India$1$2');
regex(/ [-–] (?:每日明報 daily news|東方日報)/gi, '');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?deccanherald.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Deccan Herald |___location=India');
regex(/(\.\.\. |)\{\{!\}\} 立場(報道|新聞)/gi, '');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?Expressbuzz.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The New Indian Express |___location=India');
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');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?blesk.cz\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Blesk |___location=Czech Republic');
txt.value=txt.value.replace regex(/(?:\|\s*)(?(:publisher|website|work|publisher)\s?\=\s(Amazon)(?:\[.com|)(?:\[?ihned.cz\]?\]?w{2}|)(?=[\s]*[\|\}])/gi, '|work$1via=Hospodářské noviny |___location=Czech Republic$2');
txt.value=txt.value.replace regex(/(?:\|\s?*)(work|?:publisher|website|work)=(\s?[\=[Twitter\s|𝕏\]\])(?: *\[(Formerly (?:Twitter|\[?lidovky.cz\[Twitter\]?\]?\)) *|)(?=[\s]*[\|\}])/gi, '|work$1via=Lidové noviny |___location=Czech Republic$2');
txt.value=txt.value.replace regex(/(?:\|\s?(work|*publisher=)\|\s?via\s*\=\s?*(\[?\[?idnes.cz\]?\]?w+)(?=[\s]*[\|\}])/gi, '|work=Mladá fronta DNES |___location=Czech Republic$1$2');
txt.value=txt.value.replace regex(/(?:-[ ]*Google Books[ ]*(?:\|[^}]*|)|)\|\s?(work|publisher)\s?*\=\s?\[?\[?pravo.novinky.cz\]?\]?*(Google Books)(?=[\s\.]*[\|\}])/gig, '|workvia=Právo |___location=Czech Republic$1');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?praguepost.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Prague Post |___location=Czech Republic');
 
//Remove COinS corrupting templates from CS1 citations
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?mingpao.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Ming Pao |___location=Hong Kong');
txt.value=txt.value.replace regex(/(\|\s*(?:authors?|first\d?|last\sd?(work|publisher|work)\s?*\=\s*(?\:[^{}|]*|)){{(?\:Sm|Aut|SC|Small[?newsday\.com\- ]caps|Sm?caps)\|([^{}|]?*)}}(?=(?:[\s^{}|]*|)[\|\}])/gi, '|work=Newsday |___location=New York $1');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?newsweek\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Newsweek ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?nydailynews\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Daily News |___location=New York ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?nypost.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=New York Post ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?[\b\.]{0,20}nytimes.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The New York Times ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?people.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=People ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?scmp.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=South China Morning Post |___location=Hong Kong');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?sfgate.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=San Francisco Chronicle ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?smh\.com\.au\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Sydney Morning Herald ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?spectator\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Spectator |___location=UK ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?[^\[]{0,10}scotsman\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Scotsman |___location=UK ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?thisislondon\.co\.uk\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Evening Standard |___location=UK ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?sportsIllustrated\.cnn\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Sports Illustrated ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?standard\.com\.hk\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Standard |___location=Hong Kong ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?thesun.co\.uk\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Sun |___location=UK');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?suntimes\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Chicago Sun-Times ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?telegraph\.co\.uk\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Daily Telegraph |___location=UK');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?dailytelegraph\.com\.au\]?\]?)/gi, '|work=The Daily Telegraph |___location=Australia');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?theage\.com\.au\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Age |___location=Australia');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?theaustralian\.com\.au\]?\]?)/gi, '|work=The Australian ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?stuff\.co\.nz\]?\]?)/gi, '|work=Stuff |___location=New Zealand ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?nzherald\.co\.nz\]?\]?)/gi, '|work=The New Zealand Herald');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?theglobeandmail\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Globe and Mail |___location=Canada ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?nationalpost\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=National Post |___location=Canada ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?vancouversun\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Vancouver Sun ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?thestar\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Toronto Star ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?torontosun\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Toronto Sun ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?time.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Time ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?(Timesonline\.co(?:\.uk|m)|Times ?online)\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Times |___location=UK');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?[^\[]{0,10}usatoday\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=USA Today ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?washingtonpost\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Washington Post ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?washingtontimes\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Washington Times ');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?[^\[]{0,10}wsj\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=The Wall Street Journal ');
 
txt.value=txt.value.replace regex(/(?:\|\s?(work|publisher*)\s?w+\=(url\s?*\[?=\[s*https?[^:\[]{0,10}un/\.org\]?\]?/)(?=[\s]*[\|\}])/gi, '|publisher=United Nations $1$2'); //common cs1 error
regex(/(\|\s*url\s*\=)(www\.)(?=[|}])/gi, '$1http//$2'); //common cs1 error
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, '');
//returns 'work=' for traditional media; delinks and dabs ___location
txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?\[\[((?:the |)(Globe and Mail|National Post|Vancouver Sun|Le Devoir|Le Droit))\]\])(?=[\s]*[\|\}])/gi, '|work=$1 |___location=Canada ');
txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?\[\[(the )?((Sunday )?Times|Daily (Mail|Mirror|Express)|Independent|Observer|Guardian|NME|New Musical Express|New Statesman|Scotsman|Spectator|Daily Telegraph)\]\])(?=[\s]*[\|\}])/gi, '|work=$1$2 |___location=UK');
txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?\[\[(?:The Sun|Daily Star) \((?:United Kingdom|newspaper)\)\|(The Sun|Daily Star)\]\])(?=[\s]*[\|\}])/gi, '|work=$1 |___location=UK ');
txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?\[\[(apple daily|ming pao|The standard|south china morning post)\]\])(?=[\s]*[\|\}])/gi, '|work=$1 |___location=Hong Kong');
txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?\[\[The standard\|[^\]]*\]\])(?=[\s]*[\|\}])/gi, '|work=The Standard |___location=Hong Kong ');
txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?\[\[(The Age|Herald Sun)\]\])(?=[\s]*[\|\}])/gi, '|work=$1 |___location=Australia');
txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?\[\[(Asahi Shimbun|Yomiuri Shimbun)\]\])(?=[\s]*[\|\}])/gi, '|work=$1 |___location=Japan');
txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?\[\[(?:the |)(Irish |Japan |Taipei |Taiwan )Times\]\])(?=[\s]*[\|\}])/gi, '|work=The $1Times ');
txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?\[\[(La Croix|Le Figaro|L'Humanité|Libération|Le Monde|Le Parisien|La Tribune|France Soir|Direct Matin|Direct Soir|L'Équipe|Le Canard enchaîné|Le Nouvel Observateur|L'Express|Le Point|Paris-Match|Télérama|Courrier International)\]\])(?=[\s]*[\|\}])/gi, '|work=$1 |___location=France');
txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?\[\[(Avvenire|Corriere della Sera|Il Fatto Quotidiano|Il Foglio|il Giornale|Il Giorno|il manifesto|Il Mattino|Il Messaggero|il Resto del Carlino|il Riformista|Il Secolo XIX|Il Tempo|La Nazione|la Repubblica|La Stampa|L'espresso|Corriere del Mezzogiorno)\]\])(?=[\s]*[\|\}])/gi, '|work=$1 |___location=Italy');
txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?\[\[(The |)(Times of India|Hindustan Times|Hindu|Deccan Chronicle|Statesman|Daily News and Analysis|Economic Times|Tribune|Indian Express|Deccan Herald|New Indian Express|Asian Age)\]\])(?=[\s]*[\|\}])/gi, '|work=$1$2 |___location=India');
txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?)(?:\[\[The Telegraph \(Kolkata\)\|(The Telegraph)\]\])(?=[\s]*[\|\}])/gi, '|work=$1 |___location=Kolkota, India ');
txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?)(?:\[\[The Pioneer \(Indian newspaper\)\|(The Pioneer)\]\])(?=[\s]*[\|\}])/gi, '|work=$1 |___location=India ');
txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?\[\[(?:The |)((?:Indian|Financial) Express)\]\])(?=[\s]*[\|\}])/gi, '|work=The $1 ');
txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?\[\[(Blesk|Hospodářské noviny|Lidové noviny|Mladá fronta DNES|Právo|(?:The |)Prague Post)\]\])(?=[\s]*[\|\}])/gi, '|work=$1 |___location=Czech Republic');
 
//citation template fixes
txt.value=txt.value.replace(/(?:\|\s?publisher\s?\=\s?(the |)((sunday )?Times|daily (mail|mirror|express)|(?:London |)Evening Standard|independent|observer|guardian|NME|New Musical Express|New Statesman|Scotsman|Spectator|Daily Telegraph))(?=[\s]*[\|\}])/gi, '|work=$1$2 |___location=UK |');
// 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$2');
 
// rem toggles and redundant quote marks
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?(?:the |)jakarta post\]?\]?)/gi, '|work=The Jakarta Post ');
txt.value=txt.value.replace regex(/(?:\|\s?*(?:agency|author|newspaper|work|journal|publisher|title)\s?*\=\s?*)\[?'\[?'(?:the [^|}]+)jakarta globe\]'\'(?=\s*[\}\|]?)/gi, '|work=Jakarta Globe $1$2'); //without link
txt.value=txt.value.replace regex(/(?:\|\s?*(?:agency|author|newspaper|work|journal|publisher|title)\s?*\=\s?*)\'\'(\[\[(?:The [^\|]+\||)Straits Times[^\|\]]+\]\])\'\'(?=[\s]*[\}\|\}])/gi, '|work=Straits Times |___location=Singapore $1$2'); //with link
regex(/(\|\s*title\s*\=\s*)\'&#39;([^\|\{\}]+)\'&#39;/gi, '$1$2'); //rem &#39; in titles
txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?\[\[(China Times|Liberty Times|(?:The |)China Post|United Daily News)\]\])(?=[\s]*[\|\}])/gi, '|work=$1 |___location=Taiwan (ROC)');
regex(/(\|\s*publisher\s*\=\s*)\(([^\|\{\}]+)\)/gi, '$1$2'); //rem parenthetical publishers
txt.value=txt.value.replace(/(?:\|\s?publisher\s?\=\s?(apple daily|ming pao|(?:The |Hong Kong |hk ?)standard|south china morning post))(?=[\s]*[\|\}])/gi, '|work=$1 |___location=Hong Kong |');
txt.value=txt.value.replace regex(/(?:\|\s?*publisher\s?*\=\s?*)\"([\[The standard^\|hk standard\]{\}]+)(?=[\s]*[\|\}])"/gi, '|work=The$1$2'); Standard//rem |___location=Hongquote Kongmarks ');around publishers
txt.value=txt.value.replace(/(?:\|\s?publisher\s?\=\s?the age)(?=[\s]*[\|\}])/gi, '|work=The Age |___location=Australia');
txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[?\[?(?:nz |new zealand )herald\]?\]?)/gi, '|work=The New Zealand Herald');
 
// reordering 'work' and 'publisher' (first run - see second run in cleanup function)
//returns 'work=' for traditional media not requiring ___location dab
regex(/(\|\s*publisher\s*\=\s*(?:\[\[[^<{}\]]*\]\]|[^{}\|\}<>]*))(\s?\|[^}<>]*|)(\|\s*(?: journal|newspaper|magazine|periodical|website|work)\s*\=\s*(?:\[\[[^<{}\]]*\]\]|[^{}\|\}<>]*))(?=[\s\.]*[|}])/g, '$3$1$2');
txt.value=txt.value.replace(/(?:\|\s?(?:publisher|work)\s?\=\s?\[\[(the )?(Billboard|Billboard Magazine|boston globe|chicago tribune|china daily|people.s daily|Houston chronicle|denver post|der spiegel|The economist|Entertainment Weekly|forbes(?:\smagazine|)|Financial Times|FT|(?:The |)Globe and Mail|(?:The |)Vancouver Sun|Guardian|Hello!|International Herald Tribune|iht|(?:los angeles|la) times|le figaro|le monde|lib[ée]ration|mojo|newsday|newsweek|nydailynews|new york(?: daily news| Post| Times|er)|Q magazine|rolling\sstone|scmp|south china morning post|(?:San Francisco|sf) Chronicle|Sports Illustrated|Sydney Morning Herald|smh|Chicago Sun.Times|the australian|Ottawa Citizen|Ottawa Sun|toronto (?:star|sun)|time magazine|time|usa today|washington (?:post|times)|Wall Street Journal)\]\])(?=[\s]*[\|\}])/gi, '|work=$1$2');
txt.value=txt.value.replace regex(/(?:\|\s?(?:work|publisher)*website\s?*\=\s?*(?:\[\[[^<{}\]]*\]\]|[^{}\|\}<>]*))(\s?\|[^}<>]*|)(\|\s*(?:bloomberg journal|newspaper|magazine|periodical|work)business\s?week)*\=\s*(?:\[\[[^<{}\]]*\]\]|[^{}\|\}<>]*)?)(?=[\s\.]*[\|\}])/gig, '|work=$3$1 $2');
 
/// removing identical/similar entries in 'work' and 'publisher', and in 'work' and 'website' (different default vs [post] cleanup rules)
txt.value=txt.value.replace(/(?:\|\s?(?:publisher)\s?\=\s?(the |)(Billboard|Billboard Magazine|boston globe|chicago tribune|china daily|people.s daily|Houston chronicle|denver post|der spiegel|The economist|Entertainment Weekly|forbes(?:\smagazine|)|Financial Times|FT|(?:The |)Globe and Mail|(?:The |)Vancouver Sun|(?:The |)Guardian|Hello!|International Herald Tribune|iht|(?:los angeles|la) times|le figaro|le monde|lib[ée]ration|mojo|newsday|newsweek|nydailynews|new york(?: daily news| Post| Times|er)|Q magazine|rolling\sstone|scmp|south china morning post|(?:San Francisco|sf) Chronicle|Sports Illustrated|Sydney Morning Herald|smh|Chicago Sun.Times|the australian|Ottawa Citizen|Ottawa Sun|toronto (?:star|sun)|time magazine|time|usa today|washington (?:post|times)|Wall Street Journal))(?=[\s]*[\|\}])/gi, '|work=$1$2');
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
//returns 'publisher=' for new media news magazines
txt.value=txt.value.replace regex(/(?:\|\s?publisher\s*\=\s*\[\[(?:newspaper[^<|work\]]*)\]\](\|[^}<>]*|publisher)\|\s?publisher\s*\=\s?*(?:\1|\[\[)?(Huffington Post)(?:\1\]\])\.?)(?=[\s]*[\|\}])/gig, '|workpublisher=$1 |___location=USA$2'); //unpiped work
txt.value=txt.value.replace regex(/(?:\|\s?(?:newspaper|work|publisher)\s?*\=\s?*(?:\[\[)?(Digitalspy.co.uk)(?:[^<|\]]*)\|([^}<>]*)?\]\])(\|[^}<>]*|)\|\s?publisher\s*\=[\s]*[(\1|\2)\.?(?=\s*[|}])/gig, '|workpublisher=Digital Spy |___location=UK$1$2'); //piped work
 
// remove redundant parentheses and templates from dm and md dates (equivalents also exists in Mosnum script)
//returns 'publisher=' for electronic media
regex(/(=[ ]*)\(([^()|{}])\)/gi, '$1$2');
txt.value=txt.value.replace(/(?:\|\s?(?:newspaper|work|publisher)\s?\=\s?(?:\[\[)?(bbc.co.uk)(?:\]\])?)(?=[\s]*[\|\}])/gi, '|publisher=BBC');
// txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?\[?\[?[^\[]{0,10}(bbc\.co\.uk)\]?\]?)(?=[\s]*[\|\}])/gi, '|publisher=BBC ');
txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?(?:\[\[)(bbc( sports?| news(?: online|)|))(?:\]\]))(?=[\s]*[\|\}])/gi, '|$1=$2 ');
txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?(bbc( sports?| news(?: online|)|)))(?=[\s]*[\|\}])/gi, '|$1=$2 ');
txt.value=txt.value.replace(/(=[ ]?BBC News)( online|\.com)(?=[\s]*[\|\}])/gi, '$1');
txt.value=txt.value.replace(/(?:\|\s?(?:newspaper|publisher|work)\s?\=\[\[(Al\sjazeera( English)?|AMG|All\s?Music\s?Guide|Allmusic|Amazon\.com|(?:American|Australian|Canadian|British) Broadcasting Corporation|Bloomberg|Cable News Network|cnn|Fox News|Fox News Channel|Google|MSN|MTV|Myspace|mlb\.com|xinhua( news agency)?|Yahoo!?|You\s?Tube)\]\])(?=[\s]*[\|\}])/gi, '|publisher=$1');
txt.value=txt.value.replace(/(?:\|\s?(?:work|newspaper)\s?\=(Al\sjazeera( English)?|AMG|All\s?Music\s?Guide|Allmusic|Amazon\.com|(?:American|Australian|Canadian|British) Broadcasting Corporation|Bloomberg[ ]*\||Cable News Network|cnn|Fox News|Fox News Channel|Google|MSN|MTV|Myspace|mlb\.com|VH1|xinhua( news agency)?|Yahoo!?|You\s?Tube))(?=[\s]*[\|\}])/gi, '|publisher=$1');
 
// rem corporate designation
//Television media and networks
txt.value=txt.value.replaceregex(/(?:\|\s?*(?:author|publisher|stationwork)\s?*\=\s*[^\[(BBC|}]{1,40}),? (?:OneInc|TwoLL[CP]|ThreeLtd|FourLimited|FivePLC|Six)SA|Channel(?:Snd\. [45]|)\]\]Berhad)\.?(?=[\s ]*[\|\}])/gi, '|$1=$2 |___location=UK');
txt.value=txt.value.replace(/(?:\|\s?(publisher|station)\s?\=\[\[(?:Channel Five \(UK\)\||)(Channel Five|Channel 5)\]\])(?=[\s]*[\|\}])/gi, '|$1=Channel 5 |___location=UK');
txt.value=txt.value.replace(/(?:\|\s?(publisher|station)\s?\=\[\[(Network Ten)\]\])(?=[\s]*[\|\}])/gi, '|$1=$2 |___location=Australia');
txt.value=txt.value.replace(/(?:\|\s?(publisher|station)\s?\=\[\[(?:Ten|Eleven) \(TV channel\)\|(Ten|Eleven)\]\])(?=[\s]*[\|\}])/gi, '|$1=$2 |___location=Australia');
 
// correcting yahoo! corporate designation
//returns 'publisher=' for electronic media stripped of ___domain suffices
txt.value=txt.value.replaceregex(/(?:\|\s?*(newspaper?:publisher|work|publisher)\s?*\=\s*Yahoo)(?\[?\[?ap\.org\]?\]?: |)(Finance|Green|Kids|Music|News|)(?=[\s ]*[\|\}])/gi, '|agency=Associated Press$1! $2');
txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?\[?\[?afp\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|agency=Agence France-Presse ');
txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?\[?\[?reuters\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|agency=Reuters ');
txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?\[?\[?kyodonews\.jp\]?\]?)(?=[\s]*[\|\}])/gi, '|agency=Kyodo News ');
txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?\[?\[?xinhuanet\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|agency=Xinhua News Agency ');
txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?\[?\[?aljazeera\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|publisher=Aljazeera');
txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?\[?\[?bloomberg\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|publisher=Bloomberg ');
txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?\[?\[?[^\[]{0,10}cnn\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|publisher=CNN ');
txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?\[?\[?[^\[]{0,10}espn(\.go)?.com\]?\]?)(?=[\s]*[\|\}])/gi, '|publisher=ESPN ');
txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?\[?\[?foxnews\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|publisher=Fox News');
txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?\[?\[?huffingtonpost\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=Huffington Post ');
txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?\[?\[?msnbc\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|publisher=MSNBC');
txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?\[?\[?books.google\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|publisher=Google Books');
txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?\[?\[?[^\[]{0,10}google\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|publisher=Google ');
 
// rem unnecessary quote marks
txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?\[?\[?(mtv|twitter|vh1|youtube)\.com\]?\]?)(?=[\s]*[\|\}])/gi, '|work=\'\'$2\'\'');
txt.value=txt.value.replaceregex(/(?:\|\s?(newspaper|work|publisher)*title\s?*\=\s?\*)[?\[?"“]((?:[^\w|]*\.|+)Europa\.eu|Europa \(web portal\)\|Europa)\["”]?\]?)(?=[\s]*?[\|\}])/gi, '|work=\'\'Europa (web portal)\'\'$1$2');
regex(/(\|\s*title\s*\=\s*)['‘]([^\|'’]+)['’](?=\s?[|}])/gi, '$1$2');
// repl double 'in-title' quote marks with single quotes
regex(/(\|\s*title\s*\=\s*[\w ]* )["“]((?:\w[\w]* )+(?:\w[\w]*))["”]([^\|]+|)(?=\s?[|}])/gi, '$1\'$2\'$3');
 
// adjust for possibly incorrectly input title
txt.value=txt.value.replace(/(?:\|\s?(?:newspaper|publisher|work)\s?\=\s?(?:\[\[|)(AF?P\b|Associated Press|Agence France-Presse|Kyodo ?News|Reuters)(?:\]\]|))(?=[\s]*[\|\}])/g, '|agency=$1 ');
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
txt.value=txt.value.replace(/\[\[(ABC|AP|AFP)\]\]/g, '$1');
// rem misplaced punctuation
regex(/(<ref[^>]*>[^<]+?[\]\.\},;–]\s*\'\'[\w-]*(?: [\w-]*){0,3})(\.com|)([;,\.])(\'\')(?=[^<]*?<\/ref>)/gi, '$1$2$4$3');
regex(/([\w]+)\.(['"]\])[ ]/gi, '$1$2. '); //LQ for titles
 
// removing redundanciesblank 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, '');
txt.value=txt.value.replace(/\|\s?___location\s?\=\s?(?:London|UK)\s?(\|[^}]*|)\|\s?___location\s?\=\s?(?:London|UK)/g, '|___location=UK $1');
txt.value=txt.value.replace regex(/(\|\s?___location*work\s?\=\s?USA)\s?([\|[^}iTunes\]*|)\|] Archive\s?___location\s?\=\s?USA/ggi, '|___locationpublisher=USA $1[[iTunes]]');
 
txt.value=txt.value.replace(/\|\s?___location\s?\=\s?New York(?: City|)\s?(\|[^}]*|)\|\s?___location\s?\=\s?(New York(?: City|)|USA)(?=[\s]*[\|\}])/g, '|___location=New York $1');
//rem underlining within certain fields
// txt.value=txt.value.replace(/\|\s?language\s?\=\s?English/gi, ''); //false positive in infoboxes for books
regex(/(\|\s*(?:journal|newspaper|periodical|publisher|work)\s*\=\s*)<u>([^|}]+)<\/u>/gi, '$1$2');
txt.value=txt.value.replace(/- [\w]*\.com[ ]*\|/gi, '|');
 
//rem redundant top-level domains (.com, .net, .org), strip "www"
regex(/(\|\s*(?:journal|newspaper|periodical|publisher|work)\s*\=\s*)(\[\[[^\[\]\}]*\]\])\.(?:biz|com|net|org|co\.uk|(?:com\.|)[a-z]{2})(?=\s*[|}])/gi, '$1$2');
 
//rem duplicated publishers in separate fields (pre)
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');
 
//'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');
 
// 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|archive-?date|access-?date|author)[ ]*=[ ]*)(?:(?:Mon|Tues?|Wed|Thur?|Fri|Sat|Sun)(?:[\.,]|day)?)\s/gi, "$1");
 
//'Accessed'/'Obtained' -> 'Retrieved'
txt.value=txt.value.replace(/\|\s?publisher\s?\=\s?(?:BBC|BBC News(?: Online|))\s?(\|[^}]*|)\|\s?publisher\s?\=\s?(?:BBC|BBC News(?: Online|)|British Broadcasting Corporation)(?=[\s]*[\|\}])/g, '|publisher=BBC News $1');
ohc_regex(/(?:[\.,;][ ]*(?:url |link |last |)(?:Retrieved|Accessed|Obtained))(?: on(?:line|)|):? (@month|@dd|@yyyy)(?=\D)/gi, '. Retrieved $1');
txt.value=txt.value.replace(/\|\s?publisher\s?\=\s?CNN\s?(\|[^}]*|)\|\s?publisher\s?\=\s?CNN(?=[\s]*[\|\}])/g, '|publisher=CNN $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');
// removing external links within publisher/journal/work fields
ohc_regex(/(\w|\])[\.,;]?[ ]\((Retrieved (?:@Month\s@DD,\s@YYYY|@DD\s@Month\s@YYYY|@yyyy-@mm-@dd))\)/gi, '$1. $2');
txt.value=txt.value.replace(/(\|\s?(?:newspaper|work|journal|publisher)\s?\=\s?)\[https?:\/\/[^\s\]]*[ ]([\w\d][^\]]*)\]/gi, '$1$2');
 
}
 
function Ohc_dab_news_sources() {
var txt=document.editform.wpTextbox1;
 
//pre-dab of piped sources
// 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)');
regex(/(\[\[)Daily Star \((?:British|UK)\)(?=\|)/gi, '$1Daily Star (United Kingdom)');
regex(/(\[\[Metro)(?: \(Associated Metro Limited\)| \(Associated Newspapers\)| \(London newspaper\)| \(free London newspaper\)| UK| newspaper London| newspaper UK)(?=\|)/gi, '$1 (British newspaper)');
regex(/(\[\[)(?:Calcutta Telegraph|The Telegraph \((?:Calcutta|India)\)|(?:The |)Telegraph India|Telegraphindia\.com)(?=\|)/gi, '$1The Telegraph (Kolkata)');
regex(/(\[\[)Dawn(?:, Karachi| newspaper|\.com| \((?:Newspaper|Pakistan)\))(?=\|)/gi, '$1Dawn (newspaper)');
regex(/(\[\[The Pioneer)(?:, Karachi| newspaper| \((?:indian newspaper)\))(?=\|)/gi, '$1 (Indian newspaper)');
regex(/(\[\[)dailypioneer.com(?=\|)/gi, '$1The Pioneer (Indian newspaper)');
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');
 
//unwinding of unnecessary pipes
regex(/\[\[Public Broadcasting Service\|(PBS\]\])/gi, '[[$1');
 
}
Line 265 ⟶ 242:
 
//linked publishing houses
// removing publishers less well-known than their titles
txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?\[?\[?Hachette Filipacchi Médias\|(Hachette Filipacchi) \(UK\) Ltd\]?\]?)(?=[\s]*[\|\}])/gi, '');
regex(/(\|\s*publisher\s?\=MTV\|\s?)publisher\s*\=\s*(?:MTV Networks(?: \(Viacom\)|)|Viacom)/gi, '$1=');
txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?\[?\[?(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é Nast Publications|Fairfax Media|Gannett Company|(Guardian|Telegraph) Media Group|(?:Guardian|Independent) News (?:and|&) Media|Imdb Inc\.?|IDG|IPC Media|MTV Networks|(The |)(?:Washington Post|(?:New York|Seattle) Times) Company|News (?:Corporation|International|Limited)|Prometheus Global Media|Tribune Company|Trinity Mirror|Times Newspapers (?:Limited|Ltd.?)|Nielsen (?: Media Research|Business Media(, Inc\.?|))|Rovi Corporation|Viacom|Time (?:Warner ?|)Inc\.?)(\]\]|))(?=[\s]*[\|\}])/gi, '');
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
regex(/\|publisher=\[\[(?:PMC \(company\)\||)(?:PMC|Penske Media Corporation)\]\](?=[\s\.]*[|}])/gi, '');
regex(/(?:\|\s?(newspaper|work|publisher)\s*\=\s*\[?\[?(?:Hachette Filipacchi Médias\||)Hachette Filipacchi(?: \(UK\) Ltd.?| UK|)\]?\]?)(?=[\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, '');
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(/\| ?publisher ?= ?(?:Fandango Media|\[\[Fandango Media\]\]) ?/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
 
}
 
function Ohc_sources_cleanup() {
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)
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(/(=[ ]*The Advertiser) \((Adelaide)\)([ ]*[|}])/g, '$1|___location=$2$3');
regex(/(''The Advertiser) \((Adelaide)\)('')/g, '$1$3 ($2)');
regex(/(\|)(The Advertiser)(?: \((Adelaide)\))(\]\])/g, '$1$2$4|___location=$3');
regex(/(\[\[)(The Advertiser)( \((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(/('')(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(/(\[\[(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(/(\|)(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(/(=[ ]*)(Empire) \((?:film magazine)\)(?=\s*[|}])/g, '$1$2'); //non-standard code
regex(/('')(Empire) \(film magazine\)(?='')/g, '$1$2'); //non-standard code
regex(/(''\[\[(Empire) \(film magazine\))(?=\]\]'')/g, '$1$2'); //non-standard code
regex(/(=[ ]*\[\[(Empire) \(film magazine\))(?=\]\][ ]*\|)/g, '$1|$2'); //non-standard code (unique regex added 20/6/2021)
regex(/(\|)(Empire)(?: \(film magazine\))(?=\]\])/g, '$1$2');
 
//Journals
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(/(=\s*)(Daily News) \((New York)\)(?=[ ]*[|}])/g, '$1$3 $2');
regex(/(=\s*)(Daily News)\s*\|___location=\s*(New York)/g, '$1$3 $2');
// regex(/(Daily News)\s*\|___location\s*=\s*New York\s*(?=\|)/g, '$1$2$4|___location=$3');
regex(/(\[\[)(Daily News)(?: \((New York)\))(?=[\|\]])/g, '$1$3 $2');
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)\)('')/g, '$1$3 ($2)');
regex(/(\|)(Daily Star)(?: \(United Kingdom\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*El Comercio) \((Equador|Peru|Spain)\)(\s*[|}])/g, '$1|___location=$2$3');
regex(/(''El Comercio) \((Equador|Peru|Spain)\)('')/g, '$1$3 ($2)');
regex(/(\|)(El Comercio)(?: \((?:Equador|Peru|Spain)\))(\]\])/g, '$1$2$3');
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');
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');
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');
regex(/(=[ ]*The Mercury) \((Hobart)\)(\s*[|}])/g, '$1|___location=$2$3');
regex(/(''The Mercury) \((Hobart)\)('')/g, '$1$3 ($2)');
regex(/(\|)(The Mercury)(?: \(Hobart\))(\]\])/g, '$1$2$3');
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(/(=[ ]*The National) \((Abu Dhabi)\)(\s*[|}])/g, '$1|___location=$2$3');
regex(/(''The National) \((Abu Dhabi)\)('')/g, '$1$3 ($2)');
regex(/(\|)(The National)(?: \(Abu Dhabi\))(\]\])/g, '$1$2$3');
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');
regex(/(=[ ]*Panorama) \((Gibraltar)\)(\s*[|}])/g, '$1|___location=$2$3');
regex(/(''Panorama) \((Gibraltar)\)('')/g, '$1$3 ($2)');
regex(/(\|)(Panorama)(?: \(Gibraltar\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*Público) \((Portugal)\)(\s*[|}])/g, '$1|___location=$2$3');
regex(/(''Público) \((Portugal)\)('')/g, '$1$3 ($2)');
regex(/(\|)(Público)(?: \(Portugal\))(\]\])/g, '$1$2$3');
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');
regex(/(=[ ]*The Standard) \((Hong Kong|Kenya)\)(\s*[|}])/g, '$1|___location=$2$3');
regex(/(=[ ]*Today) \((Singapore newspaper)\)(\s*[|}])/g, '$1|___location=Singapore$3');
regex(/(''Today) \((Singapore newspaper)\)('')/g, '$1$3 (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=Kolkota');
regex(/(''The Telegraph) \((Calcutta)\)('')/g, '$1$3 ($2)');
regex(/(\|)(The Telegraph)(?: \(Calcutta\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*The Daily Telegraph) \(Australia\)(?=\s*[|}])/g, '$1|___location=Australia');
regex(/(''The Daily Telegraph) \((Australia)\)('')/g, '$1$3 (Australia)');
regex(/(\|)(The Daily Telegraph)(?: \(Australia\))(\]\])/g, '$1$2$3');
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');
 
regex(/(= ?(?:ABC|Marca)) \((newspaper)\)([ ]*[|}])/g, '$1|___location=Spain$3');
regex(/(''(?:ABC|Marca)) \((newspaper)\)('')/g, '$1$3 (Spain)');
regex(/(\|)(ABC|Marca)(?: \(newspaper\))(\]\])/g, '$1$2$3');
regex(/(= ?(?:Il Giorno)) \((newspaper)\)([ ]*[|}])/g, '$1|___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(/(=[ ]*\[\[)([^\[\]\(\)\|:]*)( \([^\[\]\(\)\|]*\))(\]\])/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(/(?:author|agency|publisher)(\s*\=\s*\[\[[^()|]+ \((?:newspaper|magazine)\)\|[^\[\]|]+\]\])/gi, 'work$1');
 
// removing redundancies
regex(/ – (?:Times of India|Rediff.com [\w]*)(?=[ ]?\|)/gi, '');
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(/- [\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, '$1');
regex(/\|\s?(?:publisher|website|work)(\s?\=MTV)\|\s?publisher\s*\=\s*(?:MTV Networks|Viacom)/gi, '|publisher$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]]
 
// reordering 'work' and 'publisher'; reordering 'work' and 'website'
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*work\s*\=\s*(?:\[\[[^<{}\]]*\]\]|[^{}\|\}<>]*))(?=[\s\.]*[|}])/g, '$3$1$2');
 
/// removing identical/similar entries in 'work' and 'publisher', and in 'work' and 'website'
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?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$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, '$1'); //universal work and aliases
//unwinding of unnecessary pipes
regex(/\[\[([^\]\|]*)\|\1(?=\]\])/gi, '[[$1');
 
// removing artefacts (within citation templates)
regex(/(?:&#124; (?:Daily|English|(?:Mail |)Online|Music|News|Indian Express))(?=\s*\|)+/gi, ''); //|=: Video Gaming & Real Talk - PS4, Xbox One, Switch, PC, Handheld, Retro
 
regex(/(?:(?:[ ]+&#124;[ ]+HighBeam Research[ ]+[-–][ ]+FREE trial[ ]+|)\|publisher=Highbeam.com)/gi, '|via=Highbeam');
regex(/( &#124; [\w, ]*?)(?=[ ]&#124)/gi, '');
regex(/( &#124; Comment is free)/gi, '');
regex(/\|\s?title\s*\=\s*BBC (?:News|Sport)\s?(?:[-–]|&#124; )\s?/gi, '|title=');
regex(/\|\s?title\s*\=\s*Asia Times Online\s?(?:[-–]|&#124; |:+)\s?/gi, '|title=');
regex(/(?:Entertainment|Football|(?:inter|)national|Latest|local|Music|UK|world|) News &#124;(?=[ ]?[&\|])/gi, '');
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).');
 
// removing artefacts (outside of citation templates)
regex(/([\w]+\'\')\.(?:co(?:m|m?\.\w{2})|\.\w{2})[ ]/gi, '$1. ');
 
// removing other artefacts
regex(/(UEFA\]\])\.(?:co(?:m|m?\.\w{2})|\.\w{2})(?= ?[\|{}])/gi, '$1');
regex(/\bthe ((?:'''?|)the )/gi, '$1');
 
//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
 
}
 
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');
}
 
function Ohc_sourceunlink() {
var txt=document.editform.wpTextbox1;
 
//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
regex(/(<ref[^>]*>[^<]+?[\]\.,;]\s+)\[\[(?:[^\|\]<]*\||)([^\|\]<]*)(?: online|)\]\]([^<]*?<\/ref>)\) \./gi, '$1$2$3).');
regex(/(<ref[^>]*>[^<]+?[\]\.,;]\s+\'\')\[\[(?:[^\|\]<]*\||)([^\|\]<]*)(?: online|)\]\](\'\'[^<]*?<\/ref>)\) \./gi, '$1$2$3).');
}
 
/** ------------------------------------------------------------------------ **/
/// PROTECTION BY STRING SUBSTITUTION
 
var linkmap=[];
function Ohc_protect_urls()
{
// protects only urls
// 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;
};
 
// protect the rest (after purging urls inserted in ('website' or )'work' parameters)
regex(/((?:[\[=]\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()
{
//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;
});
}
 
/** ------------------------------------------------------------------------ **/
function Ohc_Source_edit_summary(){
//Add a tag to the summary box
setoptions(minor='true');
setreason('[[User:Ohconfucius/script|Script]]-assisted fixes: per [[WPHelp:Citation Style 1|CS1]] and [[MOS:MOSTEXTITALICS]]', 'append');
doaction('diff');
 
}
 
function Ohc_ref_formatOhc_ref_format_new() {
var txt=document.editform.wpTextbox1;
 
Ohc_remove_urls();
Ohc_news_sources();
Ohc_duplicatedcite();
Ohc_Source_edit_summary();
Ohc_protect_urls();
Ohc_sources_prep();
// ohc_foreign_dates();
Ohc_unpipe();
Ohc_dab_news_sources();
Ohc_sourcename();
Ohc_sourcework();
Ohc_sourcepub();
Ohc_sourceagency();
Ohc_redo_pipe();
Ohc_publishers();
Ohc_sources_cleanup();
Ohc_unprotect_urls();
 
Ohc_Source_edit_summary();
}
 
function Ohc_noverify() {
var txt=document.editform.wpTextbox1;
 
// removing references to other WP articles and 'external' WP links
regex(/<ref[^<>]*>[^<>]*\|[ ]*url ?= ?https?:\/\/(?:\w{2}\.wikipedia\.org\/wiki|(?:www\.|)(?:blogger|blogspot|facebook|findagrave|instagram|mailonline|myspace|twitter|x)\.com)\/[^<>]*<\/ref>/gi, '');
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]]');
 
}
 
function ohc_ref_names() {
// give names to citations in templates that are without names
//Note that this function may have unresolved bugs, particularly where the citation contains a numerical string with a '$' sign
 
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
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
regex(/<ref>((?:[^<>]*\|\s*url\s*=|[\[\s]?)https?:\/\/(?:[^|</]+\.)*([-\w]+)(?:\.[a-z]{2,3})\/[^<>|{}\d]*((?:19|20)\d\d)[-\/]((?:[0-1])\d|\w+)[-\/]((?:[0-3])\d)\/(\w+)[^<>]*)(?=<\/ref>)/gi, "<ref name=$2_$3$4$5_$6>$1"); //urls with non-date serial numbers
 
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");
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)
ohc_regex(/<ref>([^<>]*\|\s*url\s*=https?:\/\/(?:[^|</]+\.)*(\w+)\.(?:(?:com?|org|net|gov|ac|)(?:\.[a-z]{2}|))\/[^<>]*\|\s*date\s*=\s*=\s*((?:19|20)\d\d)[-\/]((?:[0-1])\d)[-\/]((?:[0-3])\d)\s*[|}][^<>]*)(?=<\/ref>)/gi, "<ref name=$2_$3$4$5>$1");
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
 
}
function prevDef ( e ) {
e.preventDefault();
}
function addLinks() {
 
var add = mw.util.addPortletLink;
$( add('p-tb', '#', 'Fix SOURCES', 's-citefix', 'Run entire new module', '', '') ).click(prevDef).click(Ohc_ref_format_new);
$( 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);
 
}
 
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 );
}
 
addOnloadHook$.when(mw.loader.using('mediawiki.util'), $.ready).done(function () {
if(document.forms.editform) {
// test buttons
// addPortletLink('p-tb', 'javascript:function_name()', 'Button name', 't-dmy', 'Hover text', '', '');
 
mw.util.addPortletLink('p-tb', 'javascript:Ohc_linkspamOhc_remove_urls()', 'LinkspamRemove certain urls', 'rms-linkspamremoveurl', 'removes linkspam in running0.Improper texturls', '', '');
mw.util.addPortletLink('p-tb', 'javascript:Ohc_ref_formatOhc_sources_prep()', 'Fix newsPrepare sources', 'ts-citefixprepsource', 'format1.Prepares citationssources', '', '');
mw.util.addPortletLink('p-tb', 'javascript:Ohc_publishersOhc_unpipe()', 'RemUnpipe publisherssources', 'ts-citefixunpipe', 'Removing certain2.Unpipe publisherslinked fieldssources', '', '');
mw.util.addPortletLink('p-tb', 'javascript:Ohc_dab_news_sources()', 'Applies DAB', 's-dab', '3.Applies disambiguation', '', '');
mw.util.addPortletLink('p-tb', 'javascript:Ohc_sourcename()', 'Align source name', 's-align', '4.Corrects source name – subscript1', '', '');
mw.util.addPortletLink('p-tb', 'javascript:Ohc_sourcework()', 'Cleanup WORK', 's-work', '5.Cleanup and reclassifies as WORK – subscript2', '', '');
mw.util.addPortletLink('p-tb', 'javascript:Ohc_sourcepub()', 'Cleanup publisher', 's-publish', '6.Cleanup and reclassifies as PUBLISHER – subscript2', '', '');
mw.util.addPortletLink('p-tb', 'javascript:Ohc_sourceagency()', 'Cleanup agency', 's-agency', '7.Cleanup and reclassifies as AGENCY – subscript2', '', '');
mw.util.addPortletLink('p-tb', 'javascript:Ohc_redo_pipe()', 'Repipe sources', 's-repipe', '8.Repipe ambiguous links', '', '');
mw.util.addPortletLink('p-tb', 'javascript:Ohc_publishers()', 'Rem publishers', 's-rempublish', '9.Removing certain publishers fields', '', '');
mw.util.addPortletLink('p-tb', 'javascript:Ohc_sources_cleanup()', 'Final cleanup', 's-cleanup', '10.Cleanup after script actions', '', '');
}
});
// </nowiki>