Jump to content

User:Jorm/unreliable.js

From Wikipedia, the free encyclopedia
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
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.
// In developpment, not yet ready to be used
// Adapted from https://en.wikipedia.org/w/index.php?title=Wikipedia:User_scripts/Requests&diff=939432100&oldid=939403363 by [[User:SD0001]]

// Unreliable websites [[WP:RSPSOURCES]], BL = Blacklisted, DEP = Deprecated, GUN = Generally Unreliable


$( function() {
	const BL_HREFS_RGX = /\b(test\.blacklist\.org|112\.ua|112\.international|breitbart\.com|infowars\.com|lenta\.ru|veteranstoday\.com|city-data\.com|globalresearch\.ca|examiner\.com|famousbirthdays\.com|liveleak\.com|lulu\.com|mylife\.com|naturalnews\.com|thepointsguy\.com|zoominfo\.com|newswar\.com|\reunion\.com)/;

	const DEP_HREFS_RGX = /\b(test\.deprecated\.org|crunchbase\.com|dailycaller\.com|dailymail\.co\.uk|theepochtimes\.com|thegatewaypundit\.com|hispantv\.com|hispantv\.ir|last\.fm|lifesitenews\.com|campaignlifecoalition\.com|mintpressnews\.com|nationalenquirer\.com|newsoftheworld\.co\.uk|nndb\.com|occupydemocrats\.com|oann\.com|rateyourmusic\.com|thesun\.co\.uk|takimag\.com|telesurtv\.net|telesurenglish\.net|vdare\.com|wnd\.com)/;

	const GUN_HREFS_RGX = /\b(test\.generallyunreliable\.org|alternet\.org|amazon\.com|ancestry\.com|answers\.com|baike\.baidu\.com|bild\.de|theblaze\.com|conservativereview\.com|blogger\.com|celebritynetworth\.com|cesnur\.org|cnsnews\.com|coindesk\.com|cracked\.com|express\.co\.uk|dailykos\.com|dailystar\.co\.uk|discogs\.com|electronicintifada\.net|familysearch\.org|fandom\.com|wikia\.org|wikia\.com|findagrave\.com|findmypast\.co\.uk|gawker\.com|geni\.com|goodreads\.com|heatst\.com|imdb\.com|indymedia\.org|ibtimes\.com|jezebel\.com|linkedin\.com|livejournal\.com|marquiswhoswho\.com|mediabiasfactcheck\.com|medium\.com|metro\.news|thenewamerican\.com|theonion\.com|patheos\.com|presstv\.com|quadrant\.org\.au|quillette\.com|quora\.com|rt\.com|scribd\.com|sputniknews\.com|stackexchange\.com|stackoverflow\.com|mathoverflow\.net|askubuntu\.com|thetruthaboutguns\.com|tunefind\.com|tvtropes\.org|twitter\.com|urbandictionary\.com|venezuelanalysis\.com|vgchartz\.com|westernjournal\.com|whosampled\.com|wordpress\.com|youtube\.com|zerohedge\.com)/;

	// Wikimedia-related websites (Main/Draft spaces only)
	const WIKI_HREFS_RGX = /\b(test\.wiki\.org|wikidata\.org|wikileaks\.org|wikinews\.org|wikipedia\.org)/;

	// Unreliable academic journals see [[Special:AbuseFilter/891]], [[WP:CITEWATCH/SETUP]], [[User:JzG/Predatory]] and https://beallslist.net/
	const PRED_HREFS_RGX = /\b(test\.predatory\.org|academicjournals\.com|academicjournals\.net|academicjournals\.org|academicpub\.org|academicresearchjournals\.org|aiac\.org\.au|aicit\.org|alliedacademies\.org|arcjournals\.org|ashdin\.com|aspbs\.com|avensonline\.org|biomedres\.info|biopublisher\.ca|bowenpublishing\.com|ccsenet\.org|cennser\.org|clinmedjournals\.org|cluteinstitute\.com|cpinet\.info|cscanada\.net|davidpublisher\.org|etpub\.com|eujournal\.org|growingscience\.com|grdspublishing\.org|hanspub\.org|hoajonline\.com|hrmars\.com|iacsit\.org|iamure\.com|idosi\.org|igi-global\.com|iises\.net|iiste\.org|imedpub\.com|informaticsjournals\.com|innspub\.net|intechopen\.com|intechweb\.org|interesjournals\.org|internationaljournalssrg\.org|ispacs\.com|ispub\.com|jaypeejournals\.com|jpmedpub\.com|jaypeebrothers\.com|julypress\.com|juniperpublishers\.com|kowsarpub\.com|kspjournals\.org|m-hikari\.com|macrothink\.org|mathewsopenaccess\.com|mecs-press\.org|medwelljournals\.com|oapublishinglondon\.com|oatext\.com|omicsonline\.org|ospcindia\.org|researchleap\.com|sapub\.org|scholink\.org|scialert\.net|scidoc\.org|sciencedomain\.org|sciencedomains\.org|sciedu\.ca|sciencepg\.com|sciencepub\.net|sciencepubco\.com|sciencepublication\.org|sciencepublishinggroup\.com|scipg\.net|scipress\.com|scirp\.org|scopemed\.com|sersc\.org|sphinxsai\.com|\.ssjournals\.com|thesai\.org|waset\.org|witpress\.com|worldwidejournals\.com|zantworldpress\.com)/;

	const PRED_DOIS_RGX = /10\.(0001|11648|1166|1234|12677|12692|12720|12988|13005|13172|13188|14257|14303|14419|14445|1453|14569|14662|15415|15373|15680|15761|17265|18005|18052|18311|18775|19030|19044|19070|19080|1999|20319|20431|20472|20849|20902|21102|21767|22158|23937|2495|30654|30845|35841|36648|3844|3923|3968|4066|4018|4156|4172|4236|4303|5005|5267|5296|5376|5430|5455|5539|5567|5580|5772|5812|5815|5829|5897|5899|5923|5963|6007|7243|7439|7537|7575|7718|7763|9734)\b/;

	// Sources that traditionally fail [[WP:MEDRS]], but which could be used for other more routine claims
	const MEDRS_HREFS_RGX = /\b(test\.medrs\.org|mdpi\.com|frontiersin\.org|hindawi\.com|medknow\.com|benthamopen\.com|dovepress\.com|wjgnet\.com|bioscience\.org|f1000\.com|e-century\.org|pulsus\.com)/;

	const MEDRS_DOIS_RGX = /10\.(0002|1100|1155|11569|12688|12703|12998|13105|19144|20944|21282|2147|2174|2741|32545|3389|3390|3410|35711|35712|35713|35995|3748|3814|4061|4089|4103|4175|4239|4240|4251|4252|4253|4254|4291|4292|4329|4330|4331|5306|5312|5313|5314|5315|5316|5317|5318|5319|5320|5321|5402|5409|5410|5411|5412|5492|5493|5494|5495|5496|5497|5498|5499|5500|5501|5527|5528|5662|6064|6219|7167|7217|7490)\b/;

	// May or maybe not contain preprints, predatory, or self-published materials
	const WARN_HREFS_RGX = /\b(test\.warn\.org|academia\.edu|arxiv\.org|citeseerx\.ist\.psu\.edu|researchgate\.net|peerj\.com\/preprints|biorxiv\.org|medrxiv\.org|eartharxiv\.org|psyarxiv\.com|osf\.io\/preprints|ssrn\.com|chemrxiv\.org|docs\.google\.com)/;

	// Varies with the contributor or topic
	const CONT_HREFS_RGX = /\b(test\.contributors\.org|forbes\.com|huffpost\.com|aa\.com\.tr)/;

	// 1101\/\d+ doesn't seem to work for some weird reason?
	const WARN_DOIS_RGX = /10\.(0003|1101\/\d+|2139|7287|13140|20935|31223|31227|31234|31235)\b/;

	// CSS colors
	const STYLES = {
		cssBL: { "background-color": "#222", "color": "#ddd", "border": "1px solid #cc0000" },
		cssDEP: { "background-color": "#ffbbbb" },
		cssGUN: { "background-color": "#ffdddd" },
		cssWIKI: { "background-color": "#ffdddd" },
		cssCONT: { "background-color": "#ffffdd" },
		cssPRED: { "background-color": "#ffbbbb" },
		cssWARN: { "background-color": "#ffffdd" },
		cssMEDRS: { "background-color": "#ffffdd" }
	}

	$('.mw-parser-output a.external').each(function() {
		if (DEP_HREFS_RGX.test(this.href)) {
			$(this).css(STYLES['cssDEP']);
		}
		if (BL_HREFS_RGX.test(this.href)) {
			$(this).css(STYLES['cssBL']);
		}
		if (GUN_HREFS_RGX.test(this.href)) {
			$(this).css(STYLES['cssGUN']);
		}
		if (PRED_HREFS_RGX.test(this.href)) {
			$(this).css(STYLES['cssPRED']);
		}
		if (PRED_DOIS_RGX.test(this.href)) {
			$(this).css(STYLES['cssPRED']);
		}
		if (WARN_HREFS_RGX.test(this.href)) {
			$(this).css(STYLES['cssWARN']);
		}
		if (WARN_DOIS_RGX.test(this.href)) {
			$(this).css(STYLES['cssWARN']);
		}
		if (MEDRS_HREFS_RGX.test(this.href)) {
			$(this).css(STYLES['cssMEDRS']);
		}
		if (MEDRS_DOIS_RGX.test(this.href)) {
			$(this).css(STYLES['cssMEDRS']);
		}
		if (mw.config.get('wgNamespaceNumber') == '0') {
			if (WIKI_HREFS_RGX.test(this.href)) {
				$(this).css(STYLES['cssWIKI']);
			}
		}
		if (mw.config.get('wgNamespaceNumber') == '118') {
			if (WIKI_HREFS_RGX.test(this.href)) {
				$(this).css(STYLES['cssWIKI']);
			}
		}
		if (CONT_HREFS_RGX.test(this.href)) {
			$(this).css(STYLES['cssCONT']);
		}
	});
} );