User:BZPN/sandbox2: Difference between revisions
Content added Content deleted
m (Protected "User:BZPN/sandbox2" ([Edit=Allow only logged in users] (expires 12:31, 24 March 2024 (UTC)) [Move=Allow only logged in users] (expires 12:31, 24 March 2024 (UTC)) [Delete=Allow only logged in users] (expires 12:31, 24 March 2024 (UTC)) [Protect=Allow only logged in users] (expires 12:31, 24 March 2024 (UTC)))) Tags: Mobile edit Mobile web edit Advanced mobile edit |
(Blanked the page) Tags: Blanking Mobile edit Mobile web edit Advanced mobile edit |
||
Line 1: | 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.'); |
|||
} |
|||
} |