// Adapted from [[User:Headbomb/unreliable.js]]
// \/ regex in links doesn't work as it should, use (%2F|\/) instead
$( function() {
const rules = [
// Identifiers
{
regex: /\b(?:arxiv\.org|adsabs\.harvard\.edu|doi\.org|pubmed\.ncbi\.nlm\.nih\.gov|ncbi\.nlm\.nih\.gov(%2F|\/)pubmed|citeseerx\.ist\.psu\.edu|handle\.net|jstor\.org|lccn\.loc\.gov|www\.ams\.org(%2F|\/)mathscinet|mathscinet\.ams\.org(%2F|\/)mathscinet|worldcat\.org|osti\.gov|ssrn\.com|openlibrary\.org|semanticscholar\.org\/CorpusID|zbmath\.org)/,
css: { "background-color": "#eeffee"}
},
// Could probably be converted
{
regex: /\b(?:psycnet.apa.org|ads\.harvard\.edu|bioone\.org|tandfonline\.com|informahealthcare\.com|nature\.com|sciencedirect.com|sciencemag\.org|ieeexplore\.ieee\.org|(%2F|\/)doi(%2F|\/)|10\.\d{4,5})/,
css: { "background-color": "#ffeedd"}
},
//{
// regex: /\b(?:ncbi\.nlm\.nih\.gov(%2F|\/)pmc)/,
// css: { "background-color": "#eeeeff"}
//}
];
// 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);
return false;
}
});
});
// Check list items against each regex to catch further reading/bibliography items without links
$('.mw-parser-output ul li:not(:has(a)), .mw-parser-output ol:not(.references) li:not(:has(a)), .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);
return false;
}
});
});
} );