User:Xover/seawall.js
Jump to navigation
Jump to search
Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Cmd-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (Cmd-Shift-R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Clear the cache in Tools → Preferences
For details and instructions about other browsers, see Wikipedia:Bypass your cache.
Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the central discussion page, Scriptorium. The code will be executed when previewing this page under some skins, including Monobook. You can in the interim if you wish to refresh the content sooner under another skin. |
Documentation for this script can be added at User:Xover/seawall. |
/* global $, mw */
"use strict";
// Make sure the necessary modules are loaded
mw.loader.using(['mediawiki.util', 'mediawiki.api'], function() {
// Wait for the page to be parsed (new-style $(document).ready())
$(function() {
// Add portlets to turn flood flag on or off
var floodonPortlet = mw.util.addPortletLink(
'p-cactions', '#', 'Flood flag ON', 'ca-floodon', 'Turn the flood flag ON'
);
$(floodonPortlet).click(function (event) {
event.preventDefault();
floodUp();
});
var floodoffPortlet = mw.util.addPortletLink(
'p-cactions', '#', 'Flood flag OFF', 'ca-floodoff', 'Turn the flood flag OFF'
);
$(floodoffPortlet).click(function (event) {
event.preventDefault();
floodDown();
});
// Flag it if +flood is on
if ($.inArray('flood', mw.config.get('wgUserGroups')) >= 0) {
$('#firstHeading').css('background', 'repeating-linear-gradient(to right,rgba(0,0,0,0.4),rgba(0,0,0,0.4) 10px,rgba(255,255,0,0.6) 10px,rgba(255,255,0,0.6) 20px)');
}
}); // END: $(document).ready()
}); // END: mw.loader.using()
// Turn flood flag on
function floodUp () {
var api = new mw.Api();
var params = {
action: 'userrights',
user: mw.config.get('wgUserName'),
add: 'flood',
reason: '+flood for bulk action',
format: 'json'
};
api.postWithToken('userrights', params).done(function (data) {
$('#firstHeading').css('background', 'repeating-linear-gradient(to right,rgba(0,0,0,0.4),rgba(0,0,0,0.4) 10px,rgba(255,255,0,0.6) 10px,rgba(255,255,0,0.6) 20px)');
});
}
// Turn flood flag off
function floodDown () {
var api = new mw.Api();
var params = {
action: 'userrights',
user: mw.config.get('wgUserName'),
remove: 'flood',
reason: '-flood after bulk action',
format: 'json'
};
api.postWithToken('userrights', params).done(function (data) {
$('#firstHeading').css('background', 'revert');
});
}