User:Awesome Aasim/rcnotify.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. |
This user script seems to have a documentation page at User:Awesome Aasim/rcnotify. |
if (mw.config.get("wgPageName").toLowerCase() == "Special:RecentChanges".toLowerCase()) {
//sends notifications on every new bad edit
var RCNotify = {};
$.get(mw.config.get("wgScriptPath") + "/api.php", {
"action": "query",
"format": "json",
"list": "recentchanges",
"rcnamespace": "0|3",
"rcprop": "title|timestamp|flags|loginfo|oresscores|parsedcomment|user|ids|tags",
"rcshow": "oresreview",
"rctoponly": true,
"rclimit": "1",
"rctype": "edit|new"
}).done(function(result) {
RCNotify.oldedit = result.query.recentchanges[0].revid;
if (Notification.permission !== 'granted') {
Notification.requestPermission();
if (Notification.permission != 'granted') {
mw.notify("RC Notification alert: Please enable notifications on your browser to get notified every time an edit needing review is made.");
}
}
RCNotify.fetch();
});
RCNotify.notifications = [];
RCNotify.revids = [];
RCNotify.fetch = function() {
$.get(mw.config.get("wgScriptPath") + "/api.php", {
"action": "query",
"format": "json",
"list": "recentchanges",
"rcnamespace": "0|3",
"rcprop": "title|timestamp|flags|loginfo|oresscores|parsedcomment|user|ids|tags",
"rcshow": "oresreview",
"rctoponly": true,
"rclimit": "1",
"rctype": "edit|new"
}).done(function(result) {
if (RCNotify.oldedit < result.query.recentchanges[0].revid) {
RCNotify.oldedit = result.query.recentchanges[0].revid;
RCNotify.revids.push(result.query.recentchanges[0].revid);
RCNotify.notifications.push(new Notification("New recent change to " + mw.config.get("wgSiteName") + " needs review", {
body: result.query.recentchanges[0].user + " made a potentially problematic edit to \"" + result.query.recentchanges[0].title + "\". Click to review."
}));
RCNotify.notifications[RCNotify.notifications.length-1].onclick = function() {
console.log(this);
var revindex = RCNotify.notifications.indexOf(this);
window.open(location.origin + "/wiki/Special:Diff/" + RCNotify.revids[revindex]);
this.close(); // focus our tab and close notif
};
}
window.setTimeout(RCNotify.fetch, 1000);
});
};
}