Jump to content

User:Moonythedwarf/extra-unreliable.js: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
add code tag
fixes
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
// Instructions available at [[User:Headbomb/unreliable]]
// Instructions available at [[User:Moonythedwarf/extra-unreliable]]
// Feel free to request tweaks or additional sources to be covered on the talk page
// Feel free to request tweaks or additional sources to be covered on the talk page


Line 7: Line 7:
// Updated from https://en.wikipedia.org/w/index.php?title=User:SD0001/unreliable.js&action=edit by [[User:SD0001]]
// Updated from https://en.wikipedia.org/w/index.php?title=User:SD0001/unreliable.js&action=edit by [[User:SD0001]]
// Updated from https://en.wikipedia.org/w/index.php?title=User:Creffett/unreliable.js&oldid=957395306 by [[User:Creffett]]
// Updated from https://en.wikipedia.org/w/index.php?title=User:Creffett/unreliable.js&oldid=957395306 by [[User:Creffett]]
// Adapted from https://en.wikipedia.org/w/index.php?title=User:Headbomb/unreliable.js&oldid=987448454 by [[User:Headbomb]]


// Big thanks to various spam-fighters on and off wiki for helping provide resources to design the built-in regexes on.
// Unreliable websites based on [[WP:RSPSOURCES]] (mostly)
//
// Unreliable publishers/journals based on [[WP:CITEWATCH]] (mostly)


// \/ regex in links doesn't work as it should, use (%2F|\/) instead
// \/ regex in links doesn't work as it should, use (%2F|\/) instead
Line 15: Line 16:


var rules = [
var rules = [
// Language 1
{
{
comment: 'Blacklisted source',
comment: 'Promotional phrasing',
// this regex kinda sucks
regex: /\b(?:test\.blacklist\.org|112\.international|112\.ua|breitbart\.com|city-data\.com|dan-news\.info|examiner\.com|famousbirthdays\.com|globalresearch\.ca|infowars\.com|infowars\.net|infowars\.tv|lenta\.ru|liveleak\.com|lulu\.com|mylife\.com|naturalnews\.com|news-front\.info|newswar\.com|newswars\.com|reunion\.com|rusdialog\.ru|southfront\.org|thepointsguy\.com|topwar\.ru|ukraina\.ru|veteransnewsnow\.com|veteranstoday\.com|zoominfo\.com)/i,
regex: /(?:\bextensive\s+(?:experience|work)|\bthe\s+field|\bwe|\bour|\ball\s+rights\s+reserved|\brevolutionary|\byour|\baward(?:\s+|\-)winning|\bperfect|\bthe\s+community|\bon\s+the\s+rise\s+|(?:\(tm\)|™)|\binspiration|\bhere\s+(?:at|in)|\bstrive|\bthe\s+best|\b(?:low|amazing|incredible|unbeatable)\s+(?:price|cost)(?:s?)|\bunbeatable|\b100%\s+guaranteed|\bwide\s+selection|\bbothersome|\b(?:wildly|amazingly|outstandingly|)\s+popular|\btoday|\btommorow|\bfrenzy|\baffordable|\bloved|\bwell(?:\s+|\-)known|\bfastest\s+growing|\bpost|\bexciting\s+(?:day|week|year|month)|\bexciting|\bendless|\bcustomers|\bhousehold\s+name|\byou|\bpublished\s+\d\s+(?:seconds|minutes|hours|days|months|years)\s+ago|\bgreatest|\bbest\s+ever|\bmilestone|\bin\s+the\s+world)\b/gmi,
css: { "background-color": "#dddddd", "text-decoration":"underline", "text-decoration-style": "wavy", "text-decoration-color": "#cc0000"}
css: { "background-color": "#ea985d" },
text_matcher: true,
},
},

// Language 2
{
{
comment: 'Deprecated source',
comment: 'Promotional phrasing',
// more bad regex!
regex: /\b(?:test\.deprecated\.org|campaignlifecoalition\.com|crunchbase\.com|dailycaller\.com|dailymail\.co\.uk|dailymail\.com|hispantv\.com|hispantv\.ir|last\.fm|lifesitenews\.com|mintpressnews\.com|nationalenquirer\.com|newsoftheworld\.co\.uk|nndb\.com|oann\.com|occupydemocrats\.com|rateyourmusic\.com|rt\.com|takimag\.com|telesurenglish\.net|telesurtv\.net|theepochtimes\.com|thegatewaypundit\.com|thesun\.co\.uk|vdare\.com|wnd\.com|worldnetdaily\.com|royalark\.net|thepeerage\.com|worldstatesmen\.org|4dw.net(%2F|\/)royalark)/i,
regex: /(?:\b(?:her|his)\s+(?:distinctive|powerful|unique|amazing|exceptional|exquisite|one\s+of\s+a\s+kind)\b|\b(?:explore|embracing|accepting|using|utilizing|creating|building)\s+ideas\b|\bnumerous|\bmore\s+than\b|\beffectively\s+(?:commit|turn|create|modify|sell)\b|\b(?:amazing|powerful|unique|exceptional|impressive)\s+technology\b|\bnew\s+standard\b|\bworld(?:\s+|)(?:reknown|reknowned|renowned|renown)\b)/gmi,
css: { "background-color": "#ffbbbb", "text-decoration":"underline", "text-decoration-style": "wavy"},
css: { "background-color": "#ea985d" },
text_matcher: true,
},
},
// Language 3
{
{
comment: 'Misleading journal metric',
comment: 'Promotional phrasing',
// more bad regex!
regex: /\b(?:test\.misleading\.org|aeglobalindex\.com|aqcj\.org|arabimpactfactor\.com|citefactor\.org|cosmosimpactfactor\.com|dids\.info|diif\.org|doi-ds\.org|drji\.org|esjindex\.org|generalimpactfactor\.com|globalimpactfactor\.com|gscif\.org|i2or\.com|iarcif\.org|ifsij\.com|iijif\.com|impact-factor\.ru|impactfactorjournals\.com|impactfactorservice\.com|indexcopernicus\.com|infobaseindex\.com|inno-space\.net|internationaljournalimpactfactor\.com|isindexing\.com|isithomsonreuters\.org|israjif\.org|jifactor\.com|jifactor\.org|jourinfo\.com|journal-index\.org|journal-metrics\.com|journalimpactfactor\.co\.in|journalimpactfactor\.co\.in|journalimpactfactor\.in|journalsconsortium\.org|journalsmetrics\.com|jprsimpactfactor\.com|oaji\.net|opqc\.org|prernasociety\.org|pubicon\.org|rjifactor\.com|rootindexing\.com|scienceimpactfactor\.com|scijournal\.org|scijournal\.org|sifactor\.org|sindexs\.org|sjournals\.net|sparcindexing\.org|timpactfactor\.com|uifactor\.org|worldbizins\.org)/i,
regex: /\b(?:own\s+new\s+world|eponymous|renowned|being\s+the\s+world|revolutionized|swiftly|(?:instant|growing)\s+popularity|clientele|breathes\s+life|coveted|(?:his|her|their)\s+audiences|ever\s+growing|upcoming\s+works)/gmi,
css: { "background-color": "#ffbbbb", "text-decoration":"underline", "text-decoration-style": "wavy"},
css: { "background-color": "#ea985d" },
text_matcher: true,
},
},

// Language 4
{
{
comment: 'Generally unreliable source',
comment: 'Promotional phrasing',
// more bad regex!
regex: /\b(?:test\.generallyunreliable\.org|alternet\.org|amazon\.(com\.br|ca|com\.mx|com|cn|in|co\.jp|sg|com\.tr|ae|fr|de|it|nl|es|co\.uk|com\.au)|amren\.com|ancestry\.com|angelfire\.com|angelfire\.lycos\.com|answers\.com|askubuntu\.com|baike\.baidu\.com|bild\.de|bipartisanreport\.com|bircham\.edu|blogger\.com|blogspot\.com|bloodandhonourcentral\.co\.uk|bloodandhonourworldwide\.co\.uk|celebritynetworth\.com|centerforfoodsafety\.org|cesnur\.org|cnsnews\.com|coindesk\.com|conservativereview\.com|conservativetribune\.com|cracked\.com|dailykos\.com|dailymotion\.com|dailystar\.co\.uk|dailywire\.com|deanradin\.com|deanradin\.org|discogs\.com|electronicintifada\.net|ewg\.org|explorejournal\.com|express\.co\.uk|facebook\.com|familysearch\.org|fandom\.com|fb\.com|findagrave\.com|findmypast\.co\.uk|foodandwaterwatch\.org|force9\.co\.uk|fwwatch\.org|gawker\.com|geni\.com|geocities\.com|goodreads\.com|guacamoley\.com|heatst\.com|ibtimes\.com|imdb\.com|indiahealthguru\.com|indymedia\.org|instagram\.com|lenr-canr\.org|liberty\.edu|linkedin\.com|livejournal\.com|marquiswhoswho\.com|mathoverflow\.net|mediabiasfactcheck\.com|medium\.com|metro\.news|mruniversity\.com|neuroquantology\.com|newenergytimes\.com|onlinegatha\.com|palmerreport\.com|pan-international\.org|patheos\.com|patribotics\.com|pesticideinfo\.org|pinterest\.com|prageru\.com|presstv\.com|prisonplanet\.com|quadrant\.org\.au|quillette\.com|quora\.com|reddit\.com|rootsweb\.com|scribd\.com|sputniknews\.com|stackexchange\.com|stackoverflow\.com|stormfront\.org|telekinesisworld\.com|theblaze\.com|thegwpf\.org|thenewamerican\.com|theonion\.com|thetruthaboutguns\.com|tunefind\.com|tvtropes\.org|twitch\.tv|twitter\.com|urbandictionary\.com|venezuelanalysis\.com|vgchartz\.com|vimeo\.com|vixra\.org|westernjournal\.com|whosampled\.com|wikia\.com|wikia\.org|wikileaks\.org|wonkette\.com|wordpress\.com|worldtruth\.tv|youtube\.com|zerohedge\.com|avn\.org\.au|childrenshealthdefense\.org|cmsri\.org|collective-evolution\.com|davidwolfe\.com|drtenpenny\.com|foodbabe\.com|greenmedinfo\.com|healthnutnews\.com|i-sis\.org|medicalveritas\.com|mercola\.com|modernalternativehealth\.com|modernalternativemama\.com|momsacrossamerica\.com|naturalnews\.com|nvic\.org|organicconsumers\.org|peteevans\.com|realfarmacy\.com|townsendletter\.com|tldp\.com|wddty\.com|sixthtone\.com|thepaper\.cn|flickr\.com|tumblr\.com|souq\.com|coresci\.org|delphiclassics\.com|gsjournal\.net|prespacetime\.com|jcer\.com|dnadecipher\.com|scigod\.com|thecanary\.co|worldometers\.info|worldometer\.info|weebly\.com|skwawkbox\.org)/i,
regex: /\b(?:world\’s\s+leading|extensive\s+range|in\s+the\s+world|innovative|market\s+leading|cutting(?:\s+|-)edge|pushing\s+the\s+boundaries|comprehensive)/gmi,
css: { "background-color": "#ffdddd" },
css: { "background-color": "#ea985d" },
text_matcher: true,
},
},
// Language 5
{
comment: 'Generally unreliable source',
regex: /\b10\.(?:0004|14704|5048|46469)\b/,
css: { "background-color": "#ffdddd" },
},

{
{
comment: 'Wikimedia-related website',
comment: 'Promotional phrasing',
regex: /\b(?:entrepreneur|motivational\s+(?:speaker|writer|author)|influencer|social\s+media\s+personality|rising\s+star|up\s+and\s+coming|notable\s+for|featured\s+in|famous|celebrity)/gmi,
filter: mw.config.get('wgNamespaceNumber') === 0 || mw.config.get('wgNamespaceNumber') === 118,
css: { "background-color": "#ea985d" },
regex: /\b(?:test\.wiki\.org|wikidata\.org|wikinews\.org|wikipedia\.org|wiktionary\.org)/i,
text_matcher: true,
css: { "background-color": "#ffdddd" },
},

// Predatory. See [[Special:AbuseFilter/891]], [[WP:CITEWATCH/SETUP]], [[User:JzG/Predatory]] and https://beallslist.net/
{
comment: 'Predatory journal or publisher',
regex: /\b(?:test\.predatory\.org|\.iiis\.org|\.ssjournals\.com|academicjournals\.com|academicjournals\.net|academicjournals\.org|academicpub\.org|academicresearchjournals\.org|aiac\.org\.au|aicit\.org|aijcrnet\.com|aijssnet\.com|alliedacademies\.org|arcjournals\.org|ashdin\.com|aspbs\.com|avensonline\.org|bibliomed\.org|biomedres\.info|biopublisher\.ca|bowenpublishing\.com|ccsenet\.org|cennser\.org|clinmedjournals\.org|cluteinstitute\.com|cosmology\.com|cpinet\.info|cscanada\.net|currentpediatrics\.com|davidpublisher\.org|esciencecentral\.org|etpub\.com|eujournal\.org|grdspublishing\.org|growingscience\.com|hanspub\.org|hoajonline\.com|hrmars\.com|iacsit\.org|iamure\.com|idosi\.org|igi-global\.com|iises\.net|iiste\.org|ijarbs\.com|ijastnet\.com|ijbhtnet\.com|ijbssnet\.com|ijddr\.in|ijhssnet\.com|ijllnet\.com|imedpub\.com|informaticsjournals\.com|innspub\.net|intechopen\.com|intechweb\.org|interesjournals\.org|internationaljournalssrg\.org|ispacs\.com|ispub\.com|jalsnet\.com|jaypeebrothers\.com|jaypeejournals\.com|jbepnet\.com|jespnet\.com|journalofcosmology\.com|jpmedpub\.com|julypress\.com|juniperpublishers\.com|kowsarpub\.com|kspjournals\.org|m-hikari\.com|macrothink\.org|mecs-press\.org|medwelljournals\.com|oapublishinglondon\.com|oatext\.com|omicsgroup\.org|omicsonline\.org|oprscience\.org|ospcindia\.org|researchleap\.com|researchpub\.org|sapub\.org|scholink\.org|scialert\.net|scidoc\.org|sciedu\.ca|sciencedomain\.org|sciencedomains\.org|sciencepg\.com|sciencepub\.net|sciencepubco\.com|sciencepublication\.org|sciencepublishinggroup\.com|scientificjournals\.org|sciepub\.com|scipg\.net|scipress\.com|scirp\.org|scitechnol\.com|scopemed\.com|scopemed\.org|seipub\.org|sersc\.org|sphinxsai\.com|thesai\.org|valleyinternational\.net|waset\.org|witpress\.com|worldsciencepublisher\.org|worldwidejournals\.com|wscholars\.com|wseas\.org|wudpeckerresearchjournals\.org|zantworldpress\.com|zenithresearch.org\.in|oapub\.org|medcraveonline\.com|journalissues.\org|rjlbpcs\.com|cosmosscholars\.com|cibtech\.org|rajpub\.com|cirworld\.com|thescipub\.com|ijirset\.com|ijltet\.org|geneticsmr\.org|ijert\.org|electrochemsci\.org|ijohmn\.com|ripublication\.com|newworldpub\.com|infinitypress\.info|sciencejournal\.in|destechpub\.com|chitkara\.edu\.in|bioinfopublication\.org|bioflux\.com\.ro|bonfring\.org|econjournals\.com|eurojournals\.com|eajournals\.org|euser\.org|scholarsresearchlibrary\.com|journalcra\.com|conferenceseries\.com|ijera\.com|stmjournals\.com|xandhpublishing\.com|xiahepublishing\.com|scholarpublishing\.org|ecronicon\.com|ijrdet\.com|ijiset\.com|ijsat\.com|warse\.org|jocpr\.com|ispub\.com|advancedscience\.org|longdom\.org|ijtrd\.com|recentscientific\.com|phytojournal\.com|scihub\.org|scientiaricerca\.com|auctoresonline\.org|universitypublications\.net|globaljournals\.org|biocoreopen\.org|ijpbs\.net|pharmascope\.org|ejpmr\.com|pharmainfo\.in|aessweb\.com|ijmhr\.org|acjol\.org|ijstr\.org|ijmrbs\.org|ijerst\.com|maxwellsci\.com|ijfcc\.org|ijmlc\.org|iaeme\.com|journalcra\.com|jioh\.org|irjponline\.com|pharmainfo\.in|stmjournals\.in|globalresearchonline\.net|ijrrjournal\.com|europeanjournalofsocialsciences\.com|ijsre\.com|ijsrpub\.com|jmest\.org|tropicalplantresearch\.com)/i,
css: { "background-color": "#ffbbbb", "text-decoration":"underline", "text-decoration-style": "wavy"},
},
},
// Language 6
{
comment: 'Predatory journal or publisher',
regex: /\b10\.(?:0001|11648|1166|1234|12677|12692|12720|12988|13005|13172|13188|14257|14299|14303|14419|14445|1453|14569|14662|15406|15415|15373|15680|15761|17265|18005|18052|18311|18775|19030|19044|19070|19080|1999|20319|20431|20472|20849|20902|20964|21102|21767|22158|23937|29322|2495|30845|35841|36648|3844|3923|3968|4018|4156|4172|4236|4303|5005|5267|5296|5376|5430|5455|5539|5567|5580|5772|5812|5815|5829|5897|5899|5923|5963|6007|6479|7243|7439|7537|7575|7718|7763|9734|22192|18535|15379|35248|24297|7176|17577|37532|24113|14218|14738|3153|9790|15550|35940|33564|24327|22271(%2F|\/)phyto|22214|37591|18632|22271|25141|22376|26452|47128|18488|16965|24105|12983|26417|3889|21474)\b/,
css: { "background-color": "#ffbbbb", "text-decoration":"underline", "text-decoration-style": "wavy"},
},

// Sources that traditionally fail [[WP:MEDRS]], but which could be used for other more routine claims
{
{
comment: 'Promotional phrasing',
comment: 'Borderline source, which often (but not always) fails higher sourcing requirements.',
regex: /\b(?:test\.medrs\.org|benthamopen\.com|f1000\.com|frontiersin\.org|mdpi\.com|businessperspectives\.org)/i,
regex: /\b(?:safe\s+shopping|fast\s+delivery|world\'?s\s+most|prime\s+goal)/gmi,
css: { "background-color": "#fffdd0" }
css: { "background-color": "#ea985d" },
text_matcher: true,
},
},
{
comment: 'Borderline source, which often (but not always) fails higher sourcing requirements. For Bentham journals, only those published by Bentham Open are of concern.',
regex: /\b10\.(?:0002|2174|3389|3390|3410|4089|4175|7490|12688|12703|20944|32545|35995|1016(%2F|\/)j\.chaos\.|1016(%2F|\/)S0960-0779|1007(%2F|\/)s12129|4103|6219|9754)\b/,
css: { "background-color": "#fffdd0" }
},

// May or may not contain preprints, predatory, or self-published materials
{
comment: 'Preprint or general repository which may or may not contain unpublished/predatory materials',
regex: /\b(?:test\.warn\.org|academia\.edu|arxiv\.org|biorxiv\.org|chemrxiv\.org|cogprints\.org|citeseerx\.ist\.psu\.edu|cureus\.com|scholar\.google|docs\.google|e-century\.org|eartharxiv\.org|figshare\.com|medrxiv\.org|osf\.io\/preprints|peerj\.com\/preprints|psyarxiv\.com|pulsus\.com|researchgate\.net|semanticscholar\.org|ssrn\.com|zenodo\.org|qeios\.com)/i,
css: { "background-color": "#fffdd0" },
},
{
comment: 'Preprint or general repository which may or may not contain unpublished/predatory materials',
regex: /\b10\.(?:0003|1101(%2F|\/)\d+|2139|7287|4066|5281|5604|6084|7759|13140|19144|20935|21282|31219|31220|31221|31222|31223|31224|31225|31226|31227|31228|31229|31230|31231|31232|31233|31234|31235|31236|31237|32388)\b/i,
css: { "background-color": "#fffdd0" },
},

// Varies with the contributor or topic
{
comment: 'Reliability depends on contributor or topic',
regex: /\b(?:test\.contributors\.org|aa\.com\.tr|forbes\.com|foxnews\.com|huffpost\.com|infotextmanuscripts\.org|jezebel\.com)/i,
css: { "background-color": "#fffdd0" },
}
];
];
// Dynamically load a user's custom rules from User:USERNAME/unreliable-rules.js
// Dynamically load a user's custom rules from User:USERNAME/extra-unreliable-rules.js
mw.loader.getScript('/w/index.php?title=User:' + encodeURIComponent(mw.config.get('wgUserName')) +
mw.loader.getScript('/w/index.php?title=User:' + encodeURIComponent(mw.config.get('wgUserName')) +
'/unreliable-rules.js&action=raw&ctype=text/javascript')
'/extra-unreliable-rules.js&action=raw&ctype=text/javascript')
.fail( function(e) {
.fail( function(e) {
// Something's gone very wrong
// Something's gone very wrong
mw.log.error("Error retrieving your unreliable-rules.js");
mw.log.error("Error retrieving your extra-unreliable-rules.js");
// More detailed error in the console if someone feels nice enough to file a bug report
// More detailed error in the console if someone feels nice enough to file a bug report
console.log("Error getting local unreliable-rules.js: " + e.message);
console.log("Error getting local extra-unreliable-rules.js: " + e.message);
})
})
.done( function () {
.done( function () {
// Script succeeded. You can use X now.
// Script succeeded. You can use X now.
if (Array.isArray(window.unreliableCustomRules)) {
if (Array.isArray(window.ExtraUnreliableCustomRules)) {
unreliableCustomRules.forEach(function(customRule) {
unreliableCustomRules.forEach(function(customRule) {
if (!(customRule.regex instanceof RegExp) || (typeof customRule.css !== 'object')) {
if (!(customRule.regex instanceof RegExp) || (typeof customRule.css !== 'object')) {
Line 121: Line 93:
var highlight = function() {
var highlight = function() {
// Check each external link on the page against each regex
$('.mw-parser-output a.external').each(function(_, link) {
$.each(rules, function(_, rule) {
if (typeof rule.filter !== 'undefined' && !rule.filter) {
return true;
}
if (rule.regex.test(link.href)) {
$(link).css(rule.css);
$(link).attr('title', rule.comment || '');
return false;
}
});
});

// Check list items against each regex to catch further reading/bibliography items without links
$('.mw-parser-output ul li, .mw-parser-output ol:not(.references) li, .reference-text:not(:has(a))')
.each(function(_, li) {
$.each(rules, function(_, rule) {
if (typeof rule.filter !== 'undefined' && !rule.filter) {
return true;
}
if (rule.regex.test(li.textContent)) {
$(li).css(rule.css);
$(li).attr('title', rule.comment || '');
return false;
}
});
});
let n = mw.config.get('wgNamespaceNumber');
let n = mw.config.get('wgNamespaceNumber');
if (n === 0 || n == 118 || n === 2)
if (n === 0 || n == 118 || n === 2)
Line 164: Line 108:
}
}


$('.mw-parser-output p, .mw-parser-output b, .mw-parser-output i, .mw-parser-output s, .mw-parser-output codea').each(function(_, para) {
$('.mw-parser-output > p, .mw-parser-output > b, .mw-parser-output > i, .mw-parser-output > s, .mw-parser-output > code, .mw-parser-output > ul li, .mw-parser-output > ol:not(.references) li').each(function(_, para) {
const fixed = $(para).html().replace(merged_rule, str => `<strong style="${final_css}" title="${first_rule.comment || ''}">${str}</strong>`);
const fixed = $(para).html().replace(merged_rule, str => `<strong style="${final_css}" title="${first_rule.comment || ''}">${str}</strong>`);
$(para).html(`${fixed}`);
$(para).html(`${fixed}`);

Latest revision as of 20:28, 19 November 2020

// Instructions available at [[User:Moonythedwarf/extra-unreliable]]
// Feel free to request tweaks or additional sources to be covered on the talk page

// Adapted from https://en.wikipedia.org/w/index.php?title=Wikipedia:User_scripts/Requests&diff=939432100&oldid=939403363 by [[User:SD0001]]
// Updated from https://en.wikipedia.org/w/index.php?title=User:Jorm/unreliable.js&oldid=940556311 by [[User:Jorm]]
// Updated from https://en.wikipedia.org/w/index.php?title=User:SD0001/unreliabe.js&oldid=941114456 by [[User:SD0001]]
// Updated from https://en.wikipedia.org/w/index.php?title=User:SD0001/unreliable.js&action=edit by [[User:SD0001]]
// Updated from https://en.wikipedia.org/w/index.php?title=User:Creffett/unreliable.js&oldid=957395306 by [[User:Creffett]]
// Adapted from https://en.wikipedia.org/w/index.php?title=User:Headbomb/unreliable.js&oldid=987448454 by [[User:Headbomb]]

// Big thanks to various spam-fighters on and off wiki for helping provide resources to design the built-in regexes on.
// 

// \/ regex in links doesn't work as it should, use (%2F|\/) instead
$( function() {

	var rules = [
		// Language 1
		{
			comment: 'Promotional phrasing',
			// this regex kinda sucks
			regex: /(?:\bextensive\s+(?:experience|work)|\bthe\s+field|\bwe|\bour|\ball\s+rights\s+reserved|\brevolutionary|\byour|\baward(?:\s+|\-)winning|\bperfect|\bthe\s+community|\bon\s+the\s+rise\s+|(?:\(tm\)|™)|\binspiration|\bhere\s+(?:at|in)|\bstrive|\bthe\s+best|\b(?:low|amazing|incredible|unbeatable)\s+(?:price|cost)(?:s?)|\bunbeatable|\b100%\s+guaranteed|\bwide\s+selection|\bbothersome|\b(?:wildly|amazingly|outstandingly|)\s+popular|\btoday|\btommorow|\bfrenzy|\baffordable|\bloved|\bwell(?:\s+|\-)known|\bfastest\s+growing|\bpost|\bexciting\s+(?:day|week|year|month)|\bexciting|\bendless|\bcustomers|\bhousehold\s+name|\byou|\bpublished\s+\d\s+(?:seconds|minutes|hours|days|months|years)\s+ago|\bgreatest|\bbest\s+ever|\bmilestone|\bin\s+the\s+world)\b/gmi,
			css:  { "background-color": "#ea985d" },
			text_matcher: true,
		},
		
		// Language 2
		{
			comment: 'Promotional phrasing',
			// more bad regex!
			regex: /(?:\b(?:her|his)\s+(?:distinctive|powerful|unique|amazing|exceptional|exquisite|one\s+of\s+a\s+kind)\b|\b(?:explore|embracing|accepting|using|utilizing|creating|building)\s+ideas\b|\bnumerous|\bmore\s+than\b|\beffectively\s+(?:commit|turn|create|modify|sell)\b|\b(?:amazing|powerful|unique|exceptional|impressive)\s+technology\b|\bnew\s+standard\b|\bworld(?:\s+|)(?:reknown|reknowned|renowned|renown)\b)/gmi,
			css:  { "background-color": "#ea985d" },
			text_matcher: true,
		},
		
		// Language 3
		{
			comment: 'Promotional phrasing',
			// more bad regex!
			regex: /\b(?:own\s+new\s+world|eponymous|renowned|being\s+the\s+world|revolutionized|swiftly|(?:instant|growing)\s+popularity|clientele|breathes\s+life|coveted|(?:his|her|their)\s+audiences|ever\s+growing|upcoming\s+works)/gmi,
			css:  { "background-color": "#ea985d" },
			text_matcher: true,
		},
		
		// Language 4
		{
			comment: 'Promotional phrasing',
			// more bad regex!
			regex: /\b(?:world\’s\s+leading|extensive\s+range|in\s+the\s+world|innovative|market\s+leading|cutting(?:\s+|-)edge|pushing\s+the\s+boundaries|comprehensive)/gmi,
			css:  { "background-color": "#ea985d" },
			text_matcher: true,
		},
		
		// Language 5
		{
			comment: 'Promotional phrasing',
			regex: /\b(?:entrepreneur|motivational\s+(?:speaker|writer|author)|influencer|social\s+media\s+personality|rising\s+star|up\s+and\s+coming|notable\s+for|featured\s+in|famous|celebrity)/gmi,
			css:  { "background-color": "#ea985d" },
			text_matcher: true,
		},
		
		// Language 6
		{
			comment: 'Promotional phrasing',
			regex: /\b(?:safe\s+shopping|fast\s+delivery|world\'?s\s+most|prime\s+goal)/gmi,
			css:  { "background-color": "#ea985d" },
			text_matcher: true,
		},
	];
	// Dynamically load a user's custom rules from User:USERNAME/extra-unreliable-rules.js
	mw.loader.getScript('/w/index.php?title=User:' + encodeURIComponent(mw.config.get('wgUserName')) + 
	    '/extra-unreliable-rules.js&action=raw&ctype=text/javascript')
	.fail( function(e) {
		// Something's gone very wrong
        mw.log.error("Error retrieving your extra-unreliable-rules.js");
        // More detailed error in the console if someone feels nice enough to file a bug report
        console.log("Error getting local extra-unreliable-rules.js: " + e.message);
	})
    .done( function () {
        // Script succeeded. You can use X now.
		if (Array.isArray(window.ExtraUnreliableCustomRules)) {
			unreliableCustomRules.forEach(function(customRule) {
				if (!(customRule.regex instanceof RegExp) || (typeof customRule.css !== 'object')) {
					return mw.log.warn("Error parsing custom unreliable links rule: ", rule);
				}
				rules.push(customRule);
			});
		}
    })
    .always( function () {
        highlight();
    });
    
    var highlight = function() {
    	let n = mw.config.get('wgNamespaceNumber');
    	if (n === 0 || n == 118 || n === 2) 
    	{
    	const text_rules = rules.filter(rule => rule.text_matcher);
    	// All text_rules are assumed to have the /gmi flags when merged.
    	const merged_rule = new RegExp(`(?:${text_rules.reduce((accum, rule) => `${accum}|${rule.regex.source}`, "^\\b$")})`, 'gmi');
    	
    	// Due to limitations of this way of implementing it, only one rule's CSS and comment are used.
    	const first_rule = text_rules[0];
			
		let final_css = "";
		for (const i in first_rule.css) {
			final_css += `${i}: ${first_rule.css[i]};`;
		}

    	$('.mw-parser-output > p, .mw-parser-output > b, .mw-parser-output > i, .mw-parser-output > s, .mw-parser-output > code, .mw-parser-output > ul li, .mw-parser-output > ol:not(.references) li').each(function(_, para) {
		    const fixed = $(para).html().replace(merged_rule, str => `<strong style="${final_css}" title="${first_rule.comment || ''}">${str}</strong>`);
		    $(para).html(`${fixed}`);
		    return true;
	    });
    	}
    };

});