Content deleted Content added
Ohconfucius (talk | contribs) bug fix |
Ohconfucius (talk | contribs) align to test script |
||
Line 8:
importScriptURI('//meta.wikimedia.org/w/index.php?title=User:Pathoschild/Scripts/Regex_menu_framework.js&action=raw&ctype=text/javascript');
importScript("User:Ohconfucius/script/MOSNUM_utils.js"); //needed for "'Accessed' ->
importScript("User:Ohconfucius/test/Sources_subscript1.js"); //convert ___domain names into article names
importScript("User:Ohconfucius/test/Sources_subscript2.js"); //Correctly casing titles and apply or rem italicisation
importScript("User:Ohconfucius/test/Sources_subscript3.js"); //link-fixing, dabbing etc
importScript("User:Ohconfucius/script/foreigndates.js"); //link-fixing, dabbing etc
function Ohc_add_ref_tags() {
Line 21:
}
function Ohc_fill_pub_with_domain() {
var txt=document.editform.wpTextbox1;
//test
regex(/\s?(<ref>(?:[^<>]*\|\s*url\s*=|\[?)https?:\/\/((?:\w+\.)*\w+(?:\.(?:com?|org|net|)(?:\.[a-z]{2}|)))\/[^<>{}]+\|publisher=)(?=}}<\/ref>)/gi, "$1$2"); //capture ___domain name to add to publisher
regex(/(\|\s?publisher=)\s?\|\s?via\s*\=\s*(\w+)(?=\s*[|}])/gi, '$1$2');
// regex(/\|\s?via\s*\=\s*/gi, '|work=');
regex(/\s?[-–]\s?(?:The |)(\w+\.(?:com?|org|net|)(?:\.[a-z]{2}|))\s?(\|\s?publisher\s*\=\s*)\1(?=}})/gi, '$2$1');
regex(/\|\s?first\s*\=[^|]*\|\s?last\s*\=(?:Editor|Group|Staff|Reporter|Writer)\s*(?=\|)/gi, '');
regex(/({{Navbox deaths}})(\n)/gi, '==References==$2{{Reflist}}$2$1$2');
regex(/(==References==\n{{Reflist}}\n)\n?\1/gi, '$1');
}
function Ohc_remove_urls() {
Line 35 ⟶ 51:
// removing references to other WP articles and 'external' WP links
regex(/<ref[^<>]*>[^<>]*\|[ ]*url ?=https?:\/\/\w{2}\.wikipedia\.org\/
regex(/<ref>\s*https?:\/\/\w{2}\.wikipedia\.org\/wiki\/[^\s\]<]*<\/ref>/gi, '{{cn}}<!-- WP:RS needed; removed link to WP-->');
regex(/<ref>\s*\[https?:\/\/\w{2}\.wikipedia\.org\/
regex(/<ref(?: name=[^<>]|)>[^<>]*\|\s*url[ ]*=[ ]*https?:\/\/\w{2}\.wikipedia\.org\/
regex(/
regex(/(<ref[^<>]*>[^<>]*\|[ ]*url ?=https?:\/\/(?:(?:www\.|)(?:facebook|myspace|twitter|mailonline|findagrave)\.com|dailymail\.co\.uk)\/[^<>]*)(<\/ref>)/gi, '$1{{Primary source inline}}$2');
Line 48 ⟶ 64:
regex(/(\|\s?url\s*\=\s*)(https?:[^|{}#\s]+\.html?)\?[^|}]{1,5}(?=[\s\[\]|{}<>])/gi, '$1$2'); //rem link tracking
regex(/(\|\s?url\s*\=\s*|\[)(https?:\/\/books\.google\.[^\/]+\/books\?id=\w{12}&pg=PA\d{1,3})&dq[^\s|}]+(?=\s?[|}])/gi, '$1$2'); //rem browser optimisation
}
Line 64 ⟶ 81:
regex(/(\|\s?volume\s*\=\s*)vol(?:ume|\.?)[ ]*(\d)/gi, '$1$2');
regex(/(\|\s?pages?\s*\=\s*)(?:pages?|p[gp]?\.?)[ ]*(\d)/gi, '$1$2');
regex(/ [-–] (?:每日明報 daily news|東方日報)/gi, '');
regex(/(\|\s?title\s*\=\s*)Login ?(?=[|}\n])/gi, '$1ACTUAL ARTICLE TITLE BELONGS HERE');
regex(/(\|\s?)(?:publisher|website|work)=(Vimeo)(?:\.com|)(?=\s*[|}])/gi, '$1via=$2');
regex(/(\|\s?publisher=)\|\s?via\s*\=\s*(\w+)(?=\s*[|}])/gi, '$1$2');
regex(/(?:-[ ]*Google Books[ ]*(?:\|[^}]*|)|)\|\s?publisher\s*\=\s*(Google Books)(?=[\s\.]*[|}])/g, '|via=$1');
// regex(/(\|\s?)(?:publisher|website|work)=books\.google(?:\.com?|.co\.uk|)(?=\s*[|}])/gi, '|via=Google Books');
// regex(/\|\s?(?:publisher|website|work)=(British Newspaper Archive|Google Books|Project Gutenberg|Proquest|Scribd|web(?:\.archive\|citation)(?:\.org|))(?=\s*[|}])/gi, '|via=$1');
//Remove COinS corrupting templates from CS1 citations
regex(/(\|\s?(?:authors?|first\d?|last\d?|publisher|work)\s*\=\s*(?:[^{}|]*|)){{(?:Sm|Aut|SC|Small[- ]caps|Sm?caps)\|([^{}|]*)}}(?=(?:[^{}|]*|)[|}])/gi, '$1');
Line 126 ⟶ 148:
// adjust for possibly incorrectly input title
// regex(/(\|\s?title\s*\=\s*)([^\|\}<>]*)(\s?\|[^}<>]*|)\|\s?(publisher|work)\s*\=\s*(?:\1|\[\[\1\]\])(?=\s*[|}])/g, '$1ACTUAL ARTICLE TITLE BELONGS HERE! |$4=$2$3');
// regex(/(\|\s?title\s*\=\s*)(\w+\.com)(?=\s?[=|{}])/gi, '$1ACTUAL ARTICLE TITLE BELONGS HERE! |publisher=$2');
// rem misplaced punctuation
Line 158 ⟶ 180:
// removing english language parameters
regex(/[ ]?\{\{en[- ]icon\}\}/gi, "");
regex(/\|[ ]*?language[ ]*?=[ ]*?en(?:-\w{2}|glish|)(?=[\s
regex(/(\|[ ]*?language[ ]*?=[ ]*?)\{\{(\w{2})(?:[- ](?:icon|UK|GB|US)|)\}\}/gi, ""); // removing icon template from within "|language=" parameter
Line 235 ⟶ 257:
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
Line 245 ⟶ 264:
regex(/(\|)((?:The ?|)[A-Z]\w*(?: [A-Z]\w*|))(?: \((?:South Africa)(?:n newspaper|)\))(\]\])/g, '$1$2$3');
regex(/(=[ ]*
regex(/(''
regex(/(
regex(/(\
regex(/(=[ ]*)(Billboard|Campaign|Fast Company|People|Q|Slate|Time(?: Out|)|Wired) \((?:magazine)\)(?=\s*[|}])/g, '$1$2'); //non-standard code
regex(/('')(Billboard|Campaign|Fast Company|People|Q|Slate|Time(?: Out|)|Wired) \(magazine\)(?='')/g, '$1$2'); //non-standard code
regex(/(''\[\[(?:Billboard|Campaign|Fast Company|People|Q|Slate|Time(?: Out|)|Wired) \(magazine\))(?=\]\]'')/g, '$1|'); //non-standard code
regex(/(\|)(Billboard|Campaign|Fast Company|People|Q|Slate|Time(?: Out|)|Wired)(?: \(magazine\))(?=\]\])/g, '$1$2');
regex(/(=[ ]*)(Quartz) \((?:publication)\)(?=\s*[|}])/g, '$1$2'); //non-standard code
regex(/('')(Quartz) \(publication\)(?='')/g, '$1$2'); //non-standard code
Line 364 ⟶ 387:
regex(/\|\s?(?:publisher|website|work)(\s?\=MTV)\|\s?publisher\s*\=\s*(?:MTV Networks|Viacom)/gi, '|publisher$1=');
regex(/\|\s?(?:publisher|website|work)\s*\=\s*(?:BBC|BBC News(?: Online|))\s*(\|[^}<>]*|)\|\s?publisher\s*\=\s*(?:BBC|BBC News(?: Online|)|British Broadcasting Corporation)(?=[\s\.]*[|}])/g, '|
regex(/\|\s?(?:publisher|website|work)\s*\=\s*(BBC Sports?)\s*(\|[^}<>]*|)\|\s?publisher\s*\=\s*(?:BBC|BBC News(?: Online|)|British Broadcasting Corporation)(?=[\s\.]*[|}])/g, '|
regex(/\|\s?publisher\s*\=\s*(BBC (?:Sports|News))\s*(?=\|[^}<>]*|)/g, '|work=\'\'$1\'\'');
regex(/\|\s?(?:publisher|website|work)\s*\=\s*(Metacritic|\[\[Metacritic\]\])\s*(\|[^}<>]*|)\|\s?publisher\s*\=\s*(CBS Interactive|\[\[CBS Interactive\]\])(?=[\s\.]*[|}])/g, '|publisher=$1$2');
Line 374 ⟶ 399:
//per [[Help:Citation Style 1#Elements not included]]
▲ regex(/(?:-[ ]*Google Books[ ]*(\|[^}]*|)|)\|\s?publisher\s*\=\s*Google Books(?=[\s\.]*[|}])/g, '');
// toggling domains within |website= parameter
▲ regex(/\|\s?publisher\s*\=\s*(?:Project Gutenberg|Proquest|Scribd|web(?:\.archive\|citation).org)(?=[\s\.]*[|}])/g, '');
regex(/(\|\s?(?:work|website)\s*\=\s*)(\w+\.(?:com?|org|net|)(?:\.[a-z]{2}|))(?=\s*[|}])/gi, '$1\'\'$2\'\'');
// reordering 'work' and 'publisher'; reordering 'work' and 'website'
Line 442 ⟶ 468:
regex(/<[Rr]eferences ?\/>/g, '{{reflist}}'); //default
regex(/({{reflist)\|30em([^}]*}})/g, '$1$2');
regex(/({{reflist)\|[23](}})/g, '$1$2');
// disambiguating duplicated ref names
Line 536 ⟶ 563:
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\.|)(?:facebook|myspace|twitter|mailonline|findagrave)\.com)\/[^<>]*<\/ref>/gi, '');
regex(/<ref>https?:\/\/(?:en\.wikipedia\.org\/wiki|(?:www\.|)(?:facebook|myspace|twitter|mailonline|findagrave)\.com)\/[^\s\]<]*<\/ref>/gi, '');
regex(/<ref>\[https?:\/\/(?:en\.wikipedia\.org\/wiki|(?:www\.|)(?:facebook|myspace|twitter|mailonline|findagrave)\.com)\/[^\s\]]*[ ]+[\w\d][^\]]*\]<\/ref>/gi, '');
regex(/\|[ ]*url[ ]*=[ ]*https?:\/\/(?:\w{2}\.wikipedia\.org\/wiki|(?:www\.|)(?:facebook|myspace|twitter|mailonline|findagrave)\.com)[^\s\|\{\}<]*(?=[ ]*[|}])/gi, '');
regex(/[ ]\[https?:\/\/en\.wikipedia\.org\/wiki\/[^\s\]]*[ ]+([\w][^\]]*)\]/gi, ' [[$1]]');
}
Line 547 ⟶ 588:
ohc_regex(/<ref>((?:[^<>]*\|\s*url\s*=|\[?)https?:\/\/(?:[^|]+\.)*(\w+)\.(?:(?:com?|org|net)(?:\.[a-z]{2}|))[^<>|{}]+@YYYY[\/-]?@Month[\/-]?@Day[^<>]*)(?=<\/ref>)/gi, "<ref name=@YYYY@MM@DD$2>$1"); //urls with embedded dates
}
Line 558 ⟶ 594:
e.preventDefault();
}
function addLinks() {
var add = mw.util.addPortletLink;
$( add('p-tb', '#', 'Add REFTAGS', 's-reftags', 'Insert missing ref tags', '', '') ).click(prevDef).click(Ohc_add_ref_tags);
$( add('p-tb', '#', 'CITE name', 's-citename', 'gives names to all citations', '', '') ).click(prevDef).click(ohc_ref_names);
$( add('p-tb', '#', 'Fill DOMAIN_NAME', 's-domainname', 'imports ___domain names to publisher field', '', '') ).click(prevDef).click(Ohc_fill_pub_with_domain);
$( add('p-tb', '#', 'Unlink source name', 's-unlink', 'Unlinks source', '', '') ).click(prevDef).click(Ohc_sourceunlink);
$( add('p-tb', '#', 'Fix SOURCES', 's-citefix', 'Run entire new module', '', '') ).click(prevDef).click(Ohc_ref_format_new);
|