Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

User:MusikAnimal/userRightsManager.js

    From Wikipedia, the free encyclopedia
    <User:MusikAnimal
    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 theappropriate village pump.
    This codewill be executed when previewing this page.
    Thisuser script seems to have a documentation page atUser:MusikAnimal/userRightsManager.
    Note: After saving, you have to bypass your browser's cache to see the changes.Google Chrome,Firefox,Microsoft Edge andSafari: Hold down the⇧ Shift key and click theReload toolbar button. For details and instructions about other browsers, seeWikipedia:Bypass your cache.
    // <nowiki>// Some UI code adapted from [[User:Mr. Stradivarius/gadgets/Draftify.js]](function(){if(!/Wikipedia:Requests for permissions\//.test(document.title)){return;}varpermissionNames={'Account creator':'accountcreator','Autopatrolled':'autoreviewer','Confirmed':'confirmed','Event coordinator':'eventcoordinator','Extended confirmed':'extendedconfirmed','File mover':'filemover','Mass message sender':'massmessage-sender','New page reviewer':'patroller','Page mover':'extendedmover','Pending changes reviewer':'reviewer','Rollback':'rollbacker','Template editor':'templateeditor','Temporary account IP viewer':'temporary-account-viewer',};vartemplates={'Account creator':'Account creator granted','Autopatrolled':'Autopatrolledgiven','AutoWikiBrowser':'','Confirmed':'','Event coordinator':'Event coordinator granted','Extended confirmed':'','File mover':'Filemovergiven','Mass message sender':'Mass message sender granted','New page reviewer':'New Page Reviewer granted','Page mover':'Page mover granted','Pending changes reviewer':'Pending changes reviewer granted','Rollback':'Rollback granted 3','Template editor':'Template editor granted','Temporary account IP viewer':'Temporary account IP viewer granted',};varapi,permission=mw.config.get('wgTitle').split('/').slice(-1)[0],revisionId=mw.config.get('wgRevisionId'),tagLine=' (using [[User:MusikAnimal/userRightsManager|userRightsManager]])',permaLink,userName,dialog;mw.loader.using(['oojs-ui','mediawiki.api','mediawiki.widgets.DateInputWidget'],function(){api=newmw.Api();$('.perm-assign-permissions a').on('click',function(e){if(permission==='AutoWikiBrowser')returntrue;e.preventDefault();userName=$(this).parents('.plainlinks').find('a').eq(0).text();showDialog();});});functionshowDialog(){Dialog=function(config){Dialog.super.call(this,config);};OO.inheritClass(Dialog,OO.ui.ProcessDialog);Dialog.static.name='user-rights-manager';Dialog.static.title='Grant '+permission+' to '+userName;Dialog.static.actions=[{action:'submit',label:'Submit',flags:['primary','constructive']},{label:'Cancel',flags:'safe'}];Dialog.prototype.getApiManager=function(){returnthis.apiManager;};Dialog.prototype.getBodyHeight=function(){return208;};Dialog.prototype.initialize=function(){Dialog.super.prototype.initialize.call(this);this.editFieldset=newOO.ui.FieldsetLayout({classes:['container']});this.editPanel=newOO.ui.PanelLayout({expanded:false});this.editPanel.$element.append(this.editFieldset.$element);this.rightsChangeSummaryInput=newOO.ui.TextInputWidget({value:'Requested at [[WP:PERM]]'});this.expiryInput=newmw.widgets.DateInputWidget({$overlay:$('.oo-ui-window')});this.closingRemarksInput=newOO.ui.TextInputWidget({value:'{{done}} ~~~~'});this.watchTalkPageCheckbox=newOO.ui.CheckboxInputWidget({selected:false});varformElements=[newOO.ui.FieldLayout(this.rightsChangeSummaryInput,{label:'Summary'}),newOO.ui.FieldLayout(this.expiryInput,{label:'Expiry (optional)'}),newOO.ui.FieldLayout(this.closingRemarksInput,{label:'Closing remarks'})];if(!!templates[permission]){formElements.push(newOO.ui.FieldLayout(this.watchTalkPageCheckbox,{label:'Watch user talk page'}));}this.editFieldset.addItems(formElements);this.submitPanel=newOO.ui.PanelLayout({$:this.$,expanded:false});this.submitFieldset=newOO.ui.FieldsetLayout({classes:['container']});this.submitPanel.$element.append(this.submitFieldset.$element);this.changeRightsProgressLabel=newOO.ui.LabelWidget();this.changeRightsProgressField=newOO.ui.FieldLayout(this.changeRightsProgressLabel);this.markAsDoneProgressLabel=newOO.ui.LabelWidget();this.markAsDoneProgressField=newOO.ui.FieldLayout(this.markAsDoneProgressLabel);this.issueTemplateProgressLabel=newOO.ui.LabelWidget();this.issueTemplateProgressField=newOO.ui.FieldLayout(this.issueTemplateProgressLabel);this.stackLayout=newOO.ui.StackLayout({items:[this.editPanel,this.submitPanel],padded:true});this.$body.append(this.stackLayout.$element);$('.mw-widget-dateInputWidget').css('width','100%');};Dialog.prototype.onSubmit=function(){varself=this,promiseCount=!!templates[permission]?3:2;self.actions.setAbilities({submit:false});addPromise=function(field,promise){self.pushPending();promise.done(function(){field.$field.append($('<span>').text('Complete!').prop('style','position:relative; top:0.5em; color: #009000; font-weight: bold'));}).fail(function(obj){if(obj&&obj.error&&obj.error.info){field.$field.append($('<span>').text('Error: '+obj.error.info).prop('style','position:relative; top:0.5em; color: #cc0000; font-weight: bold'));}else{field.$field.append($('<span>').text('An unknown error occurred.').prop('style','position:relative; top:0.5em; color: #cc0000; font-weight: bold'));}}).always(function(){promiseCount--;// FIXME: maybe we could use a self.isPending() or somethingself.popPending();if(promiseCount===0){setTimeout(function(){location.reload(true);},1000);}});returnpromise;};self.markAsDoneProgressField.setLabel('Marking request as done...');self.submitFieldset.addItems([self.markAsDoneProgressField]);self.changeRightsProgressField.setLabel('Assigning rights...');self.submitFieldset.addItems([self.changeRightsProgressField]);if(!!templates[permission]){self.issueTemplateProgressField.setLabel('Issuing template...');self.submitFieldset.addItems([self.issueTemplateProgressField]);}addPromise(self.markAsDoneProgressField,markAsDone('\n:'+this.closingRemarksInput.getValue())).then(function(data){addPromise(self.changeRightsProgressField,assignPermission(this.rightsChangeSummaryInput.getValue(),data.edit.newrevid,this.expiryInput.getValue())).then(function(){// silently add user to MMS listif(permission==='New page reviewer'){addToMMSList();}elseif(permission==='Autopatrolled'){updateWhiteList();}if(!!templates[permission]){addPromise(self.issueTemplateProgressField,issueTemplate(this.watchTalkPageCheckbox.isSelected(),this.expiryInput.getValue()));}}.bind(this));}.bind(this));self.stackLayout.setItem(self.submitPanel);};Dialog.prototype.getActionProcess=function(action){returnDialog.super.prototype.getActionProcess.call(this,action).next(function(){if(action==='submit'){returnthis.onSubmit();}else{returnDialog.super.prototype.getActionProcess.call(this,action);}},this);};dialog=newDialog({size:'medium'});varwindowManager=newOO.ui.WindowManager();$('body').append(windowManager.$element);windowManager.addWindows([dialog]);windowManager.openWindow(dialog);}functionassignPermission(summary,revId,expiry){permaLink='[[Special:PermaLink/'+revId+'#User:'+userName+'|permalink]]';returnapi.postWithToken('userrights',{action:'userrights',format:'json',user:userName.replace(/ /g,'_'),add:permissionNames[permission],reason:'+'+permissionNames[permission]+'; '+summary+'; '+permaLink+tagLine,expiry:expiry===''?'infinity':expiry});}functionmarkAsDone(closingRemarks){varsectionNode=document.getElementById('User:'+userName.replace(/"/g,'.22').replace(/ /g,'_')),sectionNumber=$(sectionNode).siblings('.mw-editsection').find("a:not('.mw-editsection-visualeditor')").prop('href').match(/section=(\d+)/)[1];returnapi.postWithToken('edit',{format:'json',action:'edit',title:mw.config.get('wgPageName'),section:sectionNumber,summary:'/* User:'+userName+' */ done'+tagLine,appendtext:closingRemarks});}functionissueTemplate(watch,expiry){vartalkPage='User talk:'+userName.replace(/ /g,'_');returnapi.postWithToken('edit',{format:'json',action:'edit',title:talkPage,section:'new',summary:permission+' granted per '+permaLink+tagLine,text:'{{subst:'+templates[permission]+(expiry===''?'':'|expiry='+expiry)+'}}',sectiontitle:permission+' granted',watchlist:watch?'watch':'unwatch'});}functionaddToMMSList(){api.postWithToken('csrf',{format:'json',action:'editmassmessagelist',spamlist:'Wikipedia:New pages patrol/Reviewers/Newsletter list',add:'User talk:'+userName});}functionupdateWhiteList(){api.edit('Wikipedia:New pages patrol/Redirect autopatrol list',function(revision){varnewContent=revision.content.replace(newRegExp('\\*\\s*{{\\s*user2\\s*\\|\\s*'+userName+'\\s*}}\\n'),'');return{text:newContent,summary:'Removing '+userName+' who is now autopatrolled'+tagLine,minor:true};});}})();// </nowiki>
    Retrieved from "https://en.wikipedia.org/w/index.php?title=User:MusikAnimal/userRightsManager.js&oldid=1303953572"

    [8]ページ先頭

    ©2009-2025 Movatter.jp