Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Wikipedia:WikiProject User scripts/Scripts/WikiBreak Enforcer

Page protected
From Wikipedia, the free encyclopedia
<Wikipedia:WikiProject User scripts |Scripts

Shortcut

WikiBreak Enforcer is ascript that prevents a user fromlogging in before a certain date, to help enforce awikibreak. If the user logs in, they are automatically logged back out, but can still view or edit from themobile interface, or as alogged out user through theirIP address.

How to Use

Warning! Be careful not to make a mistake, or you may not be able to get back in at the end of your break. In cases of errors, aninterface admin can remove the script from your user JavaScript page for you.
  1. Copy the code underScript below between/*** BEGIN WIKIBREAK ENFORCER ***/ and/*** END WIKIBREAK ENFORCER ***/.
  2. Paste the code on youruser JavaScript page, and then change the lines starting withvar date andvar time to reflect the time you want your break to end (local time). Thevar date line defines the date your break will end, while thevar time defines the time on that day that your break will end. For example, for a break ending at 8:22 pm on 6 February 2019, one would enter the settings:
    vardate={year:2019,month:2,day:6};vartime={hours:20,minutes:22,seconds:0};
  3. Save the edited user JavaScript page.
    information Note: Previewing your edit will log you out, but will not implement the enforcer.
  4. Purge the page. If successful, you will be logged out.
  5. That's it: enjoy your wikibreak! 🙂

Script

/*** BEGIN WIKIBREAK ENFORCER ***/$(document).ready(function(){/*** Start editing here ***/// When you want to end your break?// no leading zeroes. (example: 9 - correct, 09 - incorrect)vardate={year:2020,month:2,day:11};vartime={hours:20,minutes:22,seconds:0};/*** Stop editing here ***/varcurrentDate=newDate();varenforcedBreakEnd=newDate(date.year,date.month-1,date.day,time.hours,time.minutes,time.seconds);$.getJSON("/w/api.php?action=query&meta=siteinfo&siprop=general&format=json",function(data){varserverTimeStr=data.query.general.time;// ISO 8601 stringvarserverTime=newDate(serverTimeStr);if(serverTime<enforcedBreakEnd){alert("Enforced wikibreak until "+enforcedBreakEnd.toLocaleString()+"\n(now is "+currentDate.toLocaleString()+")\n\nBye!");mw.loader.using(["mediawiki.api","mediawiki.user"]).then(function(){newmw.Api().post({action:'logout',token:mw.user.tokens.get('csrfToken')}).done(function(data){location="//"+location.host+"/w/index.php?title="+"Special:Userlogin&returnto=Main_Page";}).fail(function(){console.log("logout failed");});});}});});/*** END WIKIBREAK ENFORCER ***/

See also

Wikipediaaccounts andgovernance
Unregistered users
Registered users
Account security
Blocks, bans, sanctions,
global actions
Related to accounts
User groups
andglobal user groups
Advanced user groups
Committees and related
Governance
Retrieved from "https://en.wikipedia.org/w/index.php?title=Wikipedia:WikiProject_User_scripts/Scripts/WikiBreak_Enforcer&oldid=1283053269"
Hidden category:

[8]ページ先頭

©2009-2025 Movatter.jp