User:Ohconfucius/test/Sources.js

This is an old revision of this page, as edited by Ohconfucius (talk | contribs) at 15:39, 12 July 2011 (expanded and overhauled code). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// *********************************************************************************************
 
//This is a test (non-production) script, and may have untested errors. Please exercise due care should you decide to use it.
 
// *********************************************************************************************
 
/*************
*** 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.
*************/
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;

	txt.value=txt.value.replace(/([^>\*][ ]*)\[http:\/\/[^\s\]]*[ ]([\w\d][\w\d\s-'"]*)\]/gi, '$1$2');
}

function Ohc_news_sources() {
 var txt=document.editform.wpTextbox1;

//		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 ');

	txt.value=txt.value.replace(/\{\{[i-z]{5}ews(|2|cat|has|portal|table|-inline)(\|[^\}]+|)\}\}\s*/gi, '');
	txt.value=txt.value.replace(/\*[ ]*\{\{Find a Grave\|\d{4}\|(\|[^\}]+)\}\}\s*/gi, '');

//reflinks fixes
//	txt.value=txt.value.replace(/&#\d{2,3}\;/g, ',');

    //citation template fixes
	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');
	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
	txt.value=txt.value.replace(/(\|[ ]*(?:agency|author|journal|publisher|newspaper|work))[ ]*=[ ]*/gi, '$1=');
	txt.value=txt.value.replace(/(?:\|\s?publisher\s?\=\s?\'\'\[\[([^\]]{1,40})\]\]\'\')/gi, '|work=[[$1]]');
	txt.value=txt.value.replace(/(?:\|\s?publisher\s?\=\s?\'\'([^\]]{1,40})\'\')/gi, '|work=$1');

	txt.value=txt.value.replace(/\[\[Time\s\(magazine\)\|(Time|Time Magazine)\]\]/g, 'TIME');
	txt.value=txt.value.replace(/\[\[Billboard\s\(magazine\)\|(Billboard|Billboard Magazine)\]\]/g, '$1'); 

//returns 'work=' for traditional media with websites
	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)(wired\.com)(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=Wired ');
	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?(?:\[\[|)abcnews\.com(?:\]\]|))(?=[\s]*[\|\}])/gi, '|publisher=ABC News |___location=US ');
	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)cbc\.ca(?:\]\]|))(?=[\s]*[\|\}])/gi, '|publisher=CBC |___location=Canada ');
	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?(?:\[\[|)csmonitor\.com(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work= Christian Science Monitor ');
	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)miamiherald.com(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=Miami Herald ');
	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?(?:\[\[|)atimes\.com(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=Asia Times ');
	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's daily online|[^\[]{0,10}people(?:daily|)\.com\.cn(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=People\'s Daily |___location=PRC ');
	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}seattletimes\.com(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=Seattle 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');

	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)asahi\.com(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=Asahi Shimbun |___location=Japan');
	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)(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=Haaretz |___location=Israel');
	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)jpost\.(com|co\.il)(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=Jerusalem Post ');

	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(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)Times ?of ?india(\.com|)(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=The Times of India');
	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)Hindustan ?times(\.com|)(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=Hindustan Times |___location=India');
	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)express(?:india\.com| online)(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=The Indian Express ');
	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)financialexpress(?:\.com|)(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=The Financial Express ');
	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)(?:the)?hindu.com(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=The Hindu |___location=India');
	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)deccanchronicle.com(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=The Deccan Chronicle |___location=India');
	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)Thestatesman.net(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=The Statesman |___location=India');
	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)dailypioneer.com(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=The Pioneer |___location=India');
	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(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)tribuneindia.com(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=The Tribune |___location=India');
	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)IndianExpress.com(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=The Indian Express |___location=India');
	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)deccanherald.com(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=Deccan Herald |___location=India');
	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)Expressbuzz.com(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=The New Indian Express |___location=India');

	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)blesk.cz(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=Blesk |___location=Czech Republic');
	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)ihned.cz(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=Hospodářské noviny |___location=Czech Republic');
	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)lidovky.cz(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=Lidové noviny |___location=Czech Republic');
	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)idnes.cz(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=Mladá fronta DNES |___location=Czech Republic');
	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)pravo.novinky.cz(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=Právo |___location=Czech Republic');
	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)praguepost.com(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=The Prague Post |___location=Czech Republic');

	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(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)newsday\.com(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=Newsday |___location=New York ');
	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?(?:\[\[|)[^\[]{0,10}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?(?:\[\[|)theage\.com\.au(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=The Age |___location=Australia');
	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)theaustralian\.com\.au(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=The Australian ');
	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(/(?:\|\s?(work|publisher)\s?\=\s?(?:\[\[|)[^\[]{0,10}un\.org(?:\]\]|))(?=[\s]*[\|\}])/gi, '|publisher=United Nations ');

//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 |)(Observer|Daily Telegraph|Guardian|Independent|Scotsman|(Sunday |)Times|Spectator))\]\])(?=[\s]*[\|\}])/gi, '|work=The $1 |___location=UK ');
	txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?\[\[(the )?(Daily (Mail|Mirror|Express)|NME|New Musical Express|New Statesman)\]\])(?=[\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 |Seattle |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)\]\])(?=[\s]*[\|\}])/gi, '|work=The $1 ');
	txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?\[\[(?:The |)(Hindu|Deccan Chronicle|The Statesman|Economic Times|Tribune|(?:New |)Indian Express|Asian Age)\]\])(?=[\s]*[\|\}])/gi, '|work=The $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?\[\[(?:The |)(Deccan Herald|Daily News and Analysis|Hindustan Times)\]\])(?=[\s]*[\|\}])/gi, '|work=$1 |___location=India');
	txt.value=txt.value.replace(/(?:\|\s?(?:work|publisher)\s?\=\s?)(?:\[\[The Telegraph \(Kolkata\)\|(The Telegraph)\]\])(?=[\s]*[\|\}])/gi, '|work=$1 |___location=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?\[\[(Blesk|Hospodářské noviny|Lidové noviny|Mladá fronta DNES|Právo|(?:The |)Prague Post)\]\])(?=[\s]*[\|\}])/gi, '|work=$1 |___location=Czech Republic');

	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 |');

	txt.value=txt.value.replace(/(?:\|\s?(work|publisher)\s?\=\s?\[\[(?:The |)Straits Times\]\])(?=[\s]*[\|\}])/gi, '|work=Straits Times |___location=Singapore ');
	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)');
	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(/(?:\|\s?publisher\s?\=\s?\[\[The standard\|hk standard\]\])(?=[\s]*[\|\}])/gi, '|work=The Standard |___location=Hong Kong ');
	txt.value=txt.value.replace(/(?:\|\s?publisher\s?\=\s?the age)(?=[\s]*[\|\}])/gi, '|work=The Age |___location=Australia');

//returns 'work=' for traditional media not requiring ___location dab
	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(/(?:\|\s?(?:work|publisher)\s?\=\s?(?:\[\[|)((?:bloomberg |)business\s?week)(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=$1 ');

	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');

//returns 'work=' for new media news magazines
	txt.value=txt.value.replace(/(?:\|\s?(?:newspaper|work|publisher)\s?\=\s?(?:\[\[|)(Huffington Post)(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=$1 |___location=USA');
	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?(?:\[\[|)(Digitalspy.co.uk)(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=Digital Spy |___location=UK');

//returns 'publisher=' for electronic media
	txt.value=txt.value.replace(/(?:\|\s?(?:newspaper|work|publisher)\s?\=\s?(?:\[\[|)(hrw.org)(?:\]\]|))(?=[\s]*[\|\}])/gi, '|publisher=Human Rights Watch');
	txt.value=txt.value.replace(/(?:\|\s?(?:newspaper|work|publisher)\s?\=\s?(?:\[\[|)(amnesty.org)(?:\]\]|))(?=[\s]*[\|\}])/gi, '|publisher=Amnesty International');
	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|journal)\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');

//Television media and networks
	txt.value=txt.value.replace(/(?:\|\s?(publisher|station)\s?\=\[\[(BBC (?:One|Two|Three|Four|Five|Six)|Channel [45])\]\])(?=[\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');

//returns 'publisher=' for electronic media stripped of ___domain suffices
	txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?(?:\[\[|)ap\.org(?:\]\]|))(?=[\s]*[\|\}])/gi, '|agency=Associated Press ');
	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?(?:\[\[|)[^\[]{0,10}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?(?:\[\[|)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 ');

	txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?(?:\[\[|)(mtv|twitter|vh1|youtube)\.com(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=\'\'$2\'\'');
	txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?(?:\[\[|)((?:[\w]*\.|)Europa\.eu|Europa \(web portal\)\|Europa)(?:\]\]|))(?=[\s]*[\|\}])/gi, '|work=\'\'Europa (web portal)\'\'');

	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  ');
	txt.value=txt.value.replace(/\[\[(ABC|AP|AFP)\]\]/g, '$1');

//linked publishing houses
	txt.value=txt.value.replace(/(?:\|\s?(newspaper|work|publisher)\s?\=\s?(?:\[\[|)Hachette Filipacchi Médias\|(Hachette Filipacchi) \(UK\) Ltd(?:\]\]|))(?=[\s]*[\|\}])/gi, '');
	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, '');
// removing redundancies
	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(/\|\s?___location\s?\=\s?USA\s?(\|[^}]*|)\|\s?___location\s?\=\s?USA/g, '|___location=USA $1');
	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');
//	txt.value=txt.value.replace(/\|\s?language\s?\=\s?English/gi, '');  //false positive in infoboxes for books
	txt.value=txt.value.replace(/- [\w]*\.com[ ]*\|/gi, '|');

	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');
	txt.value=txt.value.replace(/\|\s?publisher\s?\=\s?CNN\s?(\|[^}]*|)\|\s?publisher\s?\=\s?CNN(?=[\s]*[\|\}])/g, '|publisher=CNN $1');


}

function Ohc_Source_edit_summary(){
	//Add a tag to the summary box
	setoptions(minor='true'); 		
	setreason('per [[WP:MOSTEXT]]', 'append');
	doaction('diff');
}

function Ohc_ref_format() {
 var txt=document.editform.wpTextbox1;

	Ohc_news_sources();
	Ohc_Source_edit_summary();
}

addOnloadHook(function () {
 if(document.forms.editform) {
//  addPortletLink('p-tb', 'javascript:function_name()', 'Button name', 't-dmy', 'Hover text', '', '');

  addPortletLink('p-tb', 'javascript:Ohc_linkspam()', 'Linkspam', 'rm-linkspam', 'removes linkspam in running text', '', '');
  addPortletLink('p-tb', 'javascript:Ohc_ref_format()', 'Fix news sources', 't-citefix', 'format citations', '', '');
  }
});