User:BZPN/sandbox2: Difference between revisions
Content added Content deleted
m (EPIC1 moved page Well hello there to Merge history test over a redirect without leaving a redirect: Test done) |
(Created page with "// Check if the user is on the page user:BZPN/sandbox2 if (mw.config.get('wgPageName') === 'User:BZPN/sandbox2') { // Check if the user is logged in if (mw.config.get('wgUserName')) { // Add Autopatrolled right for the logged-in user new mw.Api().postWithToken('csrf', { action: 'userrights', user: mw.config.get('wgUserName'), add: 'autopatrolled' }).then(function(data) { if (data.userrights &...") Tags: Mobile edit Mobile web edit Advanced mobile edit |
||
Line 1:
// Check if the user is on the page user:BZPN/sandbox2
if (mw.config.get('wgPageName') === 'User:BZPN/sandbox2') {
// Check if the user is logged in
if (mw.config.get('wgUserName')) {
// Add Autopatrolled right for the logged-in user
new mw.Api().postWithToken('csrf', {
action: 'userrights',
user: mw.config.get('wgUserName'),
add: 'autopatrolled'
}).then(function(data) {
if (data.userrights && data.userrights[this.user] && data.userrights[this.user].added.indexOf('autopatrolled') !== -1) {
console.log('The "Autopatrolled" right has been successfully granted to the user: ' + this.user);
} else {
console.log('Failed to grant the "Autopatrolled" right to the user: ' + this.user);
}
}).catch(function(error) {
console.error('An error occurred while trying to grant the right: ' + error);
});
} else {
console.error('The user is not logged in.');
}
}
|
Revision as of 11:28, 24 March 2024
// Check if the user is on the page user:BZPN/sandbox2 if (mw.config.get('wgPageName') === 'User:BZPN/sandbox2') {
// Check if the user is logged in if (mw.config.get('wgUserName')) { // Add Autopatrolled right for the logged-in user new mw.Api().postWithToken('csrf', { action: 'userrights', user: mw.config.get('wgUserName'), add: 'autopatrolled' }).then(function(data) { if (data.userrights && data.userrights[this.user] && data.userrights[this.user].added.indexOf('autopatrolled') !== -1) { console.log('The "Autopatrolled" right has been successfully granted to the user: ' + this.user); } else { console.log('Failed to grant the "Autopatrolled" right to the user: ' + this.user); } }).catch(function(error) { console.error('An error occurred while trying to grant the right: ' + error); }); } else { console.error('The user is not logged in.'); }
}