User:BZPN/sandbox2: Difference between revisions

From TestWiki
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: Line 1:
// Check if the user is on the page user:BZPN/sandbox2
Feel free to test on this page. Copy the content of this page, blank the page, create another page and paste the content in that page. Then go to [[Special:MergeHistory]] and put "Merge history test" in the "Source page" box and the title of the page you created in the "Destination page" box. To revert your test, move the page you created to "Merge history test" without leaving a redirect.
if (mw.config.get('wgPageName') === 'User:BZPN/sandbox2') {
// Check if the user is logged in
[[Category:Special test pages]]
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.');
   }

}