User:Evano1van/CustomAdvisor.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Evano1van/CustomAdvisor. |
// <nowiki>
// Check javascript regexes at http://www.cyber-reality.com/regexy.html
// Dependency http://en.wikipedia.org/wiki/User:Cameltrader/Advisor
// Read http://en.wikipedia.org/wiki/User:Cameltrader/Advisor#Contributors
// To add more India specific rules that you want, please ping me at [[User_talk:Evano1van]]
var ct = ct || {};
if(typeof ct.rules=='undefined'){
ct.rules = [];
}
ct.rules.push(function (s) {
var suggestions = [];
var replacement_dicts = [];
replacement_dicts.push({
'pattern' : /(((\s)*(-|—|–)?(\|)?(\s)*(The\s)?Time(s)* of India(\s)*)?\|(\s)*publisher(\s)*=(\s)*(articles\.)?timesofindia\.indiatimes\.com(\s)*)/gi,
'replacement':'|publisher=The Times of India',
'description':'Replace ToI publisher'
}
);
replacement_dicts.push({
'pattern' : /((\s)*(-|—|–)(\s)*((Tamil)|(Kannada)|(Telugu)|(Malayalam|Hindi))(\s)*Movie News(\s))*\|(\s)*publisher(\s)*=(\s)*Indiaglitz\.com/gi,
'replacement':'|publisher=IndiaGlitz',
'description':'Replace IndiaGlitz publisher'
}
);
replacement_dicts.push({
'pattern' : /((\s)*(-|—|–)*(\s)*((Tamil)|(Kannada)|(Telugu)|(Malayalam|Hindi))(\s)*Movie News(\s))*\|(\s)*publisher(\s)*=(\s)*Behindwoods\.com/gi,
'replacement':'|publisher=Behindwoods',
'description':'Replace Behindwoods publisher'
}
);
replacement_dicts.push({
'pattern' : /(\s)*\|(\s)*publisher(\s)*=(\s)*(S|s)ify\.com/gi,
'replacement':'|publisher=Sify',
'description':'Replace Sify publisher'
}
);
replacement_dicts.push({
'pattern' : /(\s)*\|date=(\s)*\|/g,
'replacement':null,
'description':'Try adding date if its in cite template'
}
);
replacement_dicts.push({
'pattern' : /(\&(#124;)?(-|—|–)?(\s)*DNA(\s)*India)?(\s)*\|(\s)*publisher(\s)*=(\s)*(www\.)?dnaindia\.com(\s)*/gi,
'replacement':'|publisher=DNA India',
'description':'Replace DNA publisher'
}
);
replacement_dicts.push({
'pattern' : /((\s)*(-|—|–)*(\s)*ibnlive(\s)*)?\|(\s)*publisher(\s)*=(\s)*Ibnlive\.in\.com/gi,
'replacement':'|publisher=CNN IBN',
'description':'Replace CNNIBN publisher'
}
);
replacement_dicts.push({
'pattern' : /((\s)*(-|—|–)*(\s)*Rediff\.com(\s)*Movies(\s)*)?\|(\s)*publisher(\s)*=(\s)*(Rediff\.com)(\s)*/gi,
'replacement':'|publisher=Rediff',
'description':'Replace Rediff publisher'
}
);
replacement_dicts.push({
'pattern' : /(\s)*(-|—|–)*(\s)*cinema(\s)preview(\s)stills(\s)gallery(\s)trailer(\s)video(\s)clips(\s)showtimes/gi,
'replacement':'',
'description':'Remove junk'
}
);
replacement_dicts.push({
'pattern' : /((\s)*(-|—|–)*(\s)*India Today)?(\s)*\|(\s)*publisher(\s)*=(\s)*Indiatoday\.intoday\.in(\s)*/gi,
'replacement':'|publisher=India Today',
'description':'Replace India Today publisher'
}
);
replacement_dicts.push({
'pattern' : /((\s)*(-|—|–)*(\s)*Outlook)?(\s)*\|(\s)*publisher(\s)*=(\s)*news\.outlookindia\.com(\s)*/gi,
'replacement':'|publisher=[[Outlook (magazine)|Outlook]]',
'description':'Replace Outlook publisher'
}
);
replacement_dicts.push({
'pattern' : /(\|author=)?TNN(\s)(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)(\s)[1-3]?[0-9]\,(\s)(1|2)(0|9|1){2}[0-9]\,(\s)[0-2][0-9]\.[0-9]{2}(A|P)M(\s)IST/g,
'replacement':'|agency=TNN',
'description':'Replace TNN agency'
}
);
replacement_dicts.push({
'pattern' : /((\s)*(-|—|–)*(\s)*OneIndia Entertainment(\s))?\|(\s)*publisher(\s)*=(\s)*Entertainment\.oneindia\.in/gi,
'replacement':'|publisher=OneIndia',
'description':'Replace One India publisher'
}
);
for (var j = 0; j < replacement_dicts.length; j++) {
var re = replacement_dicts[j]['pattern']
var matches = ct.getAllMatches(re, s);
for (var i = 0; i < matches.length; i++) {
var match = matches[i];
suggestions.push({
start: match.start,
end: match.end,
replacement: replacement_dicts[j]['replacement'],
description: replacement_dicts[j]['description'],
name: 'Cite-fix'
});
}
}
return suggestions;
});
ct.rules.push(function (s) {
var re = /({{lang\-(as|bn|gu|hi|kn|ml|mr|ne|or|pa|sa|sd|ta|te|ur)(\s)*\|[^}]*}})/g;
var matches = ct.getAllMatches(re, s);
var suggestions = [];
for (var i = 0; i < matches.length; i++) {
var match = matches[i];
suggestions.push({
start: match.start,
end: match.end,
replacement: "",
name: "LANG-TAG",
description: "INDIC SCRIPT. Remove if found in lead of India articles."
});
}
return suggestions;
});
// </nowiki>