Wikipedia talk:WikiProject User scripts/Scripts/WikiBreak Enforcer/script.js

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Protocol-relative[edit]

Hello. This line:

location = "http://"+location.host+"/w/index.php?title="
                        + "Special:Userlogout&returnto=Main_Page";

should probably be changed to:

location = "//"+location.host+"/w/index.php?title="
                        + "Special:Userlogout&returnto=Main_Page";

so that it works in HTTPS (secure protocol). Thanks, πr2 (tc) 04:14, 9 December 2012 (UTC)[reply]

Done -- DQ (ʞlɐʇ) 05:25, 19 December 2012 (UTC)[reply]

Protected edit request on 4 March 2014[edit]

Since addOnloadHook has been deprecated, should we change it to $(document).ready ? Thanks! Chmarkine (talk) 05:26, 4 March 2014 (UTC)[reply]

Done, Chmarkine. Please confirm that I did what you wanted, and ping me if I made a mistake. Nyttend (talk) 13:40, 4 March 2014 (UTC)[reply]

Pedantic protected edit request[edit]

A bit of pedantry, but I'd prefer to see the leading zero example changed to 09 rather than 07. octal 7 == decimal 7, so technically the 07 example isn't much of a problem, but 09 would be. Martijn Hoekstra (talk) 16:03, 19 January 2015 (UTC)[reply]

Done --Redrose64 (talk) 23:14, 19 January 2015 (UTC)[reply]

Created Sandbox Page[edit]

I created a sandbox page for this script. See Wikipedia:WikiProject User scripts/Scripts/WikiBreak Enforcer/script/sandbox.

UpsandDowns1234 16:08, 16 March 2017 (UTC)

Topicon[edit]

Please add the topicon to the page UpsandDowns1234 15:32, 23 March 2017 (UTC)[reply]

@UpsandDowns1234: Which topicon ? could you make the description a bit more elaborate? —TheDJ (talkcontribs)
@TheDJ: The fully protected topicon. UpsandDowns1234 16:19, 23 March 2017 (UTC)[reply]
In addition, @TheDJ:, would this and other pages be suitable for the JS content model? Jo-Jo Eumerus (talk, contributions) 15:43, 23 March 2017 (UTC)[reply]
I've changed the content model of the sandbox. I guess it could be done.. Give me some time to think it through definitively :) —TheDJ (talkcontribs) 16:00, 23 March 2017 (UTC)[reply]

@TheDJ: would you mind responding to this request please? — Martin (MSGJ · talk) 08:05, 28 March 2017 (UTC)[reply]

Making the enforcer a function?[edit]

It would be more useful if you made the script a function. Then all you would have to do is call the function to enforce the wikibreak. Here is the function:

function wikiBreakEnforcer(yr, mth, dy, h, m, s) {
/*** BEGIN WIKIBREAK ENFORCER ***/
 var date = { year: yr, month: mth, day: dy};
 var time = { hours: h, minutes: m, seconds: s };
 
 var currentDate = new Date();
 var enforcedBreakEnd = new Date(
  date.year,date.month-1,date.day,time.hours,time.minutes,time.seconds);
 if (currentDate <= enforcedBreakEnd) {
  alert("Enforced wikibreak until "+enforcedBreakEnd.toLocaleString()
   + "\n(now is "+currentDate.toLocaleString()+")\n\nBye!");
 }
/*** END WIKIBREAK ENFORCER ***/
}

No need to edit, all that needs to happen is the script imported and the function called. Much cleaner, huh? All that needs to be typed:

importScript("wikibreakenforcer.js");
wikiBreakEnforcer(2017, 3, 27, 0, 0, 0);

Is it possible that an administrator makes that happen? UpsandDowns1234 (Talk to me) (My Contribs) 06:31, 16 April 2017 (UTC)[reply]

Protected edit request on 6 February 2020[edit]

Please replace

		location = "//"+location.host+"/w/index.php?title="
			+ "Special:Userlogout&returnto=Main_Page";

with

		$('#pt-logout a').click();

This fixes the bug reported here. Basically, the thing is that MW changed (phab:T25227 I think) such that navigating to that URL no longer causes a log out (rather it just leads to a confirmation page). Simulating a click on the log out button (present across all skins) uses javascript to force a log out. This change has been tested. SD0001 (talk) 11:53, 6 February 2020 (UTC)[reply]

@SD0001: For me, in Firefox with Monobook, the suggested change doesn't work, either: it simply provides a popup dialog confirming the logout, which can be canceled to allow normal editing (though it might reappear on every page load). We'll likely need to directly invoke the logout API call. Writ Keeper  16:09, 10 February 2020 (UTC)[reply]
I've applied a change to the script to call the API, rather than messing around with redirects or simulated clicks (although there is still a redirect to the login page once the logout process is complete). Writ Keeper  18:13, 10 February 2020 (UTC)[reply]

Protected edit request on 10 February 2020[edit]

Remove <syntaxhighlight lang=javascript> (and </syntaxhighlight>); it is not necessary when the content model is JavaScript. * Pppery * it has begun... 22:00, 10 February 2020 (UTC)[reply]

 Done Writ Keeper  18:04, 11 February 2020 (UTC)[reply]